; *****************************************************************************
;
; DATETIME.ASM    (Developed for TR-DOS Presentator's save/mkdir commands.)
;
; Copyright (C) 2000  Erdogan TAN  [ 30/04/2000 ]  (1)
;
; INT 1Ah - Date and Time Outputs
;
; INT 1Ah Function 04h = Return Current Date  (ROM-BIOS Interrupt/Function)
;
; Input:  AH = 04h
; Output: CF = 0 Succesfull
;            = 1 Clock has stopped running
;         CH = Century (in BCD)
;         CL = Year (in BCD)
;         DH = Month (in BCD)
;         DL = Day (in BCD)
;
; Description:
;
; Function 04h reads the current date from Real Time Clock CMOS RAM.
;
; INT 1Ah Function 02h = Return Current Time  (ROM-BIOS Interrupt/Function)
;
; Input:  AH = 02h
; Output: CF = 0 Succesfull
;            = 1 Clock has stopped running
;         CH = Number of Hours in binary coded decimal (BCD)
;         CL = Number of Minutes (in BCD)
;         DH = Number of Seconds (in BCD)
;         DL = 00h Standard time
;            = 01h Daylight savings time
;
; Description:
;
; Function 02h reads the current time from Real Time Clock CMOS RAM.
; [ Above information derived from American Megatrends Inc.'s Official
; AMIBIOS Programming Guide (1993). ]
;
; *****************************************************************************
Present segment Para 'code'
		assume CS:Present, DS:Present, ES:Present, SS:Present
                org 100h
;北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北
;
;              PROCEDURE proc_start
;
;北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北
proc_start      proc    near
start:                                         
                mov ah, 04h
                int 1Ah
                mov al, ch
                call proc_hex
                mov word ptr [Century], ax
                mov al, cl
                call proc_hex
                mov word ptr [Year], ax
                mov al, dh
                call proc_hex
                mov word ptr [Month], ax
                mov al, dl
                call proc_hex
                mov word ptr [Day], ax
                mov ah, 02h
                int 1Ah
                mov al, ch
                call proc_hex
                mov word ptr [Hour], ax
                mov al, cl
                call proc_hex
                mov word ptr [Minute], ax
                mov al, dh
                call proc_hex
                mov word ptr [Second], ax
                mov si, offset Msg_Date
loc_print:
		lodsb                           ; Load byte at DS:SI to AL
		and     AL,AL            
		je      short loc_return        ; If AL = 00h then return
		mov     AH,0Eh                  
		mov     BX,07h             
		int     10h                     ; BIOS Service func ( ah ) = 0Eh
						; Write char as TTY
						;AL-char BH-page BL-color
		jmp     short loc_print           
loc_return:
                int 20h
proc_start      endp
;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; From binary (byte) to hexadecimal (character) converter    ;
;                                                            ;
; input -> AL = byte (binary number) to be converted         ;
; output -> AH = First character of hexadecimal number       ;
; output -> AL = Second character of hexadecimal number      ;
;                                                            ;
; (c) Erdogan TAN  1998 - 1999                               ;
;............................................................;
; 1998
proc_hex        proc    near
		db 0D4h,10h                     ; Undocumented inst. AAM
						; AH = AL / 10h
						; AL = AL MOD 10h
		or AX,'00'                      ; Make it ZERO (ASCII) based
		xchg AH,AL
; 1999
		cmp AL,'9'
		jna pass_cc_al
		add AL,7
pass_cc_al:
		cmp AH,'9'
		jna pass_cc_ah
		add AH,7
pass_cc_ah:
; 1998
		retn
proc_hex        endp
Msg_Date:
                db   0Dh, 0Ah
                db   "INT 1Ah FUNCTION 04h DATE AND 02h TIME OUTPUTS"
                db   0Dh, 0Ah
                db   "(c) Erdogan Tan  [ 2000 ]"
                db   0Dh, 0Ah
		db   0Dh, 0Ah
                db   'Century : '
Century:        db   '0'
		db   '0'
                db   'h'
                db   0Dh, 0Ah
                db   'Year    : '
                db   '/'
Century:        db   '0'
                db   '0'
Year:           db   '0'
		db   '0'
                db   'h'
                db   0Dh, 0Ah
                db   'Month   : '
Month:          db   '0'
		db   '0'
                db   'h'
                db   0Dh, 0Ah
                db   'Day     : '
Day:            db   '0'
		db   '0'
                db   'h'
                db   0Dh, 0Ah
                db   0Dh, 0Ah
                db   'Hour    : '
Hour:           db   '0'
		db   '0'
                db   'h'
                db   0Dh, 0Ah
                db   'Minute  : '
Minute:         db   '0'
		db   '0'
                db   'h'
                db   0Dh, 0Ah
                db   'Second  : '
Second:         db   '0'
		db   '0'
                db   'h'
                db   0Dh, 0Ah
                db   0
Present         ends
                end  start