A Question on "REV"


Closed Thread
Results 1 to 3 of 3

Hybrid View

  1. #1

    Default A Question on "REV"

    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

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    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>
    DT

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Thanks Darrel.

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

    Ken

Similar Threads

  1. Eeprom question
    By karenhornby in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 20th April 2008, 20:21
  2. AN Question for "word" variable read The serial port
    By redfoen in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 14th December 2007, 17:39
  3. Crystals & Caps - Super noob question??
    By kevj in forum General
    Replies: 4
    Last Post: - 24th September 2007, 17:11
  4. Question for a math guru
    By Christopher4187 in forum General
    Replies: 3
    Last Post: - 22nd November 2006, 09:45
  5. Please answer my first question
    By John_001 in forum Off Topic
    Replies: 1
    Last Post: - 15th September 2006, 06:49

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts