home *** CD-ROM | disk | FTP | other *** search
- ;; DATE_IS.ASM - simple CMOS date 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 date ; go show the current system date
- ;;
- ;;==========================================================================
- ;;
- say_date DB 0dh, 0ah, 'Date is '
- table DB '00-00-0000', 0dh, 0ah
- ;;
- ;;==========================================================================
- ;; retrieve and display date
- date:
- mov ah, 4 ; function 4
- int 1ah ; BIO's get CMOS date
- push dx ; save MONTH and DAY
- push cx ; save CENTURY
- mov al, cl ; CL = YEAR/unpack_bcd uses AL
- call unpack_bcd ; go upack BCD
- ; result returned in AL
- call make_it_ascii ; make em ASCII characters
- mov [table+8], al ; store upper
- mov [table+9], ah ; store lower
- pop cx ; retrieve CENTURY
- mov al, ch ; CH = CENTURY/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
- pop dx ; retrieve DAY
- push dx ; save MONTH
- mov al, dl ; DL = DAY/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 MONTH
- mov al, dh ; DH = MONTH/unpack_bcd uses AL
- call unpack_bcd ; go upack BCD
- ; result returned in AL
- call make_it_ascii ; make em ASCII characters
- mov [table+0], al ; store upper
- mov [table+1], ah ; store lower
- ;;
- mov si, OFFSET say_date ; point to "Date 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 date table
- mov ah, 0eh ; use BIO's teletype service
- mov bh, 0 ; page 0
- mov cx, 12 ; 12 characters
- loop2:
- lodsb ; get character
- int 10h ; BIO's interrupt
- loop loop2 ; all 12 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
-