Yahoo Groups archive

AVR-Chat

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

Message

Re: [AVR-Chat] Challenge

2005-06-07 by James Hatley

Hi Dave,

How about ROL TEMP then ROR TEMP2 etc. enough to move number.

Jim

----- Original Message ----- 
From: "Dave VanHorn" <dvanhorn@dvanhorn.org>
To: <AVR-Chat@yahoogroups.com>
Sent: Tuesday, June 07, 2005 1:35 PM
Subject: [AVR-Chat] Challenge


>
> 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
>
> Input: 7,6,5,4,3,2,1,0      10101110 or AE
>
> Routine happens, then
>
> Output: 0,1,2,3,4,5,6,7    01110101 or 75
>
> The obvious solution is to clear the output and set the bits with
> SBRC like this:
>
> ;
>
;***************************************************************************
**********
> ;
> ;Bit swap end for end.
> ;
> Untwist:
> push TEMP2 ;
> clr TEMP2 ;
>
> sbrc TEMP,0 ;
> sbr TEMP2,1<<7 ;
>
> sbrc TEMP,1 ;
> sbr TEMP2,1<<6 ;
>
> sbrc TEMP,2 ;
> sbr TEMP2,1<<5 ;
>
> sbrc TEMP,3 ;
> sbr TEMP2,1<<4 ;
>
> sbrc TEMP,4 ;
> sbr TEMP2,1<<3 ;
>
> sbrc TEMP,5 ;
> sbr TEMP2,1<<2 ;
>
> sbrc TEMP,6 ;
> sbr TEMP2,1<<1 ;
>
> sbrc TEMP,7 ;
> sbr TEMP2,1<<0 ;
>
> mov TEMP,TEMP2 ;
>
> pop TEMP2
> ret ;
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>

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.