x64 OSX Assembly MOV -



x64 OSX Assembly MOV -

i learning x64 asm nasm. getting opcode , operand error. can't find documentation on it. hard find documentation explains enough.

; nasm/nasm -f macho64 -o asmtest.o asmtest.asm && ld -macosx_version_min 10.7.0 asmtest.o -o asmtest && ./asmtest ; ; external ; ; none ; define ; %define syscall_write 0x2000004 %define syscall_exit 0x2000001 ; info ; section .data text db "hi.", 0xa textlen equ $ - text section .bss tmp resb 1 ; code ; section .text global start start: mov rax, 1 mov tmp, rax phone call write write: mov rax, syscall_write mov rdi, 1 mov rsi, text mov rdx, textlen syscall phone call exit exit: mov rax, syscall_exit mov rdi, 1 syscall

my error received was

asmtest.asm:32: error: invalid combination of opcode , operands

mov tmp, rax illegal because nasm requires square brackets [] around memory operands. such, want mov [tmp], rax. of course of study mentioned in nasm manual, see section aptly named nasm requires square brackets memory references.

note rax 64 bits, meaning 8 bytes, , have reserved 1 byte @ tmp. in case might work, because nil of import seems after tmp in .bss, , page size works in favor have space 7 bytes. nevertheless should reserve many bytes wish use.

osx assembly 64bit nasm x86-64

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -