get_row: ;calculate row number
rrc matrix ;;check each bit to get row number
snz status.0 ;;
jmp get_next ;if bingo goto get_next
clr c ;
add a,4h ;(8) ;table index +4 (4 keys a row)
jmp get_row ;continue calculating
get_next: ;
MOV tblp,a ;hold table index at register TBLP
MOV a,0efh ;
MOV mask,a ;; mask = 0111 1111
MOV a,0fh ;
orm a,temp ;; temp = XXXX 1111
get_column: ;calculate column number
MOV a,temp ;load temp
xor a,mask ;;test column number
snz z ;;
jmp index ;no. test next column
ret ;yes. return (TBLP)
index: ;next column
inc tblp ;(9) ;table index +1
set c ;
rlc mask ;shift mask left (LSB=1)
jmp get_column ;repeat get_column
key_in endp
delays proc ;delay subroutine
MOV a,0ffh ;load counter
MOV count1,a ;
d1:
sdz count1 ;count down count1
jmp d1
ret
delays endp
上一页 [1] [2] [3]
本文关键字:单片机 程序 键盘 合泰单片机,单片机-工控设备 - 合泰单片机