Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#874 pic16_allocRegByName results in bad code

open
PIC16
5
2013-05-25
2005-02-03
No

Problem:

When I use "complicated" while() conditions, the resut
is a warning from the compiler and despite the warning
looking harmless enough (just needing to allocate a new
register) the resulting object file is invalid and my
pic goes off into space.

Please see the attached file. If you #undef
WORKAROUND, the problem happens, if you #define
WORKAROUND everything is fine. I have tested both on
my pic board to verify this. Additionally I have
tested this file (both configurations) using gcc and
both methods work with equal results.

Command: sdcc -mpic16 -p18f452 -c example.c

$ /usr/bin/sdcc -v
SDCC :
mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08
2.4.8 #941 (Jan 25 2005) (UNIX)
This build is a snapshot build from cvs gotten at the
end of day on Jan 25, 2005. I just got the latest (end
of day Feb 2nd and the problem still exists)

Warning: pic16_allocRegByName:942 symbol name
_snprintf_sloc0_1_0 regop= 0x8360188gen.c:1821:
WARNING: need to allocate new register by name ->
_snprintf_sloc0_1_0

Contact Information: schmidtw at users dot sourceforge
dot net

Discussion

  • example.c

     
    Attachments
  • Vangelis Rokas
    Vangelis Rokas
    2005-03-14

    Logged In: YES
    user_id=770505

    The problem is not with the *_sloc* variables.
    I've suppressed their generation and bug still
    appears.

    Vangelis

     
  • Vangelis Rokas
    Vangelis Rokas
    2005-03-17

    • assigned_to: nobody --> vrokas
     
  • Vangelis Rokas
    Vangelis Rokas
    2005-03-18

    Logged In: YES
    user_id=770505

    When compiling the source with loop induction
    disabled the produced file is run without problems.

    I don't know if this is a problem in the loopInduction functions.

    Can somebody test the same source with mcs51 port
    (enabled and disabled the loop induction) and run some
    simulations with it?

    regards,
    Vangelis

     
  • Maarten Brock
    Maarten Brock
    2005-03-20

    • labels: 608414 -->
     
  • Maarten Brock
    Maarten Brock
    2005-03-20

    Logged In: YES
    user_id=888171

    Indeed this is not restricted to pic16. mcs51 generates bad
    code too. And with --noinduction the problems disappear.
    With induction turned on line 187: digits-- decreases length
    instead of digits.

     
  • Maarten Brock
    Maarten Brock
    2010-07-24

    I retested this for mcs51 and ds390 and it seems this was solved somewhere along the way.
    It still seems broken for ucz80 and hc08 and I haven't tested pic14 or pic16.

     
  • Maarten Brock
    Maarten Brock
    2010-07-28

    • labels: --> pic16 target
     
  • Maarten Brock
    Maarten Brock
    2010-07-28

    Fixed for hc08 in SDCC 2.9.7 #5894. Z80 was ok after all.
    Still haven't tested for pic14 or pic16.

     
    • Category: --> PIC16
    • Group: --> fixed