PDA

View Full Version : A Question on "REV"



ozarkshermit
- 23rd March 2009, 17:37
Howdy

I have not tried this yet, but am confused on the definition of "REV" on page 39 of the PBP Compiler manual, section 4.17.11

" REV reverses the order of the lowest bits in a value. The number of bits to be reversed is from 1 to 32. "

The example shows:

B0 = %10101100 REV 4 'sets B0 to %00000011

I thought only the lowest 4 bits would be reversed - why are bits 5 and 7 also changed? (set to 0) ?

I Suppose I could just write a short program and try it . . . . .

Ken

Darrel Taylor
- 23rd March 2009, 19:24
Yup, that's the way it works.

It reverses the bits by rotating them into a 0'd variable.

<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" WIDTH="300" HEIGHT="200" ><PARAM NAME="MOVIE" VALUE="http://www.pbpgroup.com/files/REV4.swf"><PARAM NAME="PLAY" VALUE="true"><PARAM NAME="LOOP" VALUE="true"><PARAM NAME="QUALITY" VALUE="high"><EMBED SRC="http://www.pbpgroup.com/files/REV4.swf" WIDTH="300" HEIGHT="200" PLAY="true" LOOP="true" WMODE="opaque" QUALITY="high" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>

If you want to preserve the upper 4 bits, you can OR them back in.

B0 = (%10101100 & $F0) | (%10101100 REV 4)

--- Same thing with the value in a variable ---
B1 = %10101100
B0 = (B1 & $F0) | (B1 REV 4)

result = 10100011
<br>

ozarkshermit
- 24th March 2009, 00:13
Thanks Darrel.

I totally understand - I guess rotate would have made more sense than reverse - anyway thanks

Ken