Mail Archives: djgpp/2001/10/02/07:03:46
Don't forget to CC djgpp so others can help as well and so I can
answer by news which is how I prefer to read the djgpp list.
> : Would someone help me with the correct asm syntax for DJGPP for the
> : following Intel format instructions
>
> : mov AX, OFFSET count
>
> >>movw $count, %%ax
>
> How can you be sure the offset is being moved into ax, and not the value in
> count ??
I'm not. Or rather was not. I just tried it and it works as expected.
I think the answer to your question is "$" means a literal value,
i. e. it might do something strange but of all things it possibly
could do, it will _not_ move the contents of "count" into ax.
Actually here's one case where the AT&T syntax shines in comparision
with Intel:
"mov <something>, ax" will move something into ax. If you want
something literal moved into ax you specify it as literal.
In Intel syntax "mov ax, <something>" will do different things if
something is a literal or a variable. If "mov ax, 1" moves 1 into ax
then I'd expect "mov ax, my_var" to move what my_var is (an offset)
into ax, not the contents at the offset of my_var into ax - what a
mess! And still Intel do have a "take the contents" operator: [ ]. So
if they had had their brains connected while designing their syntax,
we could have had it like this: if you wanted the variables value
you'd use "mov ax, [ my_var ]" exactly as when you do "mov ax, [ bx ]"
Nasm, which claims it doesn't think for you, has the same misfeature,
I think.
Right,
MartinS
- Raw text -