;============================================================================== ;file :AndreDate.asm ;author :Andre Long ;due :April 5, 2006 ;description :This program will calculate the day of the week and use arrays ;============================================================================== ;Procedures To INCLUDE Pcmac.inc ;macros EXTRN NEWLINE:FAR ;display a new line EXTRN GETDEC$:FAR ;gets 16-bit decimal number EXTRN PUTDEC$:FAR ;display 16-bit decimal number EXTRN PUTSTRNG:FAR ;display a string ;============================================================================== .MODEL SMALL .586 .STACK 100h ;============================================================================== .DATA MAXBUF EQU 100 GetBuf DB MAXBUF GetCnt DB ? CharStr DB MAXBUF DUP (?) messGet DB 'Enter the date to find the day of the week of the form (mm/dd/yyyy) ', '$' days DB 'Sunday$Monday$Tuesday$Wednessday$Thursday$Friday$Saturday', '$' days2 DB 0,7,14,22,33,42,49,'$' numDays DB 0,1,2,3,4,5,6,'$' Month DB 'January$February$March$April$May$June$July$August$September$October$November$December','$' months2 DB 0,8,17,23,29,33,38,43,50,60,68,77 mmCode DB 0,3,3,6,1,4,6,2,5,0,3,5 mmCodeLeap DB 6,2,3,6,1,4,6,2,5,0,3,5 mm DB ? dday DB ? yyyy DB 5 DUP (?) year DW ? store1 DW ? store2 DW ? store3 DW ? store4 DW ? storeYr DW ? true DB 1 false DB 0 result1 DW ? result2 DW ? result3 DW ? result4 DW ? temp DW ? ;============================================================================== .CODE date proc _Begin sPutStr messGet _GetStr GetBuf ;get string from keyboard _PutCh 10 mov bl, GetCnt test bl, bl jz done sub bh, bh mov ax, 0 ;parse string and convert to number mov al, CharStr mov ah, [CharStr + 1] mov mm, al mov [mm + 1], ah mov [mm + 2], '$' mov ah, 0 mov al, 48 sub mm, al mov al, mm mov cl, 10 mul cl mov bl, [mm + 1] sub bl, 48 add al, bl call putdec$ mov mm, al call newline mov ax, 0 mov al, [CharStr + 3] mov ah, [CharStr + 4] mov dday, al mov [dday + 1], ah mov [dday + 2], '$' mov ah, 0 mov al, 48 sub dday, al mov al, dday mov cl, 10 mul cl mov bl, [dday + 1] sub bl, 48 add al, bl call putdec$ mov dday, al call newline mov ax, 0 mov al, [CharStr + 6] mov ah, [CharStr + 7] mov bl, [CharStr + 8] mov bh, [CharStr + 9] mov [yyyy + 0], al mov [yyyy + 1], ah mov [yyyy + 2], bl mov [yyyy + 3], bh mov [yyyy + 4], '$' ;Sucessfully put string into yyyy mov ah, 0 mov al, 48 mov cl, [yyyy+0] sub cl, al ;convert char to number mov al, cl mov bh, -1 call putdec$ ;1st 2 call newline mov store1, ax mov ah, [yyyy+1] mov al, 48 sub ah,al mov al,ah mov ah, 0 call putdec$ ;2nd 0 call newline mov store2, ax mov ah, [yyyy + 2] mov al, 48 sub ah, al mov al, ah mov ah, 0 call putdec$ ;3rd 0 call newline mov store3, ax mov ah, [yyyy + 3] mov al, 48 sub ah, al mov al, ah mov ah, 0 call putdec$ ;4th 6 call newline mov store4, ax mov ax, store1 mov bx, 10 mul bx add ax, store2 mul bx add ax, store3 mul bx add ax, store4 call putdec$ mov storeYr, ax call newline Calulate: mov ax, storeYr mov bx, 4 mov dx,0 div bx cmp dx, 0 je leapYr jmp noLeap noLeap: add ax, storeYr mov result1, ax mov ax, storeYr mov bx, 100 mov dx,0 div bx mov result2, ax mov ax, result1 sub ax, result2 mov result3, ax mov ax, storeYr mov bx, 400 mov dx,0 div bx mov result4, ax mov ax, result3 add ax, result4 mov bh, 0 mov bl, dday add ax, bx mov temp, ax mov bx, offset mmCode mov al, mm sub al, 1 mov ah, 0 xlat add ax, temp ;monthcode sub ax, 1 mov bx, 7 mov dx,0 div bx mov ax, dx ;remainder inside dx call putdec$ call newline mov ah, 0 mov bx, offset days2 xlat call putdec$ call newline mov dx, offset days add dx,ax mov ah, 09h int 21h leapYr: Done: _Exit date endp end date