x86 - What is wrong with this assembly code? -
it says invalid combination of opcode , operands
section .data name: db "what name?" name_l: equ $-name hello: db "hello" hello_l: equ $-hello section .bss name_v resb 255 section .test global _start: _start: mov eax, 4 mov eax, 1 mov ecx, name mov edx, name_l int 80h mov eax, 3 mov ebx, 0 mov ecx, name_v mov edx, 255 int 80h int eax, 4 mov ebx, 1 mov ecx, hello mov edx, hello_l int 80h mov eax, 4 mov ebx, 1 mov ecx, name_v mov edx, 255 int 80h mov eax, 1 mov eax, 0 int 80h
well, normally, assembler tell line offending one, , should examine opcode , operands ensure compatibility (or, @ minimum, let us know line is).
in meantime, have either incorrect or superfluous code in program after _start
:
mov eax, 4 mov eax, 1 ; should ebx
if these linux calls, you're lucky didn't assemble. passing random length sys_write
going cause sorts of grief :-) passing random exit value sys_exit
not advised:
mov eax, 1 mov eax, 0 ; should ebx int 80h
and certain want text
(code) section called test
?
you go long way toward making code readable using equ
values rather magic numbers , adding comments:
fn_exit equ 0 fb_read equ 3 fn_write equ 4 : mov eax, fn_write ; write mov ebx, 1 ; stdout (fd 1) mov ecx, name ; text write mov edx, name_l ; length of text write
Comments
Post a Comment