Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

PIC Microcontroller Question

  1. Nov 24, 2013 #1
    Hello guys!

    The following question is related to the P18F2520 series.

    Suppose you have 2 defined variables var1 and var2 each containing 8 bits from a certain source.

    However I only need the 4 least significant bits from var1 and the 4 most significant bit from var 2 in order to fill up a new variable var3.

    Any clue how to do this? (I need a command analogue to MOVFF but regarding moving single bits)

    Thank you!
     
  2. jcsd
  3. Nov 24, 2013 #2

    berkeman

    User Avatar

    Staff: Mentor

    Mask off the unwanted bits to 0 and then OR the two bytes...
     
  4. Nov 24, 2013 #3
    Ah didn't think about using logical operators for this task. Thought that a movbit function exist.
    Thanks for your answer I'll definitely use it!
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: PIC Microcontroller Question
Loading...