| ??? 05/28/07 02:11 Read: times |
#139911 - Deterministic Way Responding to: ???'s previous message |
Well....I have to admit I tried and tried to find a way to reduce Russ's algorithm to less than 11 bytes. I found 4 or 5 other ways to code to 11 bytes but none at 10. Oh well on the otherhand......
Sometimes it is desirable to code things in a way that the code path execution time is always the same length of time. (This can reduce jitter in certain types of applications). I made a new version that achieves the deterministic goal and also has a faster execution rate for most cases of the input pattern.
0006 24 Quiz13:
0006 F8 25 mov r0, a
0007 540F 26 anl a, #0Fh
0009 2409 27 add a, #9
000B 83 28 movc a, @a+pc
000C C8 29 xch a, r0
000D C4 30 swap a
000E 540F 31 anl a, #0Fh
0010 2402 32 add a, #2
0012 83 33 movc a, @a+pc
0013 28 34 add a, r0
0014 22 35 ret
36 ;
0015 00 37 db 0 ; 0 - 0000
0016 01 38 db 1 ; 1 - 0001
0017 01 39 db 1 ; 2 - 0010
0018 02 40 db 2 ; 3 - 0011
0019 01 41 db 1 ; 4 - 0100
001A 02 42 db 2 ; 5 - 0101
001B 02 43 db 2 ; 6 - 0110
001C 03 44 db 3 ; 7 - 0111
001D 01 45 db 1 ; 8 - 1000
001E 02 46 db 2 ; 9 - 1001
001F 02 47 db 2 ; A - 1010
0020 03 48 db 3 ; B - 1011
0021 02 49 db 2 ; C - 1100
0022 03 50 db 3 ; D - 1101
0023 03 51 db 3 ; E - 1110
0024 04 52 db 4 ; F - 1111
Michael Karas |
| 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 |



