电子时钟代码
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
西安邮电大学
硬件课程设计报告
院系名称:计算机学院
学生姓名:王哲
指导老师:杨锐
班级:0901
学号:
时间:
porta equ1400h
portb equ1401h
portc equ1402h
portcontrol equ1403h
timer0equ1440h
timer1equ1441h
timer2equ1442h
timer_control equ1443h
;-------------------------------------------------------------
data segment
ledbuf db3fh,06h,5bh,4fh,66h,6dh,7dh,07h,7fh,6fh;段码
datbuf db00h,00h,00h,00h;存放要显示4位
copybuf db00h,00h,00h,00h
data ends
;--------------------------------------------------------------
code segment
assume cs:code,ds:data
;---------------------------------------
start:mov ax,data
mov ds,ax
call read_cmos
call p8254
mov dx,portcontrol;将8255设为A\B口输出,A为段码输出,B为位码输出
mov al,10000001B
out dx,al
;---------------------------------------------------------------
loop2:call disp
mov dx,1402h
in al,dx
mov bl,al
and bl,02h
test bl,02h
jnz reset
mov bh,al
and bh,04h
test bh,04h
jnz stop
out2:and al,01h
test al,1h
jnz hello
jmp loop2
;----------------------------------------------------------------
stop:
push si
push ax
mov si,0
mov al,datbuf[si]
mov copybuf[si],al
mov al,datbuf[si+1]
mov copybuf[si+1],al
mov al,datbuf[si+2]
mov copybuf[si+2],al
mov al,datbuf[si+3]
mov copybuf[si+3],al
pop ax
pop si
pause:call disp1
mov dx,1402h
in al,dx
mov ah,al
and al,01h
test al,1h
jnz plus2
out3:
and ah,04h
test ah,04h
jz out2
jmp pause
reset:
mov si,0h
mov datbuf[si],0h
mov datbuf[si+1],0h
mov datbuf[si+2],0h
mov datbuf[si+3],0h
jmp loop2
hello:
call plus
call p8254
jmp loop2
plus2:
call plus
call p8254
jmp out3
;-----------------------------------------------------------------
exit:mov dx,portb
mov al,0ffh;关掉数码管显示
out dx,al
mov ah,4ch;返回DOS
int21h
;----------------------------------------------------------------
plus proc
push ax
push bx
push dx
mov si,0
mov al,datbuf[si]
cmp al,09h
jnc al9
inc al
mov datbuf[si],al
jmp out1
al9:mov datbuf[si],00h
mov ah,datbuf[si+1]
cmp ah,05h
jnc ah5
inc ah
mov datbuf[si+1],ah
jmp out1
ah5:mov datbuf[si+1],00h
mov bl,datbuf[si+2]
cmp bl,09h
jnc bl9
inc bl
mov datbuf[si+2],bl
jmp out1
bl9:mov datbuf[si+2],00h
mov bh,datbuf[si+3]
cmp bh,05h
jnc bh5
inc bh
mov datbuf[si+3],bh
jmp out1
bh5:mov datbuf[si+3],00h
out1:pop dx
pop bx
pop ax
ret
plus endp
;----------------------------------------------------------------------disp proc
mov cx,0900h
again:mov si,offset datbuf
mov bl,0feh
dispnext:mov al,[si]
push bx
mov bx,offset ledbuf
xlat
mov dx,porta
out dx,al
pop bx
mov al,bl
mov dx,portb
out dx,al
push cx
mov cx,0E000h
delay:loop delay
pop cx;延时稳定时间