NASM程序集中的Windows API哔声function

我正在尝试在NASM程序集中使用Windows API,只是一些基本的函数调用和什么。 所以,我去了MSDN网站,了解了Beepfunction。 它表示,它需要两个值,包括双重字,频率和持续时间。 所以这就是我的汇编程序的样子:

NULL equ 0 ; null global _start ; entry point extern Beep, ExitProcess ; the stuff I need section .data beepfreq dd 37 ; limit of 37 to 32,767 beepdur dd 300 ; This is in milliseconds section .bss dummy resd 1 ; nothing section .text _start: push beepfreq ; beep frequency push beepdur ; beep duration call Beep ; call it push NULL call ExitProcess 

但是,当我运行程序时,嘟嘟声总是听起来相同,并且持续时间比300毫秒长。 不pipe我改变的频率或持续时间,它总是听起来一样。 为什么?

这个:

 push beepfreq ; beep frequency push beepdur ; beep duration call Beep ; call it 

应该:

 push dword [beepdur] push dword [beepfreq] call Beep ; call it 

第一; 参数被从右向左推(即,函数的第一个参数应该被最后推)。 其次; 在NASM语法中, push beepfreq意味着“ push beepfreq的地址”(如在MASM / TASM语法中push OFFSET beepfreq )。 为了得到在那个地址的值你使用括号。