合肥工业大学微机原理课程设计数字闹钟讲解

LBloop: mov al,LEDbuf[si] MOV buf[si],al inc si

cmp si,06h jnz LBloop POP AX POP SI RET

BUFtoLED: push si push ax mov si,00h

BLloop: MOV AL,BUF[si] mov LedBuf[si],AL INC SI

CMP SI,06H JNZ BLloop pop ax pop si ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOR8259:MOV AL,13H MOV DX,Port0 OUT DX,AL ;icw1 MOV AL,08H MOV DX,Port1 OUT DX,AL ;icw2 MOV AL,0BH OUT DX,AL

MOV AL,7FH ;IRQ7 OUT DX,AL RET

;;;;;;;;;;;;;;;;;;;;;;;;中断子程序;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; INT8259:cli push ax push bx push cx push si

; call judgeclock ; cmp juRing,01h ; jnz noRing1 ; call StartRing

noRing1: mov al,[LedBuf+5] ;此处往下的代码区均无问题,无需更改 mov ah,0 call judge

mov [LedBuf+5],al

mov si,4h call judge6 dec si

call judge9 dec si

call judge6 dec si

call judge24 cmp cflag,01h jnz noringgg call judgeclock noringgg:pop si pop cx pop bx pop ax CALL DIS STI IRET

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; judge: cmp al,09h jnz LL1 mov al,0 mov ah,1h jmp judge0 LL1: inc al judge0: ret

judge6: mov al,[LedBuf+si] add al,ah mov ah,0h cmp al,06h jnz LL2 mov al,0 mov ah,1h

LL2: mov [LedBuf+si],al ret

judge9: mov al,[LedBuf+si]

add al,ah mov ah,0h cmp al,0ah jnz LL3 mov al,0 mov ah,1h

LL3: mov [LedBuf+si],al ret

judge24: mov al,[LedBuf+0] cmp al,2 jz LL4 call judge9

mov al,[LedBuf+0] add al,ah mov ah,0h

mov [LedBuf+0],al jmp L24 LL4:

mov al,[LedBuf+1] add al,ah mov ah,0h cmp al,4h jnz LL5 mov al,0

mov [LedBuf+0],al mov [LedBuf+1],al JMP L24

LL5: mov [LedBuf+1],al L24: ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; GetKey: ;键扫子程序 mov al,0ffh ;关显示口 mov dx,OUTSEG out dx,al mov bl,0 mov ah,0feh mov cx,8

key1: mov al,ah mov dx,OUTBIT out dx,al shl al,1

mov ah,al nop nop nop nop nop nop

mov dx,IN_KEY in al,dx not al nop nop

and al,0fh jnz key2 inc bl loop key1

nkey: mov al,20h ret

key2: test al,1 je key3 mov al,0 jmp key6 key3: test al,2 je key4 mov al,8 jmp key6 key4: test al,4 je key5 mov al,10h jmp key6 key5: test al,8 je nkey mov al,18h key6: add al,bl cmp al,10h jnc fkey

mov bx,offset KeyTable xlat

fkey: ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DIS: push ax push cx

push si mov si,0h

MOV CL,20H ;10000b选种某一位7段二极管 MOV BX,OFFSET LEDbuf DIS1: MOV AL,[BX+si] PUSH BX

MOV BX,OFFSET LEDmap XLAT ;换码指令 POP BX

MOV DX,outseg

OUT DX,AL ;要显示的内容 MOV AL,CL MOV DX,outbit

OUT DX,AL ;显示的二极管 PUSH CX MOV CX,256 DELAY: LOOP $ POP CX CMP SI,06H JZ EXIT INC SI SHR CL,1 JMP DIS1

EXIT: MOV AL,00H MOV DX,outbit OUT DX,AL pop si pop cx pop ax RET

LedMap: ;八段管显示码

db 0c0h,0f9h,0a4h,0b0h,099h,092h,082h,0f8h

db 080h,090h,088h,083h,0c6h,0a1h,086h,08eh,0ffh ,0bfh

KeyTable: ;键码定义

db 07h,04h,08h,05h,09h,06h,0ah,0bh db 01h,00h,02h,0fh,03h,0eh,0ch,0dh

CODE ENDS END start

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4