私はアセンブリの初心者です(実際、これは私の初めての試みです)。NASMとldリンカーを使用してこのx86アセンブリコードをMacで実行するにはどうすればよいか疑問に思いました。
SECTION .data ; Section containing initialised data
EatMsg: db "Eat at Joe's!",10
EatLen: equ $-EatMsg
SECTION .bss ; Section containing uninitialized data
SECTION .text ; Section containing code
global _start ; Linker needs this to find the entry point!
_start:
nop ; This no-op keeps gdb happy...
mov eax,4 ; Specify sys_write call
mov ebx,1 ; Specify File Descriptor 1: Standard Output
mov ecx,EatMsg ; Pass offset of the message
mov edx,EatLen ; Pass the length of the message
int 80H ; Make kernel call
MOV eax,1 ; Code for Exit Syscall
mov ebx,0 ; Return a code of zero
int 80H ; Make kernel call
このアセンブリコードはLinux用に作成された本からのものですが、LinuxとMacはどちらもUNIXベースのオペレーティングシステムであるため、アセンブリコードは一般的に同じであると想定しました。nasmとldを介してこれをmac実行可能ファイルに取得できない可能性があることに気付きましたが、可能であれば、どうすればよいでしょうか。そうでない場合は、このアセンブリコードをどのように変更して機能するようにしますが、一般的に同じことを行いますか?