1、电子日历微机课程设计stack segment stack dw 64 dup(?)stack ends clearscreen macro ;清屏宏 push ax push bx push cx push dx mov ah,6 mov al,0 mov bh,7 ;blank line mov cx,0000h ;upper left row+upper left column (0,0) mov dx,184fh ;lower right row+lower right colum (24,79) int 10h pop dx pop cx pop bx pop ax endmshow
2、line MACRO STR,STA,LEN,POS,COL ;显示字符串宏 PUSH DX PUSH BX PUSH AX MOV BP,OFFSET STR ADD BP,STA MOV DX,POS MOV CX,LEN MOV BX,COL MOV AX,1301H INT 10H POP AX POP BX POP DXendmdata segment ;数据定义 str1 db TIME str2 db DATE string db TIME DATE time db 00:00:00 date db 0000-00-00 year dw 0 mouth db 0 day db 0
3、 hour db 0 minute db 0 second db 0 sbuf db 00 sbufy db 0000 flg1 db 0 flg2 db 0 flg3 db 0 dp db yeardata endscode segment assume cs:code, ds:datastart:;main proc far ;主函数 mov ax, data mov ds, ax MOV es, ax mov ah,01h mov cx,2000h int 10h call gettime ;调用系统时间 call getdate ;调用系统日期function1: ;功能一 mov f
4、lg1,0 clearscreen showline string,0,9,0a20h,0001h ;功能一初始化显示 showline str1,0,4,0a20h,0029h showline time,0,8,0b20h,0004h call showtimeall N11: call showtime call getchar cmp al, a jne M11 call settimeM11: cmp al, m jne M12 jmp function2M12: cmp al, q je goesc jmp N11 function2: ;功能二 mov flg1,3 clears
5、creen showline string,0,9,0a20h,0001h ;功能二初始化显示 showline str2,0,4,0a25h,0029h showline date,0,10,0b20h,0004h call showdateall N22: call getchar cmp al, a jne N2 call setdateN2: cmp al, q je goesc cmp al, m jne N22 cmp al,m je function1 goesc: mov ah, 4ch ;退出 int 21h getchar proc near ;得到字符 mov ah,07
6、h int 21h retgetchar endpgettime proc near ;得系统时间 mov ah,2ch int 21h mov hour,ch mov minute,cl mov second,dh retgettime endpgetdate proc near ;得系统日期 mov ah,2ah int 21h mov year,cx mov mouth,dh mov day,dl retgetdate endp bcdch proc near ;db=00未储存 mov bl,0ah mov ah,00h div bl add al,30h add ah,30h ret
7、bcdch endp seconddelay proc near ;延时一秒 push ax push bx push dx mov ah,00H int 1aH add dl,17 mov bl,dllop1: mov ah, 00H int 1ah cmp dl,bl jnz lop1 pop dx pop bx pop ax retseconddelay endp waitf proc near ;61h 端口的延时子程序10ms push ax mov cx,6630waitf1: in al,61h and al,10h cmp al,ah je waitf1 mov ah,al l
8、oop waitf1 pop ax retwaitf endpshowtime proc ;时钟程序loop1: mov ah,01h int 16h jnz loop2 ti1: call seconddelay ;延时一秒 inc second mov al,second call showbuf showline sbuf,0,2,0b26H,0004H ;秒加 cmp second,58 jna loop1 mov second,-1 inc minute mov al,minute call showbuf showline sbuf,0,2,0b23H,0004H ;分加 cmp
9、minute,58 jna loop1 mov minute,-1 inc hour mov al,hour call showbuf showline sbuf,0,2,0b20H,0004H ;小时加 cmp hour,23 jna loop1 mov hour,0 inc day ;日加 cmp day,30 jna loop1 mov day,1 inc mouth ;月加 cmp mouth,11 jna loop1 mov mouth,1 inc year ;年加 jmp loop1 loop2: retshowtime endp settime proc near ;设置时间 f
10、lg1=0,1,2 分别代表调整时分秒 call movshuR1: call getchar cmp al,i jne K11 call addshu call showtimeall call movshu jmp R1 K11: cmp al,a jne k12 inc flg1 cmp flg1,3 jne p1 mov flg1,0 p1: call showtimeall call movshu jmp R1k12: cmp al,q jne k13 jmp goesc k13: cmp al,m je function1 jmp R1 ret settime endp setda
11、te proc near ;设置日期 flg1=3,4,5 分别代表调整年月日 call movshuR2: call getchar cmp al,i jne K21 call addshu call showdateall call movshu jmp R2 K21: cmp al,a jne k22 inc flg1 cmp flg1,6 jne p2 mov flg1,3 p2: call showdateall call movshu jmp R2k22: cmp al,q jne k23 jmp goesc k23: cmp al,m je function2 jmp R2 re
12、t setdate endp addshu proc ;根据flg1调整时间日期 cmp flg1,0 jne t1 inc hour cmp hour,24 jne t6 mov hour,0t1: cmp flg1,1 jne t2 inc minute cmp minute,60 jne t6 mov minute,0t2: cmp flg1,2 jne t3 inc second cmp second,60 jne t6 mov second,0t3: cmp flg1,3 jne t4 inc year cmp year,10000 jne t6 mov year,1t4: cmp
13、flg1,4 jne t5 inc mouth cmp mouth,13 jne t6 mov mouth,1t5: cmp flg1,5 jne t6 inc day cmp day,32 jne t6 mov day,1t6: ret addshu endp movshu proc cmp flg1,0 ;根据flg1显示时间日期调整对象 jne tt1 mov al,hour call showbuf showline sbuf,0,2,0b20H,000eHtt1: cmp flg1,1 jne tt2 mov al,minute call showbuf showline sbuf,0,2,0b23H,000eHtt2: cmp flg1,2 jne tt3 mov al,second call showbuf showline sbuf,0,2,0b26H,000eH tt3: cmp flg1,3 jne tt4 call yearbcd showline sbufy,0,4,0b20H,000eHtt4: cmp flg1,4 jne tt5 mov al,mouth call showbuf showline sbuf,0,2,0b25H,000eH tt5: cmp flg1,5 jne tt6 mov al,day call showbuf
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1