アセンブリ言語の学習に Windows 7 を使用しています。オブジェクト ファイルの作成には NASM を使用し、実行ファイルの作成には mingw を使用しています。
実行可能ファイルのコンパイルと実行に次のコマンドを使用しています
del hello.o
del hello.exe
nasm -f elf hello.asm
ld hello.o -o hello.exe
hello
hello.exe ファイルの実行中に、「hello.exe が動作を停止しました」というエラー メッセージが表示される
次のコマンドを使用している間
nasm -f bin hello.asm -o program.exe
以下に示すエラーが発生しました
私のプログラムコード
global _start ; global entry point export for ld
section .text
_start:
; sys_write(stdout, message, length)
mov eax, 4 ; sys_write syscall
mov ebx, 1 ; stdout
mov ecx, message ; message address
mov edx, length ; message string length
int 80h
; sys_exit(return_code)
mov eax, 1 ; sys_exit syscall
mov ebx, 0 ; return 0 (success)
int 80h
section .data
message: db 'Hello, world!',0x0A ; message and newline
length: equ $-message ; NASM definition pseudo-instruction