[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] swap bits
From: |
Volkmar Dierkes |
Subject: |
Re: [avr-gcc-list] swap bits |
Date: |
Tue, 21 Jan 2003 17:49:09 +0100 |
Hi,
Torsten Hahn <address@hidden> schrieb am 21.01.03 17:31:34:
> iam looking for a way, to efficiently swap all bits in an register. Can
> somebody help me with a little asm-macro or a pice of efficient c-code ?
> It schould take an 8bit value as input an give back an value, where bi7
> of the input is now the bit 0, bit6 is bit1 etc.
What do you mean with efficiently? bytes or time?
Quick is a lookup table, but it needs 256 bytes for the table plus some less
bytes for the access to the table.
one other may be (not tested):
value in r16, output in r17.
LDI r18,8
loop:
ROL r16
ROR r17
SUBI r18,1
BRNE loop
Volkmar
______________________________________________________________________________
Werden Sie kreativ! Bei WEB.DE FreeMail heisst es jetzt nicht nur schreiben,
sondern auch gestalten. http://freemail.web.de/features/?mc=021142
avr-gcc-list at http://avr1.org