Move seperate bytes into a word


Results 1 to 19 of 19

Threaded View

  1. #13
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default 4 bytes RAM, 4 instructions to convert

    OK - here's a little smaller verion...;o}
    Code:
    Z VAR WORD BANK0 ; use BANKA for 18F part
    A VAR Z.LowByte
    B VAR BYTE BANK0
    C VAR Z.HighByte
    D VAR BYTE BANK0
    
    A=%00000001
    B=%00000010
    C=%00000011
    D=%00000100
    
    ASM
        CHK?RP _Z
        swapf  _B, W     ; swap nibbles in B, result in W
        iorwf  _A, F     ; or with A, result in A (low byte is done)
        swapf  _D, W     ; swap nibbles in D, result in W
        iorwf  _C, F     ; or with C, result in C (HighByte is done)
    ENDASM
    Z = %0100 0011 0010 0001
    Last edited by Bruce; - 12th November 2008 at 09:29. Reason: Force vars into same bank
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

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