I'm trying to fill an array of double-precision (64-bit) real numbers using the loop instructions in NASM x86 16-bit, but I get the invalid effective address
error. The OS is Windows XP 32 bits, but the program actually runs as a MS-DOS 16-bit one.
For example:
mov cx, 10
fill_array:
fld qword[yArray + cx*8]
fstp qword[xArray + cx*8]
loop fill_array
Returns the previous error at the fld
and fstp
lines.
The arrays are declared this way:
yArray resq 10
xArray resq 10
I've also tried using a register as a pointer to the array, but, for example, fstp qword[ax]
also fails.
Is there a way to use indexed float arrays in 16-bit assembly? Do I need to use any particular FPU instructions?
On CPUs >= 386 you can use scaling even in 16-bit mode, but only with 32-bit registers:
But you have an "off-by-one error". If ECX=10 you address the eleventh element of the list and ECX=0 will end the loop i.e. it won't be processed. You can avoid that with a "hand-made" loop:
The "pure 8086" solution: