Dave,
> Speed contest: Fast code desired, space is no object.
> Task: Make UP look like Down by rotating all the bits in a byte.
> Input in TEMP, output in TEMP2 or for bonus points, in TEMP, such that
you want quick? and space isn't a problem?
use a Look Up Table, and use LPM
simply copy the value from the TEMP register to R30, dump the table location
into R31 (and Left shift it, or just keep a value thats correct to avoid
this step) and the move r0 to Temp2
.EQU TABLE_LOC =$02
REVERSE:
LDI R31,TABLE_LOC
MOV R30,TEMP
LPM
MOV TEMP2,R0
.ORG $0100
REVERSE_TABLE:
.db 0xFF,0xFE,0xFD, etc, etc, etc
not sure the code is 100% correct, but you get the idea.
PaulMessage
Re: [AVR-Chat] Challenge
2005-06-08 by Paul Maddox
Attachments
- No local attachments were found for this message.