variable shift on pic 18f252

Help
tymop
2009-04-27
2013-03-12
  • tymop
    tymop
    2009-04-27

    Dear all,
    I Have a problem, and I 'm not sure the problem comes from the SDCC compiler:
    the component is a pic18f252, and I compile with this command: "Executing: "C:\Program Files\SDCC\bin\sdcc.exe" TRIMBLE_decoder.c -c -mpic16 -p18F252 -I"Z:\GPS_Tracker\GPS_courseTracker\GPS_Embarque\Softs\TRIMBLE_decoder""

    this is the c code:
    it=bloque<<9;
    it and bloque are unsigned long

    And this is the asm code supplied by the compilation:
    ;    .line    205; TRIMBLE_decoder.c    it=bloque<<9;
        MOVF    (_bloque + 1), W, B
        BANKSEL    _bloque
        ADDWF    _bloque, W, B
        BANKSEL    (_it + 1)
        MOVWF    (_it + 1), B
        BANKSEL    (_bloque + 1)
        RLCF    (_bloque + 1), W, B
        BANKSEL    (_it + 2)
        MOVWF    (_it + 2), B
        BANKSEL    (_bloque + 2)
        RLCF    (_bloque + 2), W, B
        BANKSEL    (_it + 3)
        MOVWF    (_it + 3), B
        BANKSEL    _it
        CLRF    _it, B
        BANKSEL    _it

    the result in simulation and on the component is 8 shift...
    for example, bloque=1, ant the result is it=256 (instead of 512)

    I tried others shift : 1,2,3,4,8: they all works well. Only the 9 shift does not work.

    Do you think that comes from SDCC or other errors ( like me :) ).
    Can anybody help me ? Many thank.

     
    • Raphael Neider
      Raphael Neider
      2009-04-27

      This works nicely with sdcc 2.9.0 (svn r5416) as well as sdcc 2.9.1 (svn r5438).

      The culprit is the first line of your .asm excerpt:
      MOVF (_bloque + 1), W, B
      should really be
      MOVF _bloque, W, B
      which it is for recent compiler versions.

      Please update your sdcc (find out which version you have by calling
      "C:\Program Files\SDCC\bin\sdcc.exe" -v
      if you want to).

      Hope this helps,
      Raphael

       
    • Raphael Neider
      Raphael Neider
      2009-04-27

      This issue was probably fixed in sdcc 2.8.2 (svn r5200) on 2008-07-29.

       
    • tymop
      tymop
      2009-04-27

      Thank you