微机原理-虚拟仿真实验-小键盘输入电路汇编代码

微机原理-虚拟仿真实验-小键盘输入电路汇编代码

Data  segment
PortA equ 408H ; 8255的PA口地址
table db 30h,31h,32h,33h,34h,35h,36h,37h,38h,39h,41h,42h,43h,44h,45h,46h
s     db "Watch and test the keyboard on experiment platform. Press any key to end...",0dh,0ah,"$"    ;程序功能提示
Data  ends
Code  segment
      assume cs:code,ds:data
Start:mov ax,data 
      mov ds,ax
      mov dx,offset s    ;显示提示
      mov ah,9 
      int 21h
      mov dx, PortA+3
      mov al,82H    ;  PA输出 PB输入
      out dx,al         ;
   l0:mov si,0
      mov al,0feh       ;
      mov bx,04h
   l1:mov dx,PortA
      out dx,al
      push ax
      mov dx,portA+1
      in al,dx
      mov cx,04h
      mov di,0     
   l2:shr al,1
      jc l3
      call disp
   l3:inc di
      loop l2
      pop ax
      rol al,1
      inc si
      dec bx
      jnz l1
      mov ah,0bh
      int 21h    ; 检测有无按键,返回AL=0FFh(有按键)或0(无按键)
      cmp al,0FFh
      jnz l0
      mov ah,4ch
      int 21h
disp proc near
     push bx
     push si
     push di
     push ax
     push dx
     lea bx,table
     add si,si
     add si,si
     add di,si
     mov ax,di
     xlat  
     mov dl,al
     mov ah,02h
     int 21h
     pop dx
     pop ax
     pop di
     pop si
     pop bx
     ret
disp endp
Code ends
     end Start

猜你喜欢

转载自blog.csdn.net/qq_43422111/article/details/106663518