??? 11/16/09 20:05 Read: times |
#170886 - start with C, optimize generated asm later? Responding to: ???'s previous message |
Maybe start with C, passing this through a compiler:
unsigned char data a[3]; extern void out_a(void); void doit(unsigned char c) { a[0] = '0' + c/100; a[1] = '0' + (c%100)/10; a[2] = '0' + (c%10); out_a(); } Using SDCC as compiler will get you here: _doit: mov r2,dpl ; bin2ascii.c:6: a[0] = '0' + c/100; mov b,#0x64 mov a,r2 div ab add a,#0x30 mov _a,a ; bin2ascii.c:7: a[1] = '0' + (c%100)/10; mov b,#0x64 mov a,r2 div ab mov a,b mov b,#0x0A div ab add a,#0x30 mov (_a + 0x0001),a ; bin2ascii.c:8: a[2] = '0' + (c%10); mov b,#0x0A mov a,r2 div ab mov a,b add a,#0x30 mov (_a + 0x0002),a ; bin2ascii.c:10: out_a(); ljmp _out_a Especially if your knowledge of 8051 assembly code is (still) low the compiler generated code is a good start (you can strip some cycles and bytes, although that likely wont matter on a LCD:) |
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 |