Move seperate bytes into a word


Results 1 to 19 of 19

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    One step further..
    Code:
    Z VAR WORD
    A VAR Z.LOWBYTE
    B VAR BYTE
    C VAR Z.HIGHBYTE
    D VAR BYTE
    
    '
    '    Some other code where you set A, B, C & D BYTE variables
    '
    
    Z.HIGHBYTE = Z.HIGHBYTE | (D<<4)
    Z.LOWBYTE = Z.LOWBYTE | (B<<4)
    ' Now you have everything in Z... easy huh?
    or.. yet another
    Code:
    Z = Z | (B<<4) | (D<<12)
    Enjoy
    Last edited by mister_e; - 11th November 2008 at 23:10.
    Steve

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

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 08:55
  2. Read/Write Problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th February 2010, 02:51
  3. Minimizing code space
    By Tobias in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th May 2009, 08:25
  4. DS2760 Thermocouple Kit from Parallax in PicBasicPro
    By seanharmon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 9th July 2008, 00:19
  5. calculation problem
    By nicolelawsc in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st March 2006, 16:23

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