#1403 Parameter passing problem


Parameter CardValue in function M3() is not passed to function DisplayValue(). Parameter CardValue is intended to be passed via dph and dpl. dph gets loaded from r6 and dpl gets loaded from r5, but r5 and r6 are never accessed or assigned in M3() or anywhere else throughout the program:

mov _DisplayValue_PARM_2,r2
mov dpl,r5 ;r5 not assigned anywhere!!!
mov dph,r6 ;r6 not assigned anywhere!!!
lcall _DisplayValue

It is really a strange bug because it happens in the given constellation only. It disappears if:
- parameter 'n' is removed from M3()
- function call z() is removed from M3()
- first actual parameter of z() is changed to 0 z(0, 0) in M3()
- parameter 'Value' of DisplayValue() is changed from 'unsigned int' to 'int'

I could not simplify the program further without loosing the bug.
For more information see attached file.

Command to compile:
C:\>sdcc BugReport12.c

C:\GCR250\V455>sdcc -v
SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08
2.7.4 #4972 (Nov 23 2007) (MINGW32)

Microsoft Windows XP [Version 5.1.2600]


  • Laszlo BORTEL

    Laszlo BORTEL - 2007-11-27
  • Robert Larice

    Robert Larice - 2008-02-21

    Logged In: YES
    Originator: NO

    for debuging purpose, the offending code can be much reduced to:

    int glbl;

    extern void baz(unsigned int, char);

    long *foo(char n, long *p) reentrant {

    baz(glbl, *p);

    return p;

    sdcc -c generates a comparably short piece of asm,
    which passes the first parameter of baz from registers r5 and r6.
    but those are not initialized.

    Robert Larice

  • Maarten Brock

    Maarten Brock - 2008-02-28

    Logged In: YES
    Originator: NO

    Fixed in SDCC 2.7.5 #5057.

  • Maarten Brock

    Maarten Brock - 2008-02-28
    • labels: --> Live range problems
    • milestone: --> fixed
    • assigned_to: nobody --> maartenbrock
    • status: open --> closed-fixed

Log in to post a comment.