微机原理课程设计-电子钟标准版
微机原理课程设计-电子钟标准版|精品课程网站设计|课程设计网报告总结心得
电子钟标准版
.486p
code segment use16
assume cs:code
ORG 03000H
BEG:jmp start
tab db 0c0h,0f9h,0a4h,0b0h,099h,092h,082h,0f8h,080h,090h,088h,083h,0c6h,0a1h,086h,08eh
porta1 equ 200h
portb1 equ 204h
portc1 equ 208h
portp1 equ 20ch
porta2 equ 201h
portb2 equ 205h
portc2 equ 209h
portp2 equ 20dh
porta3 equ 202h
portb3 equ 206h
portc3 equ 20ah
portp3 equ 20eh
porta4 equ 203h
portb4 equ 207h
portc4 equ 20bh
portp4 equ 20fh
hour dw 23
min dw 59
sec dw 50
count db 0
c10 db 10
BIT EQU 10111111B
PORT2 EQU 360H
PORT1 EQU 340H
ROW DB 01H,02H,04H,08H
step db 0
time dw 0
stop dw 0ffh
start:mov ax,0
mov ds,ax
;关中断
cli
;8255初始化
mov al,80h;A口方式0,输出;B口方式0;C口输出
mov dx,20eh
out dx,al
mov dx,20dh
out dx,al
mov dx,20ch
out dx,ax
mov al,80h
mov dx,20fh
out dx,al
mov dx,portb4;203h口
mov al,0ffh
out dx,al
;8253 out0产生25ms信号
mov dx,30ch;8255CS接300h
mov al,00110100b ; 计数器0,读写低八位,方式2,2进制
out dx,al
mov al,01110110b ; 计数器1,读写低八位,方式3,2进制
out dx,al
mov ax,37500;初值
mov dx,300h;计数器0
out dx,al
mov al,ah
out dx,al
;8253 out1产生25MS方波
mov dx,30ch
mov ax,47000;
mov dx,304h;计数器1//////////////////////////////////////////////////308
out dx,al
mov al,ah
out dx,al
;中断向量设置
mov ax,offset interupt;中断程序的入口地址
mov bx,20h
mov [bx],ax
mov ax,cs
mov [bx+2],ax;/////////////////////////////////////////////////////?????????????
;8259init
mov dx,3a0h
mov al,00010011b ; ICW1
out dx,al
mov dx,3a8h
mov al,00001000b;IR0的中断类型号08H ICW2
;mov dx,3a8h
out dx,al
mov al,00000101b; ICW4//////////////////////////00000001
out dx,al
;写屏蔽字
mov al,11111110b; 只有IRQ0允许
mov dx,3a8h
out dx,al
aga: sti ; 开中断
;输入程序
WT:
MOV AL,00H
MOV DX,PORT2
OUT DX,AL ;使数码管全灭的同时,列线输出0判断是否有键按下
MOV DX,PORT2 ;360H地址
IN AL,DX ;是否有键按下
NOT AL
AND AL,0FH
JNZ LK1 ;有,转
JMP WT ;无键,继续查询等待
LK1:
CALL DELY
MOV AL,00H
MOV DX,PORT2
OUT DX,AL
;再次确认是否有键按下
MOV DX,PORT2
IN AL,DX
NOT AL
AND AL,0FH
JZ WT