本文介绍了与时间相关的中断在Windows的汇编中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用汇编语言创建一个小程序,该程序会延迟几秒钟.

I wanted to create a small program in Assembly language, that delays for several seconds.

我正在使用Windows XP SP3,并打开了一个DOS窗口,并运行了 debug.exe

I am using Windows XP SP3, and opened a DOS window, and ran debug.exe

我在这里输入了这个简短的汇编程序:

I entered there this short Assembly program:

MOV DX,0900

MOV DX,0900

MOV AH,86

MOV AH,86

INT 15

在中断15h中执行功能86h,执行延迟,延迟的持续时间以CX,DX为单位,以MicroSeconds为单位.

Function 86h in Interrupt 15h, performs a delay,and the Duration for the delay is in CX,DX, in MicroSeconds.

因此,例如,如果我想延迟4秒,那么它就是4,000,000微秒= 3D0900h,这就是我放在CX,DX中的内容.

So If for example I want to delay for 4 seconds, then it's 4,000,000microseconds = 3D0900h,and that's what I put in CX,DX.

运行这个简短的程序,很遗憾,它不会执行任何延迟,它会立即退出.

Running this short program, unfortunately does not perform any delay,it exits immediately.

然后我尝试了另一个中断功能:

I then tried another interrupt function:

在中断1Ah中,功能号0将PC的时钟计数返回到CX,DX.每个滴答是1/18.2秒.

Function number 0, in Interrupt 1Ah, returns the PC's clock count, to CX,DX.Each tick is 1/18.2 seconds.

然后我进入并运行了这个简短程序:

I then entered and ran this short program:

INT 1A

但是不幸的是,运行后CX和DX都等于0000h.

But unfortunately, CX and DX both equal 0000h after running it.

是否有2个与时间相关的中断在Windows中不起作用的原因?看来其他中断也可以工作..

Is there a reason why 2 Time related interrupts don't work in Windows?It seems that other interrupts do work..

有什么我可以做的,以便可以实现我要编写的小型延迟程序吗?

Is there anything I can do to make them work, so I can achieve the small delay program that I want to write?

谢谢

推荐答案

在欧洲,对于您在CodeReview上发现的延迟问题,有一个极好的解决方案.
它直接使用地址为0040h:006Ch的BIOS计时器滴答变量,而不是通过int 1Ah上的函数00h询问其值.

Omer, there's an excellent solution to your delaying problem that I found on CodeReview.
It uses the BIOS timer tick variable at address 0040h:006Ch directly rather than asking it's value through function 00h on int 1Ah.

请看一看 https://codereview.stackexchange.com/questions/101035/一种衡量游戏速度的低技术方法

这篇关于与时间相关的中断在Windows的汇编中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 09:33