完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
本帖最后由 eehome 于 2013-1-5 10:00 编辑
程序如下ctrl_port EQU 0106H A_PORT EQU 0100H B_PORT EQU 0102H c_port equ 0104h count equ 0206h count0 equ 0200h count1 equ 0202h INTR EQU 0304H INTR1 EQU 0306H DCOUNT EQU 6 data segment LEDTAB DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH,77H,7CH,39H,5EH,79H,71H BUF DB 0,0,0,0,0,0 buff db 20 dup(?) DAT1 DB 0 DAT2 DB 0 DAT3 DB 1 dat4 db 0 data ends CODE SEGMENT ASSUME CS:CODE,ds:data START: CLI PUSH DS MOV SI,2*4 MOV AX,0 MOV DS,AX MOV [SI],OFFSET INTB MOV 2[SI], SEG INTB POP DS MOV AL,00010011B MOV DX,INTR OUT DX,AL MOV AL,00000010B MOV DX,INTR1 OUT DX,AL MOV AL,00000001B MOV DX,INTR1 OUT DX,AL Sti mov ax,data mov ds,ax mov al,00110111b ;8253初始化 mov dx,count out dx,al mov dx,count0 mov ax,500h out dx,al mov al,ah out dx,al mov al,01110111b mov dx,count out dx,al mov dx,count1 mov ax,50h out dx,al mov al,ah out dx,al MOV AL,10000001B ;8255初始化, MOV DX,CTRL_PORT OUT DX,AL back: MOV DX,C_PORT in al,dx test al,00000010b jz b2 ;判断是否清0 again: MOV DX,C_PORT in al,dx test al,00000001b jz b1 ;判断是暂停还是继续? mov cx,6 jia6: inc si loop jia6 MOV AL,00000000B MOV DX,C_PORT OUT DX,AL MOV AL,DAT1 ;DTA1中是秒 CMP AL,100 JZ A1 MOV BL,10 DIV BL MOV BUF,AH ;秒的个位 MOV BUF+1,AL ;秒的十位 CALL DISPLAY_DEC INC DAT1 JMP back A1: MOV DAT1,0 ;满60秒,对DAT1清0 MOV AL,0 MOV AH,0 MOV BUF,AH MOV BUF+1,AL CALL DISPLAY_DEC ;先显示00,再进位 INC DAT2 MOV AL,DAT2 ;DAT2中是分 CMP AL,60 JZ A2 MOV BL,10 DIV BL MOV BUF+2,AH ;分的个位 MOV BUF+3,AL ;分的十位 CALL DISPLAY_DEC MOV CX,60 LOOP AGAIN A2: MOV DAT2,0 ;满60分对DAT2清0 MOV AL,0 MOV AH,0 MOV BUF+2,AH MOV BUF+3,AL CALL DISPLAY_DEC ;先显示00:00再进位 MOV AL,DAT3 ;DAT3中是时 CMP AL,24 JZ A3 MOV BL,10 DIV BL MOV BUF+4,AH ;时的个位 MOV BUF+5,AL ;时的十位 CALL DISPLAY_DEC MOV CX,60 DEC CX JZ back A3: INC DAT3 JMP back b1: CALL DISPLAY_DEC mov al,01110000b ;对8253送GATE1控制信号 mov dx,c_port out dx,al call cunchu CALL DELAY jmp back b2: mov dx,c_port in al,dx test al,00000100b jnz li call xianshicj call display_dec mov cx,1 jz next2 mov si,6 dec cx next2: call delay jmp back li: mov buf,0 ;清0 mov buf+1,0 mov buf+2,0 mov buf+3,0 mov buf+4,0 mov buf+5,0 mov dat2,0 mov dat3,1 call display_dec ; mov bx,1000 ;jz back mov al,10110000b ;对8253送GATE0控制信号 mov dx,c_port out dx,al CALL DELAY ;dec bx jmp back DISPLAY_DEC PROC DA: MOV DI,2 DISPAGAIN1: MOV BL,BUF MOV BH,0 LEA SI,LEDTAB ;以十进制显示 MOV AL,[BX][SI] ;取个位段码 not al ;共阳 MOV DX,A_PORT OUT DX,AL ;用数码管显示个位 MOV AL,11100000B ;位选,1点亮 MOV AH,0 MOV DX,B_PORT OUT DX,AL CALL DELAY MOV AL,0H ;清屏 MOV DX,B_PORT OUT DX,AL CALL DELAY1 CALL DELAY1 LEA SI,LEDTAB MOV BL,BUF+1 MOV BH,0 MOV AL,[BX][SI] ;取十位段码 not al MOV DX,A_PORT OUT DX,AL ;用数码管显示十位 MOV AL,11010000B MOV DX,B_PORT OUT DX,AL CALL DELAY MOV AL,0H MOV DX,B_PORT OUT DX,AL CALL DELAY1 LEA SI,LEDTAB MOV BL,BUF+2 MOV BH,0 MOV AL,[BX][SI] ;取分个位段码 not al MOV DX,A_PORT OUT DX,AL ;用数码管显示分个位 MOV AL,11001000B MOV DX,B_PORT OUT DX,AL CALL DELAY MOV AL,0H MOV DX,B_PORT OUT DX,AL CALL DELAY1 CALL DELAY1 LEA SI,LEDTAB MOV BL,BUF+3 MOV BH,0 MOV AL,[BX][SI] ;取分十位段码 not al MOV DX,A_PORT OUT DX,AL ;用数码管显示分十位 MOV AL,11000100B MOV DX,B_PORT OUT DX,AL CALL DELAY MOV AL,0H MOV DX,B_PORT OUT DX,AL CALL DELAY1 LEA SI,LEDTAB MOV BL,BUF+4 MOV BH,0 MOV AL,[BX][SI] ;取时个位段码 not al MOV DX,A_PORT OUT DX,AL ;用数码管显示时个位 MOV AL,11000010B MOV DX,B_PORT OUT DX,AL CALL DELAY MOV AL,0H MOV DX,B_PORT OUT DX,AL CALL DELAY1 CALL DELAY1 LEA SI,LEDTAB MOV BL,BUF+5 MOV BH,0 MOV AL,[BX][SI] ;取时十位段码 not al MOV DX,A_PORT OUT DX,AL ;用数码管显示时十位 MOV AL,11000001B MOV DX,B_PORT OUT DX,AL CALL DELAY MOV AL,0H MOV DX,B_PORT OUT DX,AL CALL DELAY1 DEC DI JNZ DISPAGAIN1 RET DISPLAY_DEC ENDP DELAY PROC MOV CX,1dh LOOP $ RET DELAY ENDP DELAY1 PROC MOV CX,3h LOOP $ RET DELAY1 ENDP cunchu proc push ax push bx push cx mov al,buf mov ah,buf+1 mov bl,buf+2 mov bh,buf+3 mov cl,buf+4 mov ch,buf+5 mov buff[si],al mov buff[si+1],ah mov buff[si+2],bl mov buff[si+3],bh mov buff[si+4],cl mov buff[si+5],ch pop ax pop bx pop cx ret cunchu endp xianshicj proc push ax push bx push cx mov al,buff[si] mov ah,buff[si+1] mov bl,buff[si+2] mov bh,buff[si+3] mov cl,buff[si+4] mov ch,buff[si+5] mov buf,al mov buf+1,ah mov buf+2,bl mov buf+3,bh mov buf+4,cl mov buf+5,ch pop ax pop bx pop cx ret xianshicj endp INTB PROC FAR PUSH AX PUSH BX PUSH CX MOV SI,6 MOV AL,20H OUT 20H,AL POP CX POP BX POP AX IRET INTB ENDP CODE ENDS END START |
|
相关推荐
5个回答
|
|
越详细越好 谢谢了!!
|
|
|
|
{:11:}{:11:}
|
|
|
|
怎么人好少
|
|
|
|
人好少啊 还那么没有爱=-=
|
|
|
|
顶一下。。。。。。。。。。。。。。。
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
3483 浏览 3 评论
4778 浏览 1 评论
5055 浏览 0 评论
Protues中自己封装的芯片元件无Program File、Clock Frequency选项怎么解决,求求大神了!
6775 浏览 1 评论
基于51单片机的车辆倒车雷达报警系统,HC-SR04超声波测距,全套资料
1190 浏览 0 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-5 02:13 , Processed in 0.638601 second(s), Total 51, Slave 44 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号