Bit Masking and Or?


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2008
    Posts
    52

    Default Bit Masking and Or?

    How do I convert from a 4 bit number such as x = 0110

    to an 8 bit number such as x = 00100110

    Do I:

    -----0110
    00001111 And
    ---------
    00000110


    00000110
    00100000 OR
    ---------
    00100110 Result



    Thanks, Don
    Last edited by dbachman; - 24th February 2009 at 05:48.

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    4 bit number . . . you trying to convert code from Stamp?
    x = 0110 is I believe the same as x = 00000110 and same as 6 and same as $06. There are no nibble variables in PBP you have to use the whole byte. So MyVar Var NIB becomes MyVar VAR BYTE.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Oct 2008
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Hi Joe,

    So....

    Data @0 , 6

    read 0, x

    Would the variable x be equal to 00000110b

    so then to make it 00100110 I would OR it with 00100000?


    Thanks, Don

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    http://en.wikipedia.org/wiki/Bitwise_operation
    I am not a MATH Guy, but I believe in the example you listed, a bitwise OR would do that. Here is a link with some info. Or cannot you just add the 32 to six ?
    Last edited by Archangel; - 24th February 2009 at 06:35.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    with PBP, 4 Bit number don't exist. I know STAMPs have Nibble variable, but not in PBP. You have Bit, BYTE, and WORD. So you could use OR or just directly set the bit you want

    ByteA = %110
    ByteA.5=1

    should do the trick as well.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Members who have read this thread : 1

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