Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Challenge

2005-06-08 by Paul Maddox

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.

Paul

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.