Question 6.7: (a) Write a program to get hex data in the range of 00 – FFH...
(a) Write a program to get hex data in the range of 00 – FFH from port 1 and convert it to decimal. Save it in R7, R6 and R5.
(b) Assuming that P1 has a value of FDH for data, analyze program.
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.
Learn more on how we answer questions.
(a)
MOV A,#0FFH MOV P1,A ;make P1 an input port MOV A,P1 ;read data from P1 MOV B,#10 ;B=0A hex DIV AB ;divide by 10 MOV R7,B ;save lower digit MOV B,#10 DIV AB ;divide by 10 once more MOV R6,B ;save the next digit MOV R5,A ;save the last digit |
(b) To convert a binary (hex) value to decimal, we divide it by 10 repeatedly until the quotient is less than 10. After each division the
remainder is saves.
Q R
FD/0A = 19 3 (low digit)
19/0A = 2 5 (middle digit)
2 (high digit)
Therefore, we have FDH=253.
Related Answered Questions
Question: 6.8
Verified Answer:
1. 0011 0100 34H given in binary
2. ...
Question: 6.12
Verified Answer:
MOV A,#41H
SETB P2.1 ;high
SETB ...
Question: 6.10
Verified Answer:
MOV P2,#00 ;clear P2
MOV P1,#0FFH ;...
Question: 6.18
Verified Answer:
(a) Find the checksum byte.
\begin{array}{r...
Question: 6.17
Verified Answer:
MOV DPTR,#MYTABLE
MOV A,P1 ...
Question: 6.16
Verified Answer:
(a)
MOV A,#72H ;A = 72H
SWAP A ...
Question: 6.15
Verified Answer:
MOV R1,#0 ;R1 keeps number of 1s
MOV...
Question: 6.14
Verified Answer:
SETB C ;CY = 1
ORL C,P2.2 ...
Question: 6.13
Verified Answer:
MOV R5,#8
AGAIN: MOV C,P2.7 ;...
Question: 6.9
Verified Answer:
\begin{array}{r c}\begin{matrix} \\ + \\ + ...