NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: nobody on August 03, 2005, 05:34:55 PM
-
Hi.
I'm new in NASM and i''ve problem with syntax addressing for egzample ...
i want to do something like this:
mov [address],[base + bx*a+cx*b]
ax,bx contain indices
and i receive error massage, the same thing is with ( gas addr(%eax,%ebx,a) in NASM should be [addr+ebx*a+eax] and i receive error again ) what should i do to FIX it ... PLEASE help :-)
-
Not going to work with ax, cx - the rules for 16-bit addressing are different (if you need to use 16-bit regs, lookitup). Nor with more than one index!
[addr + ebx * a + eax] ought to work, provided that "a" is one of 1, 2, 4, 8.
If you can't get it working, post the exact code you're trying.
Best,
Frank
-
Thank You .. code is exremely simple because i'm just learning assembler, it's multiplying of two integer matrices, looking for determinant etc. but if i WANT :-D to use 16-bit registers .. i should use only one index ?? ( i've no opportunity to check it out now, and i can't find nothing about this in manual)
Lukas
-
Only one index in 32-bit code. No index at all in 16-bit instructions. 16-bit addressing consists of an offset (address) plus an (optional) base register, plus an (optional) index register. Base registers are bx and bp, index registers are si and di. So [addr + bx + si] is okay, but not [addr + si + di]. Quite lame!
You can use 32-bit instructions in 16-bit code. There's a "penalty" in the form of an address size override byte, but it's worth it (in many cases). Make sure the upper bits of registers are clear, and make sure the total offset doesn't exceed 0FFFFh, or you'll get a segment overrun exception.
Best,
Frank