| ??? 02/21/08 22:42 Read: times |
#151277 - Weekend Quiz |
Weekend Quiz: What does the following snippet do?
;inputs: r5, r6, r7
;output: a
AaaOfBbbb:
mov a,r6 ;if Ccccc is 1 or 2
cjne a,#3,AaaOfBbbbX1
AaaOfBbbbX1:
mov a,r7 ; count it as if it would be previous Dddd
subb a,#0
mov b,a
rr a
rr a
anl a,#03Fh ;subtract the correction
clr c
subb a,b ; and store as negative
mov b,a
mov a,r7 ;Now the calculation itself: Dddd*2
rl a
add a,b ;plus the precalculated corrections
mov b,a
mov a,r6 ;plus sum of Aaa-s for Ccccc
add a,#AaaOfBbbbTab-AaaOfBbbbX2-1
movc a,@a+pc ; mod 7, picked from table
AaaOfBbbbX2:
add a,r5 ;plus Aaa
add a,b
add a,#4 ;plus correction for first Aaa of Dddd
mov b,#7
div ab ;sum mod 7 is the result
mov a,b
ret
AaaOfBbbbTab:
db 0,3,4,0,2,5,0,3,6,1,4,6
Enjoy! :-) JW |
| Topic | Author | Date |
| Weekend Quiz | 01/01/70 00:00 | |
| This is only Thursday | 01/01/70 00:00 | |
| initial conditions? | 01/01/70 00:00 | |
| I can't tell... | 01/01/70 00:00 | |
| It gives an error | 01/01/70 00:00 | |
| it depends on the assembler | 01/01/70 00:00 | |
| Jan, I sent an email clue | 01/01/70 00:00 | |
| One Instruction... | 01/01/70 00:00 | |
| well, I have a plenty of points... | 01/01/70 00:00 | |
| Dedicated HW | 01/01/70 00:00 | |
| I don\'t understand... | 01/01/70 00:00 | |
| could these two be related? | 01/01/70 00:00 | |
| Carry bit is used | 01/01/70 00:00 | |
| Thanks Craig... | 01/01/70 00:00 | |
| next time I will try to obfuscate... | 01/01/70 00:00 | |
Day Of Week calculation | 01/01/70 00:00 |



