Question 6.17: Assume that the lower three bits of P1 are connected to thre...

Assume that the lower three bits of P1 are connected to three switches. Write a program to send the following ASCII characters to P2 based on the status of the switches.

000        ‘0’
001         ‘1’
010         ‘2’
011          ‘3’
100         ‘4’
101          ‘5’
110          ‘6’
111           ‘7’

The blue check mark means that this solution has been answered and checked by an expert. This guarantees that the final answer is accurate.
Learn more on how we answer questions.

MOV      DPTR,#MYTABLE
MOV      A,P1                    ;get SW status
ANL       A,#07H              ;mask all but lower 3
MOVC   A,@A+DPTR      ;get data from table
MOV      P2,A                   ;display value
SJMP     $                         ;stay here

; – – – – – – – – – – – – – – – – – –

ORG       400H

MYTABLE     DB       ‘0’,‘1’,‘2’,‘3’,‘4’,‘5’,‘6’,‘7’

END

Related Answered Questions

Question: 6.8

Verified Answer:

1.     0011 0100        34H given in binary 2.    ...
Question: 6.10

Verified Answer:

MOV    P2,#00        ;clear P2 MOV    P1,#0FFH   ;...
Question: 6.15

Verified Answer:

MOV   R1,#0             ;R1 keeps number of 1s MOV...
Question: 6.13

Verified Answer:

MOV    R5,#8 AGAIN:         MOV   C,P2.7         ;...