??? 11/15/09 13:05 Modified: 11/15/09 13:18 Read: times |
#170846 - Binary to BCD to ascii Assembly code 8051 Responding to: ???'s previous message |
Well did a bit of searching there, found a good post saying it is impossible to convert Binary straight to ASCII. You must go to BCD or hex first. Basically he said go convert to bcd, then add 30 to every group. So if i wanted the ascii digit one, i would send 31.. etc.
This is some code i found to convert to bcd: BIN_DEC: MOV A,R0 MOV B,#100 DIV AB MOV R3,A ; R3 CONTAIN HUNDRED NUMBER MOV A,B MOV B,#10 DIV AB MOV R2,A ; R2 CONTAIN TENTH NUMBER MOV R1,B ; R1 CONTAIN LEFT DECIMAL NUMBER LJMP BCD_ASCII RET BCD_ASCII: MOV A, R0 ADD A, #30 MOV A, R1 ADD A, #30 MOV A, R2 ADD A, #30 Questions: Would this code work okay? How would i show the right side decimal number? Should i use a subroutine to add 30? NB My knowledge of assembly code is very low. |
Topic | Author | Date |
Convert Binary numbers to symbols to show on a lcd. | 01/01/70 00:00 | |
Have you considered searching? | 01/01/70 00:00 | |
BCD? | 01/01/70 00:00 | |
Quite sure ASCII | 01/01/70 00:00 | |
Yes, BCD | 01/01/70 00:00 | |
Language dependent | 01/01/70 00:00 | |
The *techniques* are not language-dependent | 01/01/70 00:00 | |
Binary to BCD to ascii Assembly code 8051 | 01/01/70 00:00 | |
Step by step... | 01/01/70 00:00 | |
Attempt to fix code | 01/01/70 00:00 | |
What Assembler? What Simulator? | 01/01/70 00:00 | |
EdSim51 | 01/01/70 00:00 | |
please comment and format your "code" | 01/01/70 00:00 | |
Test your code - at least with pen and paper | 01/01/70 00:00 | |
Not strictly true | 01/01/70 00:00 | |
start with C, optimize generated asm later? | 01/01/70 00:00 | |
That still requires... | 01/01/70 00:00 | |
Misplaced focus?![]() | 01/01/70 00:00 |