??? 05/28/07 04:05 Modified: 05/28/07 05:06 Read: times |
#139912 - Yet another tweak Responding to: ???'s previous message |
Well, well. I'm glad to see that there's at least one other person that's interested in this stuff besides Jan and me.
I think it was Quiz5 that also had a constant execution time, but it was nowhere as pretty or as fast as your table lookup method. I sort of cringed at the hard-coded constants on the ADD instructions, which depend on the offsets between the MOVC instructions and the table. Talk about a maintenance nightmare! Better IMO to let the assembler calculate those offsets, something like the following. But even this one isn't as nice as it ought to be because the "-1" term in the table offset calculations is so ugly. Can somebody suggest a good way to get rid of it? -- Russ 00C9 Quiz14: 00C9 F8 mov r0, a 00CA 540F anl a, #0Fh 00CC 2409 add a, #Table-Movc1-1 00CE 83 Movc1: movc a, @a+pc 00CF C8 xch a, r0 00D0 C4 swap a 00D1 540F anl a, #0Fh 00D3 2402 add a, #Table-Movc2-1 00D5 83 Movc2: movc a, @a+pc 00D6 28 add a, r0 00D7 22 ret 00D8 00 Table: db 0 ; 0 - 0000 00D9 01 db 1 ; 1 - 0001 00DA 01 db 1 ; 2 - 0010 00DB 02 db 2 ; 3 - 0011 00DC 01 db 1 ; 4 - 0100 00DD 02 db 2 ; 5 - 0101 00DE 02 db 2 ; 6 - 0110 00DF 03 db 3 ; 7 - 0111 00E0 01 db 1 ; 8 - 1000 00E1 02 db 2 ; 9 - 1001 00E2 02 db 2 ; A - 1010 00E3 03 db 3 ; B - 1011 00E4 02 db 2 ; C - 1100 00E5 03 db 3 ; D - 1101 00E6 03 db 3 ; E - 1110 00E7 04 db 4 ; F - 1111 |
Topic | Author | Date |
weekend-end quiz | 01/01/70 00:00 | |
How about this? | 01/01/70 00:00 | |
@#$%^& | 01/01/70 00:00 | |
Two equivalent functions | 01/01/70 00:00 | |
OK, I admit, 2:1 | 01/01/70 00:00 | |
Nice variation! | 01/01/70 00:00 | |
shortest? | 01/01/70 00:00 | |
Eleven bytes. No tricks. | 01/01/70 00:00 | |
The wayward path followed... | 01/01/70 00:00 | |
Deterministic Way | 01/01/70 00:00 | |
Yet another tweak | 01/01/70 00:00 | |
OMG.... | 01/01/70 00:00 | |
You are forgiven | 01/01/70 00:00 | |
commented | 01/01/70 00:00 | |
Nastiness density increased | 01/01/70 00:00 | |
That looks like my assembly code. | 01/01/70 00:00 |