#1358 variables located in same place as actively-used registers

closed-fixed
5
2013-05-25
2007-07-24
TParker
No

Version 2.7
Build output (using Silicon Labs IDE):

Invoking project defined compiler.
c:\SDCC\BIN\SDCC.EXE -c --debug --use-stdout -V -IM:\PRIVATE\an219\sdcc_bug M:\PRIVATE\an219\sdcc_bug\F360_Blinky.c
.................
+ c:\SDCC\BIN\sdcpp.exe -nostdinc -Wall -std=c99 -I"M:\PRIVATE\an219\sdcc_bug" -obj-ext=.rel -DSDCC_MODEL_SMALL -DSDCC=270 -DSDCC_mcs51 -D__mcs51 -I"c:\SDCC\BIN\..\include\mcs51" -I"c:\SDCC\BIN\..\include" "M:\PRIVATE\an219\sdcc_bug\F360_Blinky.c"
+ c:\SDCC\BIN\asx8051.exe -plosgffc "F360_Blinky.asm"

Link in progress...
c:\SDCC\BIN\SDCC.EXE --debug --use-stdout -V -IM:\PRIVATE\an219\sdcc_bug -oM:\PRIVATE\an219\sdcc_bug\F360_Blinky.hex M:\PRIVATE\an219\sdcc_bug\F360_Blinky.rel
..........
+ c:\SDCC\BIN\aslink.exe -nf "M:\PRIVATE\an219\sdcc_bug\F360_Blinky.lnk"

Problem:

The "using" directive switches to the correct register bank in the ISR. However, the SDCC Linker is still allocating variables to those DRAM areas so that any instructions using those registers overwrite the variables in DRAM.

Using the attached program for a C8051F36x Target Board, the map file for the DRAM segment looks like this:

Hexadecimal

Area Addr Size Decimal Bytes (Attributes)
-------------------------------- ---- ---- ------- ----- ------------
DSEG 0000 0080 = 128. bytes (REL,CON)

Value Global
-------- --------------------------------
0008 G$phase_add1$0$0
0008 _phase_add1
000A G$phase_add2$0$0
000A _phase_add2
000C LTimer2_ISR$phase_acc1$1$1
000E LTimer2_ISR$phase_acc2$1$1

The variables <phase_add1> and <phase_add2> are global constants that are added to <phase_acc1> and <phase_acc2> in the Timer2 ISR. However, <phase_add1> and <phase_add2> are located by the linker in Register Bank 1, the same Register Bank specified to be used by the ISR by the "using" directive. Because of this, the <add> variables are overwritten by the process of adding them to the accumulator variables.

Please contact me if you have any questions at tabitha.parker@silabs.com. The attached file requires "compiler_defs.h" and "C8051F360_defs.h" to compile, but it seems like I can only upload the one file.

Discussion

  • TParker

    TParker - 2007-07-24

    test file

     
  • TParker

    TParker - 2007-07-24

    Logged In: YES
    user_id=1852451
    Originator: YES

    File Added: compiler_defs.h

     
  • TParker

    TParker - 2007-07-24

    compiler definitions (for multiple compilers, including SDCC)

     
  • TParker

    TParker - 2007-07-24

    'F36x SFR, interrupt, and SFR paging definitions

     
  • TParker

    TParker - 2007-07-24

    Logged In: YES
    user_id=1852451
    Originator: YES

    File Added: C8051F360_defs.h

     
  • TParker

    TParker - 2007-07-24

    shows the problem in the Silicon Labs IDE

     
  • TParker

    TParker - 2007-07-24

    Logged In: YES
    user_id=1852451
    Originator: YES

    File Added: sdcc_bug.JPG

     
  • TParker

    TParker - 2007-07-24

    Logged In: YES
    user_id=1852451
    Originator: YES

    The header files are now attached, along with a picture displaying the problem in the Silicon Labs IDE.

     
  • Maarten Brock

    Maarten Brock - 2007-07-24

    Logged In: YES
    user_id=888171
    Originator: NO

    Hi Tabitha,

    Thanks for reporting this. I was able to reproduce the problem and also found some workarounds:
    * Put the using directive also in the prototype of the ISR.
    * Or remove the prototype when the ISR is in the same file as the function main().

    About uploading files, yes that's a bit annoying, but out of our control. The solution is to put everything in a zip first or to upload them later one by one as you did. It is allowed but not necessary to include a comment as it is automatically registered. Luckily you logged in so you were able to add files, because it's not possible when 'anonymous'.

    HTH,
    Maarten

     
  • TParker

    TParker - 2007-07-24

    Logged In: YES
    user_id=1852451
    Originator: YES

    Hi Maarten,

    Thanks for taking a look at it so quickly, and I'll implement one of those workarounds. My workaround was just remove the "using" keyword from the ISR, but I would much rather keep the context switching.

    Thanks again!
    ~Tabitha

     
  • Maarten Brock

    Maarten Brock - 2007-09-04
    • labels: --> C-Front End
    • assigned_to: nobody --> maartenbrock
     
  • Maarten Brock

    Maarten Brock - 2007-09-04

    Logged In: YES
    user_id=888171
    Originator: NO

    Fixed in SDCC 2.7.3 #4909.

     
  • Maarten Brock

    Maarten Brock - 2007-09-04
    • milestone: --> fixed
    • status: open --> closed-fixed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks