我必须显示在屏幕上传递的时间,我一直在网上查找并找到如何设置延时但我不知道如何在屏幕上显示 这就是我现在所得到的(我甚至不知道这是否是这样做的方式)
delay proc
mov ah, 00
int 1Ah
mov bx, dx
jmp_delay:
int 1Ah
sub dx, bx
cmp dl, delaytime
jl jmp_delay
ret
delay endp
答案 0 :(得分:1)
时间是一个数字,您需要将其转换为字符串才能显示它。有很多程序要做,接下来我发一个(程序"美元"是次要的但是必要的):
;------------------------------------------
;CONVERT A NUMBER IN STRING.
;ALGORITHM : EXTRACT DIGITS ONE BY ONE, STORE
;THEM IN STACK, THEN EXTRACT THEM IN REVERSE
;ORDER TO CONSTRUCT STRING (STR).
;PARAMETERS : AX = NUMBER TO CONVERT.
; SI = POINTING WHERE TO STORE STRING.
proc number2string
;FILL BUF WITH DOLLARS.
push si
call dollars
pop si
mov bx, 10 ;DIGITS ARE EXTRACTED DIVIDING BY 10.
mov cx, 0 ;COUNTER FOR EXTRACTED DIGITS.
cycle1:
mov dx, 0 ;NECESSARY TO DIVIDE BY BX.
div bx ;DX:AX / 10 = AX:QUOTIENT DX:REMAINDER.
push dx ;PRESERVE DIGIT EXTRACTED FOR LATER.
inc cx ;INCREASE COUNTER FOR EVERY DIGIT EXTRACTED.
cmp ax, 0 ;IF NUMBER IS
jne cycle1 ;NOT ZERO, LOOP.
;NOW RETRIEVE PUSHED DIGITS.
cycle2:
pop dx
add dl, 48 ;CONVERT DIGIT TO CHARACTER.
mov [ si ], dl
inc si
loop cycle2
ret
endp
;------------------------------------------
;FILLS VARIABLE WITH '$'.
;USED BEFORE CONVERT NUMBERS TO STRING, BECAUSE
;THE STRING WILL BE DISPLAYED.
;PARAMETER : SI = POINTING TO STRING TO FILL.
proc dollars
mov cx, 6
six_dollars:
mov bl, '$'
mov [ si ], bl
inc si
loop six_dollars
ret
endp
使用以前的程序,您可以显示时间,下一个示例显示如何使用它们,它也只显示秒数(我确定您将能够自己显示分钟和小时),请注意有两个重要的您必须在数据段中创建的变量:
seconds db ? ;◄■■ IMPORTANT VARIABLES IN DATA SEGMENT.
buf db 6 dup (?)
display_time:
;▼ GET SYSTEM TIME.
mov ah, 2ch
int 21h ;◄■■ SECONDS RETURN IN DH.
;▼ TIMER (1 SECOND).
cmp dh, seconds
je display_time ;◄■■ REPEAT UNTIL 1 SECOND PASSED.
mov seconds, dh
;▼ CONVERT SECONDS TO STRING.
xor ax, ax ;◄■■ NUMBER TO CONVERT TO STRING.
mov al, dh ;◄■■ SECONDS IN AX.
lea si, buf ;◄■■ VARIABLE WHERE STRING WILL BE STORED.
call number2string ;◄■■ CALL PROCEDURE THAT CONVERTS NUMBER TO STRING.
;▼ MOVE CURSOR TO 0,0.
mov dl, 0 ;◄■■ X.
mov dh, 0 ;◄■■ Y.
mov ah, 2
mov bh, 0
int 10h
;▼ DISPLAY STRING.
mov ah, 9
lea dx, buf
int 21h
jmp display_time
答案 1 :(得分:0)
可以使用以下几种方法:
使用DOS int 21h显示文本(可能是9?)。
使用BIOS int 10h显示字符。
或者最后直接写在B800:0000
我个人使用BIOS方法。