我知道它讓0進入ebx,但為什么?如果對你來說這是一個no-brainer問題,我很抱歉,這是我學習匯編和幾個月編程的第一周。
我沒有包括下面的所有內容,因為這是一個相當長的lmk,如果必要的話
該組件來自《從頭開始編程第6章》一書
組裝總結:
打開輸入和輸出文件,從輸入中讀取記錄,增加時間,將新記錄寫入輸出文件
SYS_EXIT is 1
LINUX_SYSCALL is 0x80
loop_begin:
pushl ST_INPUT_DESCRIPTOR(%ebp)
pushl $record_buffer
call read_record
addl $8, %esp
# Returns the number of bytes read. If it isn’t the same number we requested, then it’s either an end-of-file, or an error, so we’re quitting
cmpl $RECORD_SIZE, %eax
jne loop_end
#Increment the age
incl record_buffer + RECORD_AGE
#Write the record out
pushl ST_OUTPUT_DESCRIPTOR(%ebp)
pushl $record_buffer
call write_record
addl $8, %esp
jmp loop_begin
loop_end:
movl $SYS_EXIT, %eax
movl $0, %ebx <------------------------ THE INSTRUCTION'S PURPOSE THAT IM ASKING FOR
int $LINUX_SYSCALL
這相當于C中的
_exit(0);
;除了Linux內核使用不同的調用約定(參數在寄存器中傳遞,而不是在堆棧上傳遞)。movl $0, %ebx
正在將第二個參數(0)加載到內核調用約定的右側寄存器中。第一個參數是函數號(SYS_EXIT)。