在汇编中,'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