How to reverse a byte
How to reverse a byte I am currectly working on a project and it happens that I have to reverse the order of a byte. I am currently using AVR Studio Mega32 Microcontroller. For example: 0000 0001 becomes 1000 0000 0001 0110 becomes 0110 1000 1101 1001 becomes 1001 1011 To start I have this: ldi r20,0b00010110 What is the easiest way to reverse the byte so that r20 becomes 01101000? have a look at stackoverflow.com/questions/4924060/… there are a few suggestions how to solve it. You may also have a look at graphics.stanford.edu/~seander/bithacks.html#BitReverseObvious for more algorithms how to reverse a byte (the code is in C but should be ported to asm easily) – dwalter Mar 15 '13 at 10:48 Easy for whom? Personally I'd use (table16[orig & 15]<<4) | table16[(orig>>4)];` One can easily conv...