In: Computer Science
Write an assembly program that displays the following two options: 1. Display the current date. 2. Enter a date for a meeting and display remaining days. If the user selects the first option, the program should display the current date in dd/mm/yyyy format. If the user selects the second option, the program asks the user to enter a date for a meeting within year 2020 (in decimal) in dd/mm format. The program then calculates and displays the number of days remaining for the meeting (in decimal).
Program for the given question:
.MODEL SMALL
.STACK 100H
.DATA
PROMPT DB 'Current System Time is : $'
TIME DB '00:00:00$' ; time format hr:min:sec
.CODE
MAIN PROC
MOV AX, @DATA ; initialize DS
MOV DS, AX
LEA BX, TIME ; BX=offset address of string TIME
CALL GET_TIME ; call the procedure GET_TIME
LEA DX, PROMPT ; DX=offset address of string PROMPT
MOV AH, 09H ; print the string PROMPT
INT 21H
LEA DX, TIME ; DX=offset address of string TIME
MOV AH, 09H ; print the string TIME
INT 21H
MOV AH, 4CH ; return control to DOS
INT 21H
MAIN ENDP
;----------- Definitions of procedure -----------;
;----------------- GET_TIME ----------------;
GET_TIME PROC
; this procedure will get the current system time
; input : BX=offset address of the string TIME
; output : BX=current time
PUSH AX ; PUSH AX onto the STACK
PUSH CX ; PUSH CX onto the STACK
MOV AH, 2CH ; get the current system time
INT 21H
MOV AL, CH ; set AL=CH , CH=hours
CALL CONVERT ; call the procedure CONVERT
MOV [BX], AX ; set [BX]=hr , [BX] is pointing to hr
; in the string TIME
MOV AL, CL ; set AL=CL , CL=minutes
CALL CONVERT ; call the procedure CONVERT
MOV [BX+3], AX ; set [BX+3]=min , [BX] is pointing to min
; in the string TIME
MOV AL, DH ; set AL=DH , DH=seconds
CALL CONVERT ; call the procedure CONVERT
MOV [BX+6], AX ; set [BX+6]=min , [BX] is pointing to sec
; in the string TIME
POP CX ; POP a value from STACK into CX
POP AX ; POP a value from STACK into AX
RET ; return control to the calling procedure
GET_TIME ENDP
; end of procedure GET_TIME
;******Program to select another date from calender******;
.model tiny
.data
Apr db " April 2017 ",13,10
db "Sun Mon Tue Wed Thu Fri Sat",13,10
db " 1 ",13,10
db " 2 3 4 5 6 7 8 ",13,10
db " 9 10 11 12 13 14 15 ",13,10
db "16 17 18 19 20 21 22 ",13,10
db "23 24 25 26 27 28 29 ",13,10
db "30 ",13,10,0
May db " May 2017 ",13,10
db "Sun Mon Tue Wed Thu Fri Sat ",13,10
db " 1 2 3 4 5 6 ",13,10
db " 7 8 9 10 11 12 13 ",13,10
db " 14 15 16 17 18 19 20 ",13,10
db " 21 22 23 24 25 26 27 ",13,10
db " 28 29 30 31 "
.code
org 100h
print :
mov ah,9
int 21h
ret
end print
start:
lea dx,Apr
call print
lea dx,May
call print
mov ah, 4ch
int 21h
end start
Output of the above program:
Apr 17 '17 at 23:01