| ??? 07/22/08 06:25 Read: times |
#156926 - first do it in C, then Responding to: ???'s previous message |
do final polishing on the generated assembler code:
#define NUM_DIGITS 8
unsigned char __idata __at(0x60) my_num[NUM_DIGITS];
void inc_my_num()
{
unsigned char __idata *p = my_num;
unsigned char i = NUM_DIGITS;
do
{
(*p)++;
if( 10 == *p )
*p = 0;
else
break;
p++;
} while (--i)
using SDCC:
0000 101 _inc_my_num:
110 ; inc.c:7: unsigned char idata *p = my_num;
111 ; inc.c:10: do
0000 78 60 112 mov r0,#_my_num
0002 7A 08 113 mov r2,#0x08
0004 114 00104$:
115 ; inc.c:12: (*p)++;
0004 86 03 116 mov ar3,@r0
0006 0B 117 inc r3
0007 A6 03 118 mov @r0,ar3
119 ; inc.c:13: if( 10 == *p )
0009 BB 0A 05 120 cjne r3,#0x0A,00107$
121 ; inc.c:14: *p = 0;
000C 76 00 122 mov @r0,#0x00
000E 08 123 inc r0
124 ; inc.c:18: p++;
125 ; inc.c:19: } while (--i);
000F DA F3 126 djnz r2,00104$
0011 127 00107$:
0011 22 128 ret
|
| Topic | Author | Date |
| incrementing a large number in assembly | 01/01/70 00:00 | |
| Wear and tear | 01/01/70 00:00 | |
| The EEPROM is | 01/01/70 00:00 | |
| F-RAM | 01/01/70 00:00 | |
| F-RAM problem | 01/01/70 00:00 | |
| what's the problem? | 01/01/70 00:00 | |
| found a substitute | 01/01/70 00:00 | |
| first do it in C, then | 01/01/70 00:00 | |
| Load/Save in loop | 01/01/70 00:00 | |
| To Answer Your Question ... | 01/01/70 00:00 | |
| Thanks Russ - slow event | 01/01/70 00:00 | |
| A sample code for your task | 01/01/70 00:00 | |
| Sample code irrelevant | 01/01/70 00:00 | |
| Socketed EEPROM? | 01/01/70 00:00 | |
| walking writes are dead simple | 01/01/70 00:00 | |
| Larger EEPROM = simple code | 01/01/70 00:00 | |
| the counter is | 01/01/70 00:00 | |
| good point | 01/01/70 00:00 | |
Blinkers | 01/01/70 00:00 |



