??? 09/07/09 22:47 Modified: 09/07/09 22:48 Read: times |
#168786 - what to unroll Responding to: ???'s previous message |
Gonzalo unrolled the loop over P2 in the inner loop, thereby saving 28% time compared to P2 unrolled in the outer loop (which is a few bytes shorter).
clr a mov r0, a mov p2, a cpl a lp0: movx @r0, a ;P2 = 0 djnz r0, lp0 inc p2 lp1: movx @r0, a ;P2 = 1 djnz r0, lp1 inc p2 lp2: movx @r0, a ;P2 = 2 djnz r0, lp2 inc p2 lp3: movx @r0, a ;P2 = 3 djnz r0, lp3But if you use an auto-incrementing DPTR as you mentioned and keep counting in R0 and/or R1 using DJNZ you gain little from the auto-increment. (Checking DPL and/or DPH is even more expensive.) clr a mov r0, a mov r1, #4 mov dptr, #0 mov autoinc, #1 ;or whatever it takes cpl a lp0: movx @dptr, a djnz r0, lp0 djnz r1, lp0 ;no unroll clr a mov r0, a mov dptr, #0 mov autoinc, #1 ;or whatever it takes cpl a lp0: movx @dptr, a ;DPH = 0 djnz r0, lp0 lp1: movx @dptr, a ;DPH = 1 djnz r0, lp1 lp2: movx @dptr, a ;DPH = 2 djnz r0, lp2 lp3: movx @dptr, a ;DPH = 3 djnz r0, lp3Now with a different unroll you do start to gain. clr a mov r0, a mov dptr, #0 mov autoinc, #1 ;or whatever it takes cpl a lp0: movx @dptr, a ;DPL = 0xn0/4/8/C movx @dptr, a ;DPL = 0xn1/5/9/D movx @dptr, a ;DPL = 0xn2/6/A/E movx @dptr, a ;DPL = 0xn3/7/B/F djnz r0, lp0You can choose how far to unroll and adjust R0 accordingly. |
Topic | Author | Date |
Fastest way to fill buffer | 01/01/70 00:00 | |
something like this | 01/01/70 00:00 | |
when software hits limits... | 01/01/70 00:00 | |
auto-increment | 01/01/70 00:00 | |
Two questions .. | 01/01/70 00:00 | |
But Gonzallo unrolled it already isn't it? | 01/01/70 00:00 | |
Yes, but not with the hardware increment | 01/01/70 00:00 | |
be specific | 01/01/70 00:00 | |
Don't forget about the Maxim/Dallas parts! | 01/01/70 00:00 | |
what to unroll | 01/01/70 00:00 | |
Well, what you CAN do ...![]() | 01/01/70 00:00 |