No title

An Assembly language program to read the current date and time 


An Assembly Language program to read the current time and date from the system and display it on the output screen.


;*******************************************************

.MODEL SMALL

.DATA

msg db "The Time is: "

hrs db ?,?,' : '

mins db ?,?,' (hh:mm) ',10,13

db "The Date is: "

da db ?,?, '/'

mon db ?,?, '/'

yea db ?,?, '(dd/mm/yy)', 10,13,'$'

.CODE

MOV AX,@DATA

MOV DS, AX

; Time Part

mov ah,2ch                   ; DOS function to read system time

int 21h

mov al,ch                      ; load the hours to 'al'

aam                                ; ASCII adjust after multiplication

add ax, 3030h

mov hrs, ah

mov hrs+1, al

mov al,cl                        ; load the seconds to 'al'

aam

add ax, 3030h

mov mins, ah

mov mins+1,al

; Day Part

MOV AH, 2AH          ; To get System Date

INT 21H

MOV AL, DL              ; Day is in DL

AAM

Add ax,3030h

mov da,Ah

mov da +1, al

MOV AL, DH           ; Month is in DH

AAM

Add ax, 3030h

MOV mon,AH

mov mon+1,al

; YEAR

ADD CX, 0F830H         ; To negate the effects of 16bit value,

MOV Al, cl                      ; since AAM is applicable only for AL (YYYY -> YY)

aam

Add ax, 3030h

mov yea,ah

mov yea+1,al

lea dx,msg                ; Display the time

mov ah,09h

int 21h

;int 3

end               

;*******************************************************


Previous Post Next Post

Cybersecurity - How to stay safe in digital world

Contact Form