??? 01/19/11 23:01 Read: times |
#180708 - algorithm, assembler Responding to: ???'s previous message |
> i am not familier with C language and i have already told you that i have just started progrmmimng on microcontrollers so please keep in mind MY LEVEL.
You specifically asked a question and posted code, everything is fine! (The slightly inflamatory subject I had chosen was because I reacted on the part where you seemed to require an implementation "ASSEMBLER" and within that implementation further implementation details (ajmp/acall) while I felt you were talking about algorithms) Anyway here goes assembler code, how about: 000A 342 00102$: 000A 7A 00 343 mov r2,#0x00 000C 344 00115$: 000C EA 345 mov a,r2 000D 20 E7 FA 346 jb acc.7,00102$ 0010 7B 80 347 mov r3,#0x80 0012 348 00111$: 0012 EB 349 mov a,r3 0013 60 13 350 jz 00117$ 0015 EA 351 mov a,r2 0016 4B 352 orl a,r3 0017 F5 90 353 mov _P1,a 0019 7C BE 354 mov r4,#0xBE 001B 7D AF 355 mov r5,#0xAF 001D 356 00104$: 001D 00 357 NOP 001E DC FD 358 djnz r4,00104$ 0020 DD FB 359 djnz r5,00104$ 0022 EB 360 mov a,r3 0023 C3 361 clr c 0024 13 362 rrc a 0025 FB 363 mov r3,a 0026 80 EA 364 sjmp 00111$ 0028 365 00117$: 0028 EA 366 mov a,r2 0029 2A 367 add a,r2 002A FA 368 mov r2,a 002B 43 02 01 369 orl ar2,#0x01 002E 80 DC 370 sjmp 00115$ Which was generated from: #include <8051.h> static inline void delay(void) { unsigned char i = 0xbe; // 0x00 -> 256 unsigned char k = 0xaf; // 0x00 -> 256 do { do { __asm NOP __endasm; } while ( --i ); } while( --k ); } void main(void) { while( 2 ) { unsigned char sanddrop; // highest bit on top unsigned char sandbottom; // lowest bit at bottom for( sandbottom = 0x00; !(sandbottom & 0x80); sandbottom <<= 1, sandbottom |= 0x01 ) // C is ugly too! { for( sanddrop = 0x80; sanddrop; sanddrop >>= 1 ) { P1 = sanddrop | sandbottom; delay(); } } } } with: sdcc --no-xinit-opt --main-return --acall-ajmp --std-sdcc99 --no-c-code-in-asm sandwatch.c (Note, the table approach Michael mentioned makes a lot of sense too) |
Topic | Author | Date |
Help Help Codes for 8 LEDs Sand Watch in ASSEMBLY | 01/01/70 00:00 | |
Hourglass? | 01/01/70 00:00 | |
8 LEDs sand watch | 01/01/70 00:00 | |
Table or nested loops | 01/01/70 00:00 | |
Didn't you just repeat exactly the same post? | 01/01/70 00:00 | |
possible approach | 01/01/70 00:00 | |
LED Patterns | 01/01/70 00:00 | |
Using spreadsheets | 01/01/70 00:00 | |
Further -- Consider | 01/01/70 00:00 | |
Cart before horse | 01/01/70 00:00 | |
What does AND and OR? | 01/01/70 00:00 | |
last time I looked 89S52 had 8 kByte flash, ASSEMBLY? | 01/01/70 00:00 | |
First Cycle Compete | 01/01/70 00:00 | |
How to post legible source code | 01/01/70 00:00 | |
algorithm, assembler | 01/01/70 00:00 | |
Thanks for the help and support | 01/01/70 00:00 |