I'm trying to make a simple x86 program that reverses a string, in this case: "ciao".
section .data
msg db "ciao"
len equ $ - msg
section .text
global _start
_start:
lea eax, [msg]
mov ebx, len
add eax, ebx-1
reverseloop:
push [eax]
sub eax, 1
cmp eax, [msg]
jl reverseloop
When I try to assemble it, I get the error:
main.asm:14: error: operation size not specified
So, I tried to specify the size, by modifying line 14 to:
push byte [eax]
And now I get the error:
main.asm:14: error: invalid combination of opcode and operands
I don't really understand what is the problem here.
The command I use to compile is:
nasm -f elf32 main.asm -o main.o
pushwith a memory operand only supports pushing a word or a dword. You can't push a byte. So you could only dopush word [eax]orpush dword [eax]but you can't dopush byte [eax]. See an Instruction Set Architecture document like: felixcloutier.com/x86/push