I am beginner, trying to use masm6.11. (Intel 8086)
How do I point to these values without using "inc" or #[SI].
The displacement value comes frm a memory location that produces various values based on
previous cod conditions. eg. I might table to be loaded in SI ("DATA_1" amount of times)
ORG 100H
TABLE DB '0', '1', '5' ,'3' ,'4' ,'8' ,'6' ,'7' ,'8' ,'9'
if I do
"mov si, OFFSET TABLE "
Si would hold the value for 0, which is 30H.
Let's say I want to point to '8'. What do I do without having to tyoe "8" in the code.
I really really need help as soon as possible.
Hello! Welcome aboard!
mov si, TABLE
mov si, TABLE[0]
;both instructions put "0" in si
mov si, TABLE[2]
;put "5" in si
This is a quick answer, there are another ways. You should do some reading, 'cause this stuff is in the intro part of any material concerning assambly!
Forum search and your favorite search engine can do the job! :U
Regards,
Nick
Ok, but that is something that I did before. However, I am upgrading a program that does division, and stores the remainder in a memory location "REM".
si is alerady OFFSET to table.
Let's say the contents of REM is suppose to take SI to a specific location in "TABLE" so that I could put it into a register for the 21H INT.
I.E. I am suppose to get the correct displacement without typing in the displacement value.
ORG 100H
REM DB ?
ORG 140H
TABLE DB '0', '1', '2', '3', '4', 5', '6', '7', '8', '9'
My professor doesn't want me to do
mov al TABLE[3]
He wants the contents of "REM" to take it there.
It has to be that way for later expansion, if "TABLE" contents change to Letters and HEX values.
I'm working hard at it, but no progress.
note. "REM" is remainder from a division function.
mov bp,TABLE
mov al,[bp+REM]
mov al,[si+(rem-table)]
Those do not work.
Every other part of my code works but that part. I have tried other ways pn my own, but It just ended up giving me the correct values, but not from mthe tabel. I found that out when I re-arranged the numbers in the table to test it.
I really must learn to read the whole post... ::)
QuoteLet's say the contents of REM is suppose to take SI to a specific location in "TABLE" so that I could put it into a register for the 21H INT.
Try this
movzx bx,rem
mov al,[bx+si]
It says.
Instruction or register not accepted in current cpu mode.
Is movzx correct?
:lol
mov bp,TABLE
add bp,REM
mov si,bp
mov al,[si]
The correct value shows up in si and bp, but nothing goes into al. At the same time, the value that goes into si may look correct because the table goes in ascending order, but when I changed the values in the table, It was not actually pointing at the values "in" the table (it just added values to the 30H). I already got this far since a week ago. But, I am learning through u guys.
mov bl,rem
sub bh,bh
mov al,[bx+si]
movzx is a 386(?) instruction...
It didnt work.
If SI points to TABLE and REM has a valid (0,1,2...9) value then it should work. Post all of your code. Or fail your assignment ::).
This is suppose to be part of 300 line code. all other parts work. I see nothing going into al.
.MODEL SMALL
.STACK 64
.DATA
ORG 100H
TABLE DW '0','1','2','3','4','5','6','7','8','9'
ORG 140H
REM DB 05H
.CODE
.STARTUP
PNT PROC
mov si, TABLE
mov bl,REM
sub bh,bh
mov al,[bx+si]
ret
PNT ENDP
END
Since you've declared TABLE to be words, you need BX*2
mov bl,rem
sub bh,bh
shl bx,1
mov al,[bx+si]
and use
mov si,OFFSET TABLE
since you want the address of TABLE, not its first element
:lol
Declare table as bytes IMHO, as it was originally
QuoteThe correct value shows up in si and bp, but nothing goes into al. At the same time, the value that goes into si may look correct because the table goes in ascending order, but when I changed the values in the table, It was not actually pointing at the values "in" the table
Since we can't see all your code try some code segment overrides at the tricky bit, not sure of the syntax you guys use.
cs:mov al,[bx+si] kinda thing
you could also try:
mov bp,TABLE
mov dl,[REM]
xor dh,dh
add bp,dx
mov si,bp
mov al,[si]
My previous feeble attempt added the word at REM to bp instead of the byte.
Thanks alot. It works. I'm now just trying to fix a loop problem. After putting in key entries for the division, and it points and displays, after about 5 loops, it starts displaying weird displacement values. I think I should be able to fix that myself. Thanks.
The last two solutions are good.
Actually, the last one still gives some problems, so I will stick with Sinsi's solution. Thanks.