I am trying to use this instruction movs[x] that moves an entire string. When using it on the NASM assembler, it is working well but with the MASM assembler, an error occurs.
NASM:
section .data
msg db 'Hello', 0
len equ $ - msg
section .bss
msg2 resb len
section .text
global CMAIN
CMAIN:
mov ecx, 0
mov ecx, len
mov esi, msg
mov edi, msg2
rep movsb
ret
The previous code is working well.
MASM:
.386
.model flat, c
.stack 50
.data
msg db 'Hello', 0
len equ $ - msg
msg2 db len dup(0)
.code
_start:
mov ecx, 0
mov ecx, len
mov esi, msg
mov edi, msg2
rep movsb
ret
end _start
The previous code always gives me Error A2022 instruction operands must be the same size
and points to those lines:
mov esi, msg
mov edi, msg2
I know the msg
and msg2
are 8-bit and ESI
register is 32-bit but there's no 8-bit ESI
, and why that code is working well on NASM?
How do I solve that problem?