Assembly Language Help (alang.hlp) (
Table of Contents;
Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
GetKeyClock
◄Map► ◄Up► ◄Contents► ◄Index► ◄Back►
────────────────────────────────────────────────────────────────────────────
;* GetKeyClock - Waits for keypress while updating time at specified location
;* on screen.
;*
;* Shows: BIOS Interrupt - 16h, Functions 0 and 10h (Read Character)
;* 16h, Functions 1 and 11h (Get Keyboard Status)
;* DOS Functions - 2Ah (Get Date)
;* 2Ch (Get Time)
;*
;* Uses: vconfig - Video configuration structure (initialized
;* by calling the GetVidConfig procedure)
;*
;* Params: Row - Screen row for clock display
;* Col - Screen column for clock display
;*
;* Return: Short integer with key scan code in high byte and ASCII
;* character code in low byte. Low byte is 0 for special
;* keys (such as the "F" keys) which don't generate characters.
.DATA
PUBLIC datestr
datestr BYTE " - - : : ", 0 ; Date/time string
.CODE
GetKeyClock PROC,
Row:WORD, Col:WORD
LOCAL service:BYTE
INVOKE GetShift ; Check for extended keyboard
mov service, 11h ; Assume Function 11h
.IF dx != 1 ; If no extended keyboard:
mov service, 1 ; Use Function 1
.ENDIF
.WHILE 1
mov ah, service
int 16h ; Get Keyboard Status
.BREAK .IF !zero? ; If no key yet, update clock
; If not monochrome, color text, or black and white, skip clock update
; and poll keyboard again
.CONTINUE .IF (vconfig.mode != 7) \
&& (vconfig.mode != 3) \
&& (vconfig.mode != 2)
; If 80-column text, get date and time from DOS before again
; polling keyboard, and display at upper right corner of screen.
mov ah, 2Ch ; Request time
int 21h ; Get Time
mov dl, dh
push dx ; Save seconds,
push cx ; minutes,
mov cl, ch ; and
push cx ; hours
mov ah, 2Ah ; Request date
int 21h ; Get Date
sub cx, 1900 ; Subtract century, CL = year
push cx ; Save year,
push dx ; day,
mov dl, dh ; and
push dx ; month
mov cx, 6
sub bx, bx
.REPEAT
pop ax ; Recover all 6 numbers in AL
aam ; Convert to unpacked BCD
xchg al, ah ; Switch bytes for word move
or ax, "00" ; Make ASCII numerals
mov WORD PTR datestr[bx], ax; Copy to string
add bx, 3 ; at every third byte
.UNTILCXZ
INVOKE StrWrite, Row, Col, ADDR datestr
.ENDW ; Loop again for keypress
mov ah, service ; 1 or 11h, depending on keybd
dec ah ; Set AH to 0 or 10h
int 16h ; Get key to remove it from
ret ; keyboard buffer
GetKeyClock ENDP
-♦-