setting a bit on a ram variable

Discussion in 'Sega Discussion' started by Scorpion Illuminati, Nov 10, 2015.

  1. Scorpion Illuminati

    Scorpion Illuminati Scorpion Illuminati Lead Developer(Site Supporter)

    Joined:
    Oct 1, 2015
    Messages:
    25
    Likes Received:
    1
    Lets say i have a Byte variable called flags. As you know an integer has 8 bits.
    Code:
    7-6-5-4-3-2-1-0
    
    How would I set bit X where x is 0 to 7? For example:
    Code:
    flags       equ (audio_clock+SizeByte)
    
    FLAG_FRET_GREEN       equ 0x1
    FLAG_FRET_RED           equ 0x2
    FLAG_FRET_YELLOW    equ 0x4
    
    // now set it
    ?????
    
    I want to set a bit without effecting the other ones. Any assistance in this matter would be greatly appreciated.

    Sincerely,

    Scorpion Illuminati
     
  2. rso

    rso Gone. See y'all elsewhere, maybe.

    Joined:
    Mar 26, 2010
    Messages:
    2,190
    Likes Received:
    447
    Simply OR the current value with the bitmask. And re-/unset by ANDing it with the inverse of the mask.
     
sonicdude10
Draft saved Draft deleted
Insert every image as a...
  1.  0%

Share This Page