Question: BE DETAILED , KINDLY Consider the keypad program attached to this assignment called hw5 keypad.asm (using the connection as given in the code), what will

BE DETAILED , KINDLY

Consider the keypad program attached to this assignment called hw5 keypad.asm (using the connection as given in the code), what will be the value returned in register R7 for each of the following cases:

(a) keys 2 and 5 are pressed simultaneousl.

(b) keys 4 and 5 are pressed simultaneously.

Your answer should be based on analyzing the code and not by using the simulator. Explain your answer for each of the cases given.

content of file attached :

;Keyboard subroutine. This program sends the number of key pressed to R7

;P0.0-P0.3 connected to rows, P0.4-P0.6 connected to columns

; organization as follows:

; -------------

; row 0 | * | 0 | # | D0

; -------------

; row 1 | 7 | 8 | 9 | D1

; -------------

; row 2 | 4 | 5 | 6 | D2

; -------------

; row 3 | 1 | 2 | 3 | D3

; -------------

; c0 c1 c2

; D6 D5 D4

K1: MOV P0,#01110000B

MOV A,P0 ;read all col. (ensure all keys open)

ANL A,#01110000B ;masked unused bits

CJNE A,#01110000B,K1 ;check til all keys released

K2:

MOV A,P0 ;see if any key is pressed

ANL A,#01110000B ;mask unused bits

CJNE A,#01110000B,OVER1 ;key pressed, await closure

SJMP K2 ;check if key pressed

MOV P0,011111111B

OVER1:

CLR P0.0

MOV A,P0 ;read all columns

ANL A,#01110000B ;mask unused bits

CJNE A,#01110000B,ROW_0 ;key row 0, find the col.

SETB P0.0

CLR P0.1

MOV P0,#01111101B ;ground row 1

MOV A,P0 ;read all columns

ANL A,#01110000B ;mask unused bits

CJNE A,#01110000B,ROW_1 ;keyrow 1, find the col.

SETB P0.1

CLR P0.2

MOV P0,#01111011B ;ground row 2

MOV A,P0 ;read all columns

ANL A,#01110000B ;mask unused bits

CJNE A,#01110000B,ROW_2 ;key row 2, find the col.

MOV P0,#01110111B ;ground row 3

MOV A,P0 ;read all columns

ANL A,#01110000B ;mask unused bits

CJNE A,#01110000B,ROW_3 ;keyrow 3, find the col.

LJMP K2 ;if none, false input, repeat

ROW_0: MOV DPTR,#KCODE0 ;set DPTR=start of row 0

SJMP FIND ;find col. key belongs to

ROW_1: MOV DPTR,#KCODE1 ;set DPTR=start of row 1

SJMP FIND ;find col. key belongs to

ROW_2: MOV DPTR,#KCODE2 ;set DPTR=start of row 2

SJMP FIND ;find col. key belongs to

ROW_3: MOV DPTR,#KCODE3 ;set DPTR=start of row 3

FIND:

RLC A ;skip D7 data (unused)

FIND1:

RLC A ;see if any CY bit low

JNC MATCH ;if zero, get the key number

INC DPTR ;point to next col. address

SJMP FIND1 ;keep searching

MATCH: CLR A ;set A=0 (match is found)

MOVC A,@A+DPTR ;get key number from table

MOV R7,A ;store pressed key in R7

LJMP K1

;ASCII LOOK-UP TABLE FOR EACH ROW

ORG 300H

KCODE3: DB '1','2','3' ;ROW 3

KCODE2: DB '4','5','6' ;ROW 2

KCODE1: DB '7','8','9' ;ROW 1

KCODE0: DB '*','0','#' ;ROW 0

END

WHAT IS IT EXCTLY THAT IT IS NOT CLEAR ?????????

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!