shiftin with \bits - What order do they come?


Results 1 to 3 of 3

Threaded View

  1. #3
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: shiftin with \bits - What order do they come?

    I’m mixed up between significant bits & bytes here!

    “The bits shifted in are always the low order bits” reads to me like if you shifted in 4 bits,
    they will be populated from bit0 to bit3 of the variable you read in to, and the difference
    between lowest or highest bit first refers to the order of those 4 bits.
    ie. %00001011 as opposed to %00001101.

    I wouldn’t bet my life on it either, but I’m sure whatever mess you make can be cleaned up after the read.
    REV will reverse the order of a specified number of the lowest bits in a value, so there’s an easy way to
    fix the above two numbers.
    If you want to swap bytes in a word, you can alias the byte values which is a lot more typing than code space.
    Code:
    16bitval var word
    16bitvalswapped var word
    L16bitval var 16bitval.byte0
    H16bitval var 16bitval.byte1
    Ls16bitval var 16bitvalswapped.byte0
    Hs16bitval var 16bitvalswapped.byte1
    
    Ls16bitval = H16bitval ‘ swap bytes
    Hs16bitval = L16bitval
    Last edited by Art; - 3rd April 2015 at 04:48.

Similar Threads

  1. Replies: 2
    Last Post: - 23rd April 2013, 16:34
  2. ShiftIn to array of bits using EXT modifier?
    By HenrikOlsson in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th March 2011, 14:30
  3. DT_INTS-14 /interrupts enable bits / flag bits
    By bogdan in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 16th May 2009, 18:42
  4. Need clever way to convert 10 bits to 8 bits
    By MikeTamu in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 2nd September 2005, 15:13

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts