Menu

#1186 Error with unreferenced function argument

closed-fixed
5
2013-05-25
2006-08-21
paolo112
No

SDCC :
mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08
2.6.0 #4 309 (Jul 28 2006) (MINGW32)

char test_fnc(const char *str0,const char *str1,const
char *str2 , const char *str3){

return strX[0]; // X=0,1,2,3
}

Function test_fnc return always the first argument
regardless of value of strX, for X=0..3. The ASM code
is the same for X = 0,1,2,3 and the function suppose
that the only used argument was passed in STK00 and
STK01 registers, but this is wrong according the
function prototype.

sdcc.exe -mpic14 -p16f877 -c test_fnc.c

The generate code is always:
0000 00158 _test_fnc ;Function start
00159 ; 2 exit points
gpasm-0.13.3 beta test_fnc.asm8-21-2006
19:56:47 PAGE 4

LOC OBJECT CODE LINE SOURCE TEXT
VALUE

00160 ; .line 4; "test_fnc.c"
char test_fnc(const char *str0,const char *str1,const
char *str2 , const char *str3){
0000 0000 0000 00161 BANKSEL r0x20
0002 0080 00162 MOVWF r0x20
0003 0800 00163 MOVF STK00,W
0004 0080 00164 MOVWF r0x21
0005 0800 00165 MOVF STK01,W
00166 ;; peep 2 - Removed redundant move
00167 ;;1 MOVWF r0x22
00168 ; .line 6; "test_fnc.c"
return str2[0];
0006 0080 00169 MOVWF STK01
0007 0800 00170 MOVF r0x21,W
0008 0080 00171 MOVWF STK00
0009 0800 00172 MOVF r0x20,W
000A 0000 0000 00173 PAGESEL __gptrget1
000C 2000 00174 CALL __gptrget1
000D 0000 0000 00175 PAGESEL $
00176 ;; peep 2 - Removed redundant move
00177 ;;1 MOVWF r0x23
000F 0008 00178 RETURN

Discussion

  • Raphael Neider

    Raphael Neider - 2006-08-22

    Logged In: YES
    user_id=1115835

    The same bug has been fixed 2 years ago in the PIC16 port; I
    will apply a similar fix in the next 2 weeks or so for PIC14
    (currently my PC is not available ot me). The fix should
    also allow to apply the address of operator to the first
    argument; currently &str0 fails utterly...

    Regards,
    Raphael

     
  • Raphael Neider

    Raphael Neider - 2006-08-22
    • assigned_to: nobody --> tecodev
     
  • Raphael Neider

    Raphael Neider - 2006-09-04
    • labels: --> pic14 target
    • milestone: --> fixed
    • status: open --> closed-fixed
     
  • Raphael Neider

    Raphael Neider - 2006-09-04

    Logged In: YES
    user_id=1115835

    Fixed in SDCC r4358.
    Address-of-operator remains broken for now...

     

Log in to post a comment.