.model small .486 .data ; ----- ; Constants CR equ 13 LF equ 10 NULL equ 0 TRUE equ 1 FALSE equ 0 ; ----- ; Variables for main. month dw ? date dw ? year dw ? day dw ? hdr db CR, LF, "CSC218 - Date Formatter" db CR, LF, NULL ; ----- ; Variables for get_date procedure. pmt_month db CR, LF, "Enter Month (1-12): ", NULL pmt_date db CR, LF, "Enter Date (1-31): ", NULL pmt_year db CR, LF, "Enter Year (yyyy): ", NULL inbuff db 5 rd db ? chrs db 5 dup (0) bad_month db "Invalid Month, Please Re-Enter" db CR, LF, NULL bad_date db "Invalid Date, Please Re-Enter" db CR, LF, NULL bad_year db "Invalid Year, Please Re-Enter" db CR, LF, NULL mn_num dw ? dt_num dw ? yr_num dw ? ok_flag db ? chk_date db 0 ; n/a db 31 ; january db 29 ; february db 31 ; march db 30 ; april db 31 ; may db 30 ; june db 31 ; july db 31 ; august db 30 ; september db 31 ; october db 30 ; november db 31 ; december ; ----- ; Variables for find_day procedure. a dw ? m dw ? y dw ? ; ----- ; Variables for wrt_date procedure. dat_str db CR, LF, CR, LF, "Date: ", NULL days db "Sunday, ", NULL, " " db "Monday, ", NULL, " " db "Tuesday, ", NULL, " " db "Wednesday, ", NULL db "Thursday, ", NULL, " " db "Friday, ", NULL, " " db "Saturday, ", NULL, " " days_size dw 12 months db "January ", NULL, " " db "February ", NULL, " " db "March ", NULL, " " db "April ", NULL, " " db "May ", NULL, " " db "June ", NULL, " " db "July ", NULL, " " db "August ", NULL, " " db "September ", NULL db "October ", NULL, " " db "November ", NULL, " " db "December ", NULL, " " months_size dw 11 tmp_str db 10 dup (?) n_line db CR, LF, NULL ; ----- ; Variables for a_to_i and i_to_a procedure. ten dw 10 ; ------------------------------------------------ .stack .code extrn get_date:near extrn find_day:near extrn wrt_date:near ; ------------------------------------------------ ; General process: ; * Prompt user for month, date, and year. ; includes performing basic error checking. ; * Determine the day of week using month/date/year. ; * Display the day of week, month date, and year ; in the required format. main proc far mov ax, @data mov ds, ax lea dx, hdr ; display simple header push dx call prt_string push month push date push year call get_date push month ; calculate day of week push date push year push day call find_day push month ; display formatting date push date push year push day call wrt_date mov ah, 4ch int 21h main endp prt_string proc near push bp mov bp, sp push ax push bx push dx mov bx, word ptr 4[bp] prt_chr_lp: mov dl, byte ptr [bx] cmp dl, NULL je prt_done mov ah, 02h int 21h inc bx jmp prt_chr_lp prt_done: pop dx pop bx pop ax leave ret prt_string endp end main get_date proc near push bp mov bp, sp push ax push dx lea ax push ax call prt_string mov ah, 0ah lea dx, ybuff int 21h cmp yrd, 4 pop dx pop ax leave ret get_date endp find_day proc near push bp mov bp, sp leave ret find_day endp wrt_date proc near push bp mov bp, sp leave ret wrt_date endp