Question

Q4. Write an 8051 assembly program (using Keil/edsim) to convert a series of ASCII numbers to packed BCD. Assume that the ASC

0 0
Add a comment Improve this question Transcribed image text
Answer #1

.area HOME (CODE)
.area CSEG (CODE)


MOV R1,#0x60;MEMORY ADDRESS TO STORE PACKED BCD
MOV R3,#0x20;COUNT OF ASCII
MOV DPTR,#0x0030
TOP:
MOV A,#0x00
MOVC A,@A+DPTR;FETCH FIRST ASCII
CLR C
SUBB A,#0x30
ANL A,#0x0F
MOV R0,A
INC DPTR
MOV A,#0x00
MOVC A,@A+DPTR;FETCH SECOND ASCII
CLR C
SUBB A,#0x30
SWAP A
ANL A,#0xF0
ORL A,0x00

MOV @R1,A;STORE BCD TO RAM
INC DPTR
INC R1
DJNZ R3,TOP

HERE: SJMP HERE

In the simulator there is no option to edit code segment and hence in place of read code segmnent with the help of DPTR i have direcltly given values 0x36 and 0x35.So the result will store 65 as BCD

I hope you can better understand the self explanatory code.Thank You

Add a comment
Know the answer?
Add Answer to:
Q4. Write an 8051 assembly program (using Keil/edsim) to convert a series of ASCII numbers to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT