Another way to left shift a 32 bit data?


Closed Thread
Results 1 to 22 of 22

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139


    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

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

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139


    Did you find this post helpful? Yes | No

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

    It is indeed a complex problem. In any option chosen, there would be some overhead lower or higher I guess.

    I think I will end up in the asm code to rotate the variables.

    Ioannis

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,653


    Did you find this post helpful? Yes | No

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

    you can set or clr any bit in an array
    dis var byte [4]

    dis.0[x] = 1 ; will set bit x in array dis where x=0 to 31

    or make a user command something like this (untested)
    USERCOMMAND "SETBIT" ; BIT,VALUE

    Code:
    SETBIT?CC macro Bitin,Val
    if Bitin <32
      if Bitin > 23
    k=3
      elseif  Bitin > 15
    k=2
      elseif  Bitin > 7
    k=1
      elseif  Bitin <8
    k=0
      endif
    b=Bitin-k*8
    
    
      if Val >0
      bsf _dis+k,b
      else
      bcf  _dis+k,b
      endif
    endif
    endm
    not sure if user cmd is really useful here
    Last edited by richard; - 25th November 2015 at 03:12. Reason: white spac e

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139


    Did you find this post helpful? Yes | No

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

    Thanks Richard.

    Interesting approach!

    Ioannis

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

    I don’t yet know if I’ve wrecked it in basic.

    Code:
    shifter byte
    offset byte
    array byte[7]
    
    
    shifter = 11
    offset = shifter >> 3            // byte in array to pass to whatever needs the 4 byte result, in this case 2
    array[3] = 1<<(shifter & 7)      // Set it to 00000000 (00000000 00000000 00001000 00000000) 00000000 00000000
    ‘dostuff with array[offset]

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139


    Did you find this post helpful? Yes | No

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

    I could not follow that...

    Ioannis

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