我在Mac OS X上用NASM做x86。复制一个例子并进行实验我注意到我的打印命令需要在其他参数之后将四个字节压入堆栈,但无法弄清楚为什么第五行是必要的:
1 push dword len ;Length of message
2 push dword msg ;Message to write
3 push dword 1 ;STDOUT
4 mov eax,4 ;Command code for 'writing'
5 sub esp,4 ;<<< Effectively 'push' Without this the print breaks
6 int 0x80 ;SYSCALL
7 add esp,16 ;Functionally 'pop' everything off the stack
我无法找到有关此问题的任何文档,并将参数推送到堆栈&#39; NASM / OS X似乎需要的语法。如果有人能指出我一般的资源,那么很可能也会回答这个问题。