I doubt there is an efficient way. Possibly this one could be worth a try:

var bit data_0 at data:0
var bit data_1 at data:1
var bit data_2 at data:2
var bit data_3 at data:3
var bit data_4 at data:4
var bit data_5 at data:5
var bit data_6 at data:6
var bit data_7 at data:7

var bit temp_0 at temp:0
var bit temp_1 at temp:1
var bit temp_2 at temp:2
var bit temp_3 at temp:3
var bit temp_4 at temp:4
var bit temp_5 at temp:5
var bit temp_6 at temp:6
var bit temp_7 at temp:7

temp_0=data_7
temp_1=data_6
temp_2=data_5
temp_3=data_4
temp_4=data_3
temp_5=data_2
temp_6=data_1
temp_7=data_0


But surely my favourite version would be

  asm rrf data,f  asm rlf temp,f  

  asm rrf data,f  asm rlf temp,f  

  asm rrf data,f  asm rlf temp,f  

  asm rrf data,f  asm rlf temp,f  

  asm rrf data,f  asm rlf temp,f  

  asm rrf data,f  asm rlf temp,f  

  asm rrf data,f  asm rlf temp,f  

  asm rrf data,f  asm rlf temp,f  


Greets, 
Kiste
     Von: Rob Hamerling <[email protected]>
 An: [email protected] 
 Gesendet: 10:44 Dienstag, 28.April 2015
 Betreff: [jallib] reversing bits in a byte
   

Hi guys,

Recently I picked up an old project again which uses among others a 
graphical LCD. I think I did put the board aside because I could not get 
it to work properly. It turns out the that the (8) datalines to the GLCD 
are in the wrong sequence. Since the GLCD library uses the full 8 bits 
of a port I do not see a better way to solve this problem (apart from 
changing the hardware) than to insert code to reverse the bits in the 
data byte. Now I'm looking for a good algorithm. I found several pretty 
efficient procedures for ASM and also a few for C/C++. For now I'm using:

> function reverse_bits(byte in data) return byte is
>    const byte lookup_table[16] = { 
> 0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15 }
>    var byte temp
>    temp = 16  * lookup_table[data & 0x0F]
>    temp = temp + lookup_table[data >> 4]
>    return temp
> end function

This looks elegant and seems to work OK, but it may not be very efficient.
Suggestions???


I may not be the only one with the mentioned mistake with the datalines, 
but it would also make the GLCD library more flexible when there are 
more choices for the datalines. Reversing the bits could be one option, 
the use of 2 half ports or 8 individual pins could be other options 
(like with the character-LCD libraries).

Regards, Rob.

-- 
*Rob H*amerling - http://www.robh.nl

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/jallib.
For more options, visit https://groups.google.com/d/optout.


  

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/jallib.
For more options, visit https://groups.google.com/d/optout.

Reply via email to