yyyymmdd date/time generator

From: Andrew Kennedy (andrewkennedy2_at_LOGev1.net)
Date: 02/09/04


Date: Mon, 9 Feb 2004 22:09:49 +0000 (UTC)


; yyyymmdd.asm Andrew Kennedy 2/2004 Known to work on Win 98
; Com file Display date and time Format: YYYYMMDD hhmmss
; Redirectable to a file or printer. 2/9/04
; No external programs needed !!

.model tiny
.code
.386

ORG 100h

start:

date:
       MOV AH,2Ah
       INT 21h ; Get Date
       mov ax,cx
       push dx
           
       call year

       pop dx
       MOV AL,DH ; DH contains month
       CALL SHOWIT ; call month

       MOV AL,DL ; DL has day
       CALL SHOWIT
       jmp short space

year: ; print the year in full 4 digit format

             mov cx,0ffffh
             push cx
             mov cx,10
pd1:
             mov dx,0
             div cx
             add dl,30h
             push dx
             cmp ax,0
             jne pd1
pd2:
             pop dx
             cmp dx,0ffffh
             je short pd3
             mov ah,2
             int 21h
             jmp pd2
pd3:
             ret

space:

       MOV DL,' ' ; 0D = CR
       INT 21h ; display space

       MOV AH,2Ch
       INT 21h ; Get Time
       MOV BL,3Ah ; 3Ah = ':'
       MOV AL,CH ; CH contains hour

       CALL SHOWIT
       MOV AL,CL ; CL contains minutes
       CALL SHOWIT
       MOV BL,20h
       MOV AL,DH ; DH contains seconds
       CALL SHOWIT
       MOV DL,' '
       INT 21h
       MOV AX,4C00h
       INT 21h
SHOWIT:
       PUSH DX ; Save DX, holds date or time
       MOV DL,0Ah ; move 10 into DL
       XOR AH,AH ; Zero AH
       DIV DL ; Div by 10
       OR AX,3030h ; Convert to ASCII
       MOV DX,AX
       MOV AH,02h
       INT 21h ; Display_character from DL, First charter
       MOV DL,DH
       INT 21h ; Display_character from DL, Second charter
       cmp bl, 21h ; Is it '/','-',or':'?
       JL LAST_D ; If not, quit
       MOV DL,BL
       INT 21h ; Display_character from DL, '/' or ':'
LAST_D:
       POP DX ; Restore DX
       RET ; End branch

END START