实验目的
熟悉星研集成开发环境,掌握微机接口程序编写调试的基本方法。
掌握矩阵式键盘工作原理及识别按键的方法。
掌握8段数码管显示数字或字符的工作原理和它的使用方法。
掌握用8255扫描键盘及用8255刷新数码管的显示方法。文章来源:https://www.toymoban.com/news/detail-587248.html
实验要求
在2*8(看着像4*4,实际上是2*8)的小键盘上按下按键,该键的值同时显示在8个数码管上。按键松开时显示上一次的按键值。文章来源地址https://www.toymoban.com/news/detail-587248.html
.Model tiny
.data
.stack 100
segtab db 0c0h,0f9h,0a4h,0b0h,99h,92h,82h,0f8h,80h,90h,88h,0h,0c6h,40h,86h,8eh
keycode dw 0fe02h,0fd02h,0fb02h,0f702h,0ef02h,0df02h,0bf02h,7f02h
dw 0fe01h,0fd01h,0fb01h,0f701h,0ef01h,0df01h,0bf01h,7f01h
.CODE
start:
mov ax,@data
mov ds,ax
mov es,ax
mov dx,273h
mov al,81h
out dx,al
wait1:
call scankey
cmp ax,-1
jz wait1
call translate
call led_disp
jmp wait1
mov ax,4c00h
int 21h
scankey proc near
push cx
push dx
mov dx,271h
mov al,0
out dx,al
mov dx,272h
in al,dx
and al,00000011B
cmp al,00000011B
jz no_key
in al,dx
and al,00000011B
cmp al,00000011B
jz no_key
mov ah,0feh
mov cx,8
next:
mov al,ah
rol ah,1
mov dx,271h
out dx,al
mov dx,272h
in al,dx
and al,03H
cmp al,03H
loopz next
jz no_key
ror ah,1
jmp exit
no_key:
mov ax,-1
exit:
pop dx
pop cx
ret
scankey endp
translate proc
push cx
mov cx,16
lea si,segtab-1
lea di,keycode-2
scantab:inc si
inc di
inc di
cmp ax,[di]
loopnz scantab
mov dl,[si]
pop cx
ret
translate endp
led_disp proc
push bx
push ax
mov bl,dl
mov al,0ffh
mov dx,271h
out dx,al
mov al,bl
mov dx,270h
out dx,al
mov al,0h
mov dx,271h
out dx,al
pop ax
pop bx
ret
led_disp endp
end start
到了这里,关于【汇编语言与微机原理】实验五:键盘按键与数码管显示的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!