nasm コンパイラと ld リンカを使用して、アセンブリ言語で hexdump ユーティリティを作成しました。このプログラムは、任意の入力ファイルの 16 進値をダンプすることになっています。 16バイトのバッファ。コードは
LoadBuff:
push ebx
push edx
push eax
mov eax,3 ;sys_read call
mov ebx,0 ;read from standard input
mov ecx,Buff ;pass the buffer adress
mov edx,BuffLen ;pass the number of bytes to be read at a time
int 80h ;call the linux kernel
mov ebp,eax
;cmp eax,0 ;number of characters read is returned in eax
;jz exit ;if zero character is returned i.e end of iinput file
;jump to exit
xor ecx,ecx
pop eax
pop edx
pop ebx
ret
行の場合
;cmp eax,0
;jz exit
ただし、コメントを付けてこれらの行を呼び出し元に含めて、ここではなく呼び出し元で同じ比較を行うと、このプロシージャ セグメント エラーが発生します。
gdb バックトレースが与える
#0 0x00000000 in ?? ()
なぜそのようなことが起こっているのですか?