

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Lab; Professor: Johnson; Subject: Electrical and Computer Engineering ; University: Oklahoma State University - Stillwater; Term: Spring 2005;
Typology: Lab Reports
1 / 3
This page cannot be seen from the preview
Don't miss anything!


;Table for scanning 4 x 4 keyboard ;keys should be labeled as ; 1 2 3 4 ; 5 6 7 8 ; 9 A B C ; D E F 0 scantab: ;most significant nibble has hex digit db %01110000 PORTC for PC7 row db %10000000 DDRC for PC7 row db $10,$20,$30,$ db %10110000 PORTC for PC6 row db %01000000 DDRC for PC6 row db $50,$60,$70,$ db %11010000 PORTC for PC5 row db %00100000 DDRC for PC5 row db $90,$A0,$B0,$C db %11100000 PC4 row db %00010000 DDRC for PC4 row db $D0,$E0,$F0,$ db $00 end of table marker
;scan keyboard, no registers preserved ;hex digit returned in high nibble of A-reg ;number of keys pressed returned in Y-reg scan ldy #0 initial number pressed ldx #scantab sloop ldb 0,x beq sdone check for end of table stb PORTC select row ldb 1,x stb DDRC ldb PORTC read column lsrb PC0 into carry bcs not lda 5,x load key value into a iny inc y for a key detected not0 lsrb PC1 into carry bcs not lda 4,x load key value into a iny inc y for a key detected not1 lsrb PC2 into carry bcs not lda 3,x load key value into a iny inc y for a key detectedsdonerts not2 lsrb PC1 into carry bcs not lda 2,x load key value into a iny inc y for a key detected not3 ldb #6 scantab entry size abx inc x to next row bra sloop sdone rts