为什么我的“ show_msg”功能不能正常工作?
org 100h
push str1
call show_msg
pop ax
mov ah, 4Ch
int 21h
show_msg:
mov ah, 9
mov bx, sp ;in 16bit bx is the only register that can act as a pointer (besides di and si)
mov dx, [bx]
int 21h
ret
str1 db 'Hello world!$'
Run Code Online (Sandbox Code Playgroud)
很有可能是因为[sp]在进入函数时包含返回码的地址,对于此程序,返回码的地址将是pop ax开头的任意地址。尝试更改mov dx, [bx]为mov dx, [bx+2],这将导致检索到函数入口之前推送的参数的值。