How can I run this assembly code on OSX?
Starting to learn assembly, I was given some Hello World assembly code
created during the class on Linux. I would like to get it to work for
64-bit Mac OSX.
code.asm:
SECTION .data
hola: db "Hola!",10
tam: equ $-hola
SECTION .text
global main
main:
mov edx,tam
mov ecx,hola
mov ebx,1
mov eax,4
int 0x80
mov ebx,0
mov eax,1
int 0x80
This is what I do:
nasm -f macho32 -o object.o code.asm
gcc -m32 -o program object.o
Which tells me:
Undefined symbols for architecture i386: "_main", referenced from: start
in crt1.10.6.o ld: symbol(s) not found for architecture i386
Searching for this error, I found this question: nasm and gcc: 32 bit
linking failed (64 bit Mac OS X)
One answer says
The problem you're having is that you're creating a 32-bit Linux(ELF)
object file which isn't compatible with the Mac OS X object format. Try
switching '-f elf' to '-f macho32'.
But I'm definitely using -f macho32. So what would the problem be then?
No comments:
Post a Comment