我編寫了IA32的以下彙編腳本。它應該從stdin中讀取一個數字,將其增加並將其輸出到stdout,但它不像預期的那樣工作,它不會打印任何東西(也許stdin的讀取不會終止,或者打印出來的東西是錯誤的?)彙編:從標準輸入讀取整數,遞增並打印到標準輸出
.section .text
.globl _start
_start:
movl $3, %eax # use syscall 3 (read) to read from stdin
movl $0, %ebx # reads from stdin (FD 0)
movl %edi, %ecx # store input in register %edi
movl $4, %edx # read one byte
int $0x80 # invoke system call to read from stdin
incl %edi # increment the value we got from stdin
movl $4, %eax # use syscall 4 (write) to print to screen
movl $1, %ebx # print to stdout (FD 1)
movl %edi, %ecx # pointer to text to write out
movl $4, %edx # length of text to write out (1 byte)
int $0x80 # invoke system call to write to stdout
movl $1, %eax # use syscall 1 (exit) to exit
movl $0, %ebx # error code = 0
int $0x80 # invoke system call
您是否看到錯誤?對於任何幫助,我感謝你在前進,
一切順利, 西蒙
只是好奇。這看起來像Linux程序集,對嗎? – Linuxios
是的,這是Linux程序集 – saimn