#874 pic16_allocRegByName results in bad code



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
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 ->

Contact Information: schmidtw at users dot sourceforge
dot net


  • Weston T. Schmidt


  • Vangelis Rokas

    Vangelis Rokas - 2005-03-14

    Logged In: YES

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


  • Vangelis Rokas

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

    Vangelis Rokas - 2005-03-18

    Logged In: YES

    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?


  • Maarten Brock

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

    Maarten Brock - 2005-03-20

    Logged In: YES

    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.

  • Philipp Klaus Krause

    • Category: --> PIC16
    • Group: --> 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