一个定时器,用的1CH,如何实现——若键入a,则保留旧时间,重新另起一行开始计时
以下(8086汇编)代码实现了从0到59的计时并显示INTNO EQU 1CH
USEINT = 1
DATA SEGMENT
OLDISR DW ?,?
TIMER DB 100
COUNTER DW 0
ISDONE DB 0
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
MOV AX,0
MOV ES,AX
;PROTECT
IF USEINT
MOV AL, INTNO
MOV AH,35H
INT 21H
;ES:BX
MOV OLDISR[0], BX
MOV AX,ES
MOV OLDISR[2], AX
ELSE
CLI
MOV AX, ES:[INTNO*4]
MOV OLDISR[0],AX
MOV AX,ES:[INTNO*4+2]
MOV OLDISR[2], AX
STI
ENDIF
;SET NEW ISR
IF USEINT
PUSH DS
MOV AX, SEG ISR
MOV DS,AX
MOV DX, OFFSET ISR
MOV AL, INTNO
MOV AH, 25H
INT 21H
POP DS
ELSE
CLI
MOV WORD PTR ES:[INTNO*4], OFFSET ISR
MOV WORD PTR ES:[INTNO*4+2],SEG ISR
STI
ENDIF
;WAIT HERE
WAITHERE:
CMP ISDONE,1
JNZ WAITHERE
EXIT:
;RESTORE
IF USEINT
PUSH DS
MOV DX,OLDISR[0]
MOV AX,OLDISR[2]
MOV DS,AX
MOV AL, INTNO
MOV AH, 25H
INT 21H
POP DS
ELSE
CLI
MOV AX,OLDISR[0]
MOV ES:[INTNO*4],AX
MOV AX,OLDISR[2]
MOV ES:[INTNO*4+2],AX
STI
ENDIF
MOV AX,4C00H
INT 21H
ISR PROC FAR
PUSH DX
PUSH AX
MOV AX,DATA
MOV DS,AX
STI ;便于中断嵌套
;COUNT HERE
INC TIMER
AGAIN:
CMP TIMER, 1000/55 ;18
JB DONE
MOV TIMER,0
;carriage
MOV AH,2
MOV DL,13
INT 21H
;print time
MOV AX,COUNTER
MOV DL,10
DIV DL
MOV DH,AH
MOV DL,AL
MOV AH,2
ADD DL,30H
INT 21H
MOV DL,DH
ADD DL,30H
INT 21H
inc COUNTER
cmp COUNTER,59
jbe DONE
MOV ISDONE,1
jmp DONE
DONE:
PUSHF
CALL DWORD PTR OLDISR
CLI
POP AX
POP DX
IRET ;中断返回
ISR ENDP
CODE ENDS
END START
如何修改,使得——若键入a,则保留旧时间,重新另起一行开始计时
用21h的0B功能