Another way to left shift a 32 bit data?


Results 1 to 22 of 22

Threaded View

  1. #22
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Another way to left shift a 32 bit data?

    The code in post 16 that will easily beat that, and take the same duration no matter what the input.
    I’ve only measured PBP by disassembly and then counting the assembler instruction time.
    Bitwise rotation of each byte is one instruction, shifting and other bitwise operations that have an input value should be two assembler instructions.

    But yes, using the same technique as post #16 expressed in PBP will beat the assembler in post #6.

    Consider the value you begin with begins at array location 0,
    and your input is 16, so you need to rotate it 16 times:
    Code:
    00000000 00000000 00000000 00000001
    ^
    arraylocation[0]
    Divide the 16 by 8, and result is 2. Add 2 to the array location index and bingo:



    The reason your 4 byte array has values around it is so you can still use the four bit value



    The only thing that complicates it is that your input won’t often be evenly divisible by 2.
    The rest of the code shifts the byte by the modulus.
    You could still easily beat the asm rotation with a single PBP divide with modulus,
    but PBP might not beat the particular implementation of asm divide and modulus!

    I edited images in there because I wasn’t getting fixed width for spaces.
    Last edited by Art; - 12th December 2015 at 17:58.

Similar Threads

  1. how to "shift" a data into led matrix display ?
    By CuriousOne in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 9th January 2015, 16:09
  2. Bit Shift difference between PIC16 and PIC18 ???
    By bambi123 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 26th February 2012, 01:04
  3. Shift Right, Left
    By tazntex in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th July 2010, 15:28
  4. Replies: 2
    Last Post: - 7th March 2008, 02:16
  5. LCDOUT 4-bit data on 8-bit setting
    By breesy in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 26th June 2006, 18:39

Members who have read this thread : 1

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