在彙編中,'pop'命令用於返回指定的值嗎?我似乎無法使其正常工作。我嘗試打印輸入以查看輸入是否已更改,但是在再次等待用戶輸入之前,程序會循環兩次。在Assey中,我的函數試圖返回一個值是否有問題?
數據聲明:
section .data
test db "Test",10
testLen equ $-test
這裏的輸入聲明
section .bss
input resb 1
則子程序調用:
section .text
global _start
_start:
sub esp,2 ;this is for the return value
call function ; call the subprogram
pop word[input]
mov eax,4
mov ebx,1
mov ecx,input
mov edx,1 ;1 character input only from user is expected
int 80h
mov eax,4
mov ebx,1
mov ecx,test
mov edx,testLen
int 80h
jmp _start
則子程序:
function:
mov eax,3
mov ebx,0
mov ecx,[esp+4]
mov edx,2 ;of length 2 because only 1 character is expected from user + the \n char
int 80h
ret
我在我的子程序'function'中的掃描程序中做錯了什麼?謝謝你能幫助我的人。剛開始學習Assembly的子程序,我無法弄清楚這個。一直呆在這個簡單的bug現在一個小時。
通常'pop'不用於返回,'mov eax,SOMETHING'是。但是這看起來像手寫的asm,並沒有遵循任何標準的調用約定。 – o11c 2014-10-10 04:20:03