如何创建在16位MASM大会86休眠功能? [英] How can I create a sleep function in 16bit MASM Assembly x86?
问题描述
我想创建16位MASM大会的x86睡眠/延迟过程,将,比如说,在屏幕上打印字符每500毫秒。
从我已经做了研究,似乎有三种方法来实现这一点 - 我想用使用CPU时钟周期一个
请注意我在Mac OS X雪豹运行Windows XP通过VMware Fusion的 - 我不知道这会影响什么。
。可能有人请点我在正确的方向,或提供code我可以调整的工作一块?谢谢!
在code,我发现应该是打印'A'的屏幕每秒,但不工作(我想反正用毫秒)。
TOP:
MOV AH,2C
INT 21
MOV BH,DH;卫生署当前的第二
GETSEC:;循环,直到目前的第二不等于最后,在波黑
MOV AH,2C
INT 21
CMP BH,DH;这里是退出循环和打印'A'的比较
JNE PRINTA
JMP GETSEC
PRINTA:
MOV AH,02
MOV DL,41
INT 21
JMP TOP
编辑:继GJ的建议,这里的工作程序。叫它
DELAY PROC
TIMER:
MOV AH,00H
INT 1AH
CMP DX,WAIT_TIME
JB TIMER
ADD DX,3; 1-18,其中较小的速度更快,18接近1秒
MOV WAIT_TIME,DX
RET
DELAY ENDP
其实你可以使用ROM BIOS中断为1Ah功能00H,读取当前时钟计数。或者你可以在地址$ 40读出DWORD:$ 6C,但你必须确保原子读。它是由MS-DOS在约18.2赫兹递增。欲了解更多信息,请阅读:的DOS时钟
I am trying to create a sleep/delay procedure in 16bit MASM Assembly x86 that will, say, print a character on the screen every 500ms. From the research I have done, it seems that there are three methods to achieve this - I would like to use the one that uses CPU clock ticks.
Please note I am running Windows XP through VMWare Fusion on Mac OS X Snow Leopard - I am not sure if that affects anything.
Could someone please point me in the right direction, or provide a working piece of code I can tweak? Thank you!
The code I have found is supposed to print 'A' on the screen every second, but does not work (I'd like to use milliseconds anyways).
TOP:
MOV AH,2C
INT 21
MOV BH,DH ; DH has current second
GETSEC: ; Loops until the current second is not equal to the last, in BH
MOV AH,2C
INT 21
CMP BH,DH ; Here is the comparison to exit the loop and print 'A'
JNE PRINTA
JMP GETSEC
PRINTA:
MOV AH,02
MOV DL,41
INT 21
JMP TOP
EDIT: Following GJ's advice, here's a working procedure. Just call it
DELAY PROC
TIMER:
MOV AH, 00H
INT 1AH
CMP DX,WAIT_TIME
JB TIMER
ADD DX,3 ;1-18, where smaller is faster and 18 is close to 1 second
MOV WAIT_TIME,DX
RET
DELAY ENDP
Actually you can use ROM BIOS interrupt 1Ah function 00h, 'Read Current Clock Count'. Or you can read dword at address $40:$6C but you must ensure atomic read. It is incremented by MS-DOS at about 18.2 Hz. For more information read: The DOS Clock
这篇关于如何创建在16位MASM大会86休眠功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!