Another way to left shift a 32 bit data?


Closed Thread
Results 1 to 22 of 22

Hybrid View

  1. #1
    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?

    You didn’t say what you want to do with the bit that drops off the end.
    Assuming you want what PBP shift would do with a byte, and just drop the end bit,
    and feed in a zero to the right.
    Code:
    dis var byte [4]
    
    BitwiseRotateLeft:						' bitwise rotate array
      @ rlf 	_dis+3		,F				; ditching the first bit
      @ rlf		_dis+2		,F				;
      @ rlf		_dis+1		,F				;
      @ rlf		_dis+0		,F				;
      @ bcf		_dis+3		,0				;clear MSB
    return
    So long as you can access the first byte by aliasing it, I’m sure the assembler is a continuous 4 bytes.

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,167


    Did you find this post helpful? Yes | No

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

    Well, yes, it is a PBP3 feature. But besides that, even if you are on a previous version, you may still face the fact of 32 bit variables.

    At the cost of 4x8x32 bytes, George's approach is obviously the fastest because n (times a shiftmust happen) can be anywhere between 1 and 32.

    Thanks for the post.

    Ioannis

  3. #3
    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?

    Oh I get it, the 32 bit var always has 31 clear bits and 1 set bit.

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,167


    Did you find this post helpful? Yes | No

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

    Yes, thats right.

    In case you wonder is part of the Microchip Keeloq algo. A really intense algo...

    Ioannis

  5. #5
    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?

    Can LOOKUP/2 now contain enough elements,
    or you'd need to use 4 lookups? (One for each byte element of the 32 bit val).
    It does sound like reading program memory would be economical for that.
    Last edited by Art; - 24th November 2015 at 17:47.

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,167


    Did you find this post helpful? Yes | No

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

    Since using LONGs in the program will slow down the execution of the program, I am reluctant to use longs. Also the PIC that curretly is used is 16F series.

    So, seems better to spend some bytes in RAM or FLASH and have immediate response.

    Ioannis

  7. #7
    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?

    That’s what I mean. Still a more difficult problem than appears, or more than it intuitively feels like it should be, if speed is the goal.
    The extra 6 bits returned by a single 14 bit READCODE are useless to you because of the time taken to extract them.
    The word variable you get to use to address program memory is also useless to you because you only needed a 32 bit index (or 32x4).
    I’d be interested to hear how you end up tackling it.

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