0% found this document useful (0 votes)
4 views2 pages

PR4

The document contains assembly code for a microcontroller that handles input from a keypad. It defines several registers and implements a routine to detect key presses, storing the results in specific registers. The program continuously checks for key presses and updates the output accordingly.

Uploaded by

Ameer Abuamar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

PR4

The document contains assembly code for a microcontroller that handles input from a keypad. It defines several registers and implements a routine to detect key presses, storing the results in specific registers. The program continuously checks for key presses and updates the output accordingly.

Uploaded by

Ameer Abuamar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

.

DEF A=R16
.DEF B=R17
.DEF V=R18
.DEF RW=R19
.DEF CL=R20
LL:
LDI A,0
LDI B,64
MOV ZH,A
MOV ZL,B
STORE:
ST Z+,A
RET
START:
LDI A,0B11111111
OUT DDRA,A
LDI A,0B00000000
OUT DDRB,A
LDI V,0
CALL FINDR
MAIN:
;(RW-1)*4+CL
MOV A,RW
SUBI A,1
LDI B,4
MUL A,B
MOV A,R0
ADD A,CL
CPI CL,0
BREQ NOT_PRESSED
CPI V,1
BREQ START
LDI V,1
CALL STORE
RJMP START
NOT_PRESSED:
LDI V,0
RJMP START

FINDR:
LDI RW,0
LDI A,0B00001110
OUT PORTA,A
CALL FINDC
CPI CL,0
BREQ SET_ROW1
LDI RW,1
RJMP MAIN
SET_ROW1:
LDI A,0B00001101
OUT PORTA,A
CALL FINDC
CPI CL,0
BREQ SET_ROW2
LDI RW,2
RJMP MAIN
SET_ROW2:
LDI A,0B00001011
OUT PORTA,A
CALL FINDC
CPI CL,0
BREQ SET_ROW3
LDI RW,3
RJMP MAIN
SET_ROW3:
LDI A,0B00000111
OUT PORTA,A
CALL FINDC
CPI CL,0
BREQ SET_ROW4
LDI RW,4
RJMP MAIN
SET_ROW4:
RET

FINDC:
LDI CL,0
IN A,PINB
CPI A,0B00001110
BRNE SET_COLUMN1
LDI CL,1
SET_COLUMN1:
CPI A,0B00001101
BRNE SET_COLUMN2
LDI CL,2
SET_COLUMN2:
CPI A,0B00001011
BRNE SET_COLUMN3
LDI CL,3
SET_COLUMN3:
CPI A,0B00000111
BRNE SET_COLUMN4
LDI CL,4
SET_COLUMN4:
RET

You might also like