I'm very new at this and I'm trying to move values from one array to the other, it suppose to be:
vec1 = 1, 2, 3, 4, 5
vec2 = 5, 4, 3, 2, 1
but I get an error: "instruction operands must be the same size"
TITLE program
.386
.model flat
extern _ExitProcess@4:Near
.data
vec1 WORD 1, 2, 3, 4, 5; original array
vec2 WORD 5 DUP(?)
.code
_main:
mov ebx, 0
mov ecx, lengthof vec1
DO:
mov eax, vec1[ebx]
mov vec2[ecx], eax
inc ebx
loop DO
push 0
call _ExitProcess@4
end _main
please help.
The first thing I'd be looking at is the fact the a WORD
is 16 bits wide and eax
is 32 bits wide. So, when you load something into eax
(without an explicit size specifier), you'll get 32 bits rather than 16.
In addition, I'm not convinced that your values of ecx
will be what you expect - you should check that, keeping in mind that it needs to iterate from n-1
down to 0
inclusive. The way you have it, it's going from n
to 1
.