【发布时间】:2014-01-01 10:15:26
【问题描述】:
我正在尝试在 NASM 程序集中使用 Windows API,只是一些基本的函数调用等等。所以,我去了 MSDN 网站并阅读了有关 Beep 功能的信息。它说它需要两个值,都是双字,频率和持续时间。所以这就是我的汇编程序的样子:
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 毫秒。无论我将频率或持续时间更改为什么,它听起来总是一样的。为什么?
【问题讨论】:
-
您在哪个 Windows 版本上调用此函数?
-
Windows 7 64 位家庭版。
-
您以错误的顺序将调用参数推送到堆栈。
-
无论哪种方式,结果都是一样的。总是倒退吗?
标签: windows winapi assembly x86-64 nasm