Y
Y
yuki2021-10-25 18:23:18
assembler
yuki, 2021-10-25 18:23:18

NASM offset in array (invalid effective address)?

How can offset be done in nasm?
That is, you can do something like [string + 2], but I need to do it through a variable that increments (in my case, cx, that is, [string + cx]). When trying to perform such an action, "mov [str2 + cx], ax" knocks out invalid effective address

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
jcmvbkbc, 2021-10-25
@jcmvbkbc

How can offset be done in nasm?
[string + cx]
invalid effective address

It's not in the assembler, but in the processor device. x86 has base+offset addressing mode in 16-bit mode, but only the bx, si, di, and bp registers can act as the base. In this case, di is addressed relative to the segment register es, and bp is addressed relative to the segment register ss.
This is documented in Table 2-1 "16-Bit Addressing Forms with the ModR/M Byte" in volume 2A of the Intel Developer Manual, available for example here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question