This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Cortex M3 - Right Shift Bug

Hi,

I'm using uVision 3.33, supplied as part of the Luminary Micro design contest. I've noticed the following problem when trying to right-shift a 16-bit unsigned value.

The code produced is:-

   176: unsigned short int16;
   177:
   178: void testfunc(void)
   179: {
0x0000072E BD10      POP      {r4,pc}
   180:         int16 >>= 1;
0x00000730 480A      LDR      r0,[pc,#40]  ; @0x0000075C
0x00000732 8800      LDRH     r0,[r0,#0x00]
0x00000734 4909      LDR      r1,[pc,#36]  ; @0x0000075C
0x00000736 8008      STRH     r0,[r1,#0x00]
   181: }

.. which does not do a right shift !

If I do a left shift, however, it works:-

   176: unsigned short int16;
   177:
   178: void testfunc(void)
   179: {
0x0000072E BD10      POP      {r4,pc}
   180:         int16 <<= 1;
0x00000730 480C      LDR      r0,[pc,#48]  ; @0x00000764
0x00000732 8800      LDRH     r0,[r0,#0x00]
0x00000734 F64F71FF  MOVW     r1,#0xFFFF
0x00000738 EA010040  AND      r0,r1,r0,LSL #1
0x0000073C 4909      LDR      r1,[pc,#36]  ; @0x00000764
0x0000073E 8008      STRH     r0,[r1,#0x00]
   181: }

.. with the LSL instruction clearly visible.

Is this a known bug in the Keil compiler ?

Thanks,

Pete Baston.

  • Not sure what versions of the simulator and compiler you are using. It works with uVision V3.35, SarmCM3.DLL V3.01 and RVCT3.0 [Build 947]:

       136:   int16 >>= 1;
    0x000001FC 483D      LDR      r0,[pc,#244]  ; @0x000002F4
    0x000001FE 8801      LDRH     r1,[r0,#0x00]
    0x00000200 0849      LSRS     r1,r1,#1
    0x00000202 8001      STRH     r1,[r0,#0x00]
       137: }
       138:
    0x00000204 4770      BX       lr
    

    There have been some fixes to the Cortex-M3 simulation engine.

  • Hi,

    Thanks for your reply. I have uVision 3.33 which includes ARMCC 3.0.0.942 and SARMCM3.DLL 3.01. I'm not sure what RVCT is - can't see it listed.

    I would have thought the problem would be with the compiler - how does the simulation engine come into it ?

    I think there might be an updated development kit CD available - I'll try that and see if it fixes the problem.

    Best Regards,

    Pete.

  • Pete,

    RVCT means 'RealView Compilation Tools' and consists of ArmCC, ArmAsm, ArmLink and the includes and libraries.

    You can find out your versions and build info by using the uVision menu command 'Help - About uVision...'.

    Regards,
    Peter

  • Hi Peter

    Here's the version info from my uVision.

    Best Regards,

    Pete.

    IDE-Version:
    µVision3 V3.33b
    Copyright (c) Keil Elektronik GmbH / Keil Software, Inc. 1995 - 2006
    
    License Information:
    Peter Baston
    PB Engineering
    LIC=----
    
    Tool Version Numbers:
    Toolchain Path:    C:\Program Files\Keil\ARM\BIN30\ 
    C Compiler:         ARMCC.Exe       V3.0.0.942
    Assembler:          ARMASM.Exe       V3.0.0.942
    Linker/Locator:     ARMLINK.Exe       V3.0.0.942
    Librarian:          ARMAR.Exe       V3.0.0.942
    Hex Converter:      FROMELF.Exe       V3.0.0.942
    CPU DLL:            SARMCM3.DLL       V3.01
    Dialog DLL:         DLM.DLL       V1.00a
    Target DLL:         BIN\lmidk-agdi.dll       V???
    Dialog DLL:         TLM.DLL       V1.00
    

  • Pete,

    I am running the following version, which is RVCT3.0 with service pack 1:

    IDE-Version:
    µVision3 V3.50
    Copyright (c) Keil Elektronik GmbH / Keil Software, Inc. 1995 - 2007
    
    Tool Version Numbers:
    Toolchain Path:    BIN30\ 
    C Compiler:         ARM/Thumb C/C++ Compiler, RVCT3.0 [Build 951] for uVision [Full]
    Assembler:          ARM/Thumb Macro Assembler, RVCT3.0 [Build 951] for uVision [Full]
    Linker/Locator:     ARM Linker, RVCT3.0 [Build 951] for uVision [Full]
    Librarian:          ARM Archiver, RVCT3.0 [Build 951] for uVision
    Hex Converter:      ARM FromELF, RVCT3.0 [Build 951] for uVision [Full]
    CPU DLL:            SARM.DLL       V3.04
    Dialog DLL:         DARMAT.DLL       V1.04
    Target DLL:         BIN\UL2ARM.DLL       V1.26
    Dialog DLL:         TARMAT.DLL       V1.03
    

    Regards,
    Peter