home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
assemblr
/
library
/
datetime
/
cmosdate
/
time_is.asm
< prev
next >
Wrap
Assembly Source File
|
1992-12-01
|
5KB
|
103 lines
;; TIME_IS.ASM - simple CMOS time display program.
;;
;; This program can be assembled using the A86 or TASM assemblers
;;
;; Not tested with Masm, should work?
;;
;; This code is "PUBLIC DOMAIN"
;;
;; by William Cravener 11/28/92
;;
;---------------------------------------------------------
;;
code SEGMENT
ASSUME cs:code, ds:code, es:code, ss:code
ORG 100h ; COM files begin here
start:
jmp time ; go show the current system time
;;
;;==========================================================================
;;
say_time DB 0dh, 0ah, 'Time is '
table DB '00:00:00', 0dh, 0ah
;;
;;==========================================================================
;; retrieve and display time
time:
mov ah, 2 ; function 2
int 1ah ; BIO's get CMOS time
push dx ; save SECONDS
push cx ; save MINUTES
cmp ch, 12h ; past noon ?
jb meridian
sub ch, 12h ; if yes, adjust.
meridian:
cmp ch, 0 ; midnight ?
jnz notmidnight
mov ch, 12h ; if yes, adjust.
notmidnight:
mov al, ch ; CH = HOURS/unpack_bcd uses AL
call unpack_bcd ; go upack BCD value
; result returned in AL
call make_it_ascii ; make em ASCII characters
mov [table+0], al ; store upper
mov [table+1], ah ; store lower
pop cx ; retrieve MINUTES
mov al, cl ; CL = MINUTES/unpack_bcd uses AL
call unpack_bcd ; go upack BCD
; result returned in AL
call make_it_ascii ; make em ASCII characters
mov [table+3], al ; store upper
mov [table+4], ah ; store lower
pop dx ; retrieve SECONDS
mov al, dh ; DH = SECONDS/unpack_bcd uses AL
call unpack_bcd ; go upack BCD
; result returned in AL
call make_it_ascii ; make em ASCII characters
mov [table+6], al ; store upper
mov [table+7], ah ; store lower
;;
mov si, OFFSET say_time ; point to "Time is"
mov ah, 0eh ; use BIO's teletype service
mov bh, 0 ; page 0
mov cx, 10 ; 10 characters
loop1:
lodsb ; get character
int 10h ; BIO's interrupt
loop loop1 ; all 10 characters
;;
mov si, OFFSET table ; point to time table
mov ah, 0eh ; use BIO's teletype service
mov bh, 0 ; page 0
mov cx, 10 ; 10 characters
loop2:
lodsb ; get character
int 10h ; BIO's interrupt
loop loop2 ; all 10 characters
int 20h ; exit to DOS
;---------------------------------
; unpacked binary result returned in AL
unpack_bcd:
mov ch, al ; save low digit in CH
and ch, 0fh ; by clearing the high
mov cl, 4 ; shift high digit
shr al, cl ; to low bits
mov cl, 0ah ; and multiply by 10
mul cl ; multiply
add al, ch ; add the digits
ret
;---------------------------------
make_it_ascii:
; binary value in AL
xor ah, ah ; zero out AH
mov cl, 0ah ; divide
div cl ; by 10
add al, 30h ; make it a
add ah, 30h ; ASCII value
ret
;---------------------------------
code ENDS
END start