📄 电梯3b.txt
字号:
call delay
push dx
vd: mov ah,1
int 16h
jne vipgetch
mov dx,io8255c
in al,dx
and al,01
jz vd
pop dx
ret
vipdelay endp
stop proc near;暂停子程序,实现按回车继续和判断是否为直达键
gostop: mov al,0
mov ah,1
int 21h
cmp al,76h;是否为直达键
je vip
cmp al,13;是否为运行键
jne gostop
mov al,0
ret
stop endp
upbl proc near;上行到bl的子程序
upbl1: add cl,1
call dirdelay
call disp
cmp cl,bl
jl upbl1
ret
upbl endp
upch proc near;上行到ch的子程序
upch1: add cl,1
call dirdelay
call disp
cmp cl,ch
jl upch1
ret
upch endp
downbl proc near;下行到bl的子程序
downbl1:sub cl,1
call dirdelay
call disp
cmp cl,bl
jg downbl1
ret
downbl endp
downch proc near;下行到ch的子程序
downch1:sub cl,1
call dirdelay
call disp
cmp cl,ch
jg downch1
ret
downch endp
delay proc near;初始化8253的子程序,两计数器连级
push dx
mov dx,io8253c;8253的计数器0置方式3
mov al,36h
out dx,al
mov dx,io8253a;计数器0初始值为10000
mov ax,10000
out dx,al
mov al,ah
out dx,al
mov dx,io8253c;8253的计数器1置方式0
mov al,70h
out dx,al
mov dx,io8253b;计数器1初始值为200
mov ax,200
out dx,al
mov al,ah
out dx,al
pop dx
ret
delay endp
urgent3:call delay2
call disp
jmp main
blequcl proc near
cmp bl,cl
jne back
cmp bl,ch
je blequch
mov bl,0
call disp
call disp8led
call stop2
cmp ch,cl
jg upchhere
jl downchhere
upchhere:call upch
jmp main
downchhere:call downch
jmp main
blequch:mov ch,0
call disp8led
call delay2
jmp main
back: ret
blequcl endp
dirdelay proc near;直接上下行的延时子程序
call delay
push dx
dirback:mov ah,1
int 16h
jne dirgetch
mov dx,io8255c
in al,dx
and al,01
jz dirback
pop dx
ret
dirdelay endp
dirgetch:mov ah,1;直接上下行对按键的处理
int 21h
cmp al,73h
je dirrepair
cmp al,70h
je urgent3
jmp dirback
dirrepair:mov al,0
mov ah,1
int 21h
cmp al,73h
jne dirrepair
call delay2
call disp
jmp dirback
stop2 proc near;没有直达键的暂停子程序
gostop2:mov al,0
mov ah,1
int 21h
cmp al,13
jne gostop2
mov al,0
ret
stop2 endp
delay2 proc near;判断延市时是否结束的子程序
push dx
delay3: mov dx,io8255c
in al,dx ;查询8255的Pc0是否为高电平
and al,01
jz delay3
pop dx
ret
delay2 endp
disp proc near;显示当前楼层的子程序
mov dl,cl
mov ah,2
int 21h;用于在屏幕上显示
mov dl,0dh
mov ah,2 ;回车符
int 21h
mov dl,0ah
mov ah,2 ;换行符
int 21h
sub cl,30h;七段码显示
mov al,cl
push bx
push dx
mov bx,offset led
xlat
mov dx,io8255a
out dx,al
pop dx
pop bx
add cl,30h
mov al,0
ret
disp endp
disp8led proc near;8led显示,显示bl与cl对应的楼层
push ax
cmp bl,0h
je n0
cmp bl,31h
je n1
cmp bl,32h
je n2
cmp bl,33h
je n3
cmp bl,34h
je n4
cmp bl,35h
je n5
cmp bl,36h
je n6
cmp bl,37h
je n7
cmp bl,38h
je n8
n0: mov al,0b
jmp chled
n1: mov al,1b
jmp chled
n2: mov al,10b
jmp chled
n3: mov al,100b
jmp chled
n4: mov al,1000b
jmp chled
n5: mov al,10000b
jmp chled
n6: mov al,100000b
jmp chled
n7: mov al,1000000b
jmp chled
n8: mov al,10000000b
jmp chled
chled: cmp ch,0
je m0
cmp ch,31h
je m1
cmp ch,32h
je m2
cmp ch,33h
je m3
cmp ch,34h
je m4
cmp ch,35h
je m5
cmp ch,36h
je m6
cmp ch,37h
je m7
cmp ch,38h
je m8
m0: add al,0b
jmp displed
m1: add al,1b
jmp displed
m2: add al,10b
jmp displed
m3: add al,100b
jmp displed
m4: add al,1000b
jmp displed
m5: add al,10000b
jmp displed
m6: add al,100000b
jmp displed
m7: add al,1000000b
jmp displed
m8: add al,10000000b
jmp displed
displed:push dx
mov dx,ls273
out dx,al
pop dx
pop ax
mov al,0
ret
disp8led endp
exit: mov ah,4ch
int 21h
code ends
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -