📄 6-1'.asm
字号:
data segment
t0 equ 280h
t1 equ 281h
t2 equ 282h
ctl53 equ 283h
pa equ 288h
pb equ 289h
pc equ 28ah
ctl55 equ 28bh
in0 equ 290h
dat db ?
table db 3fh,30h,5bh,4fh,66h,6dh,7dh,07h,7fh,6fh,77h,7ch,39h,0deh,7bh,71h
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
xor ax,ax
xor bx,bx
xor cx,cx
mov dx,ctl55
mov al,10001000b
out dx,al
mov dx,ctl53
mov al,00100101b
out dx,al
mov dx,t0
mov al,10h
out dx,al
mov dx,ctl53
mov al,01100111b
out dx,al
mov dx,t1
mov al,10h
out dx,al
mov dx,ctl53
mov al,10100111b
out dx,al
mov dx,t2
mov al,50h
out dx,al
mov cx,0ah
l1: mov dx,in0
out dx,al
l2: call led
mov dx,pc
in al,dx
test al,80h
jnz l2
mov dx,in0
in al,dx
mov dat,al
mov dx,pb
out dx,al
l3: call led
mov dx,pc
in al,dx
test al,80h
jz l3
call screen
mov al,dat
mov dx,pa
out dx,al
loop l1
mov ah,4ch
int 21h
screen proc near
push cx
mov cl,4
mov al,dat
shr al,cl
and al,0fh
cmp al,0ah
jc l7
add al,07h
l7: add al,30h
mov dl,al
mov ah,02h
int 21h
mov al,dat
and al,0fh
cmp al,0ah
jc l8
add al,07h
l8: add al,30h
mov dl,al
mov ah,02h
pop cx
int 21h
ret
screen endp
led proc near
push cx
mov cl,4
mov al,dat
and al,0f0h
rol al,cl
lea bx,table
xlat
mov dx,pb
out dx,al
mov dx,pc
mov al,02h
out dx,al
mov al,0
out dx,al
mov al,0fch
out dx,al
mov al,dat
and al,0fh ;取低4位
lea bx,table
xlat ;八段显示器译码
mov dx,pb
out dx,al ;送数据至B口
mov dx,pc
mov al,01h ;送低位位码0000001
out dx,al
mov al,0 ;送间隔
out dx,al
mov al,0fch
out dx,al
pop cx
ret
led endp
code ends
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -