#1061 pic14 bad code with varargs

open
nobody
PIC14
5
2013-07-16
2006-02-08
No

1 - sample code:
---------------------
void f2(int *p)
{
p;
}

void f1(int p, ...)
{
f2(&p); //wrong code for address of parameter
}

void
main(void)
{
f1(1); //wrong code: parameter not passed
}
---------------------

2 - command:
$ sdcc -mpic14 -pp16f877 t.c

3 - sdcc version:
$ sdcc -v
SDCC :
mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08
2.5.4 #1199 (Feb 7 2006) (MINGW32)

4 - The code compiles without errors, but the generated
code is wrong:
- in main() the parameter is not passed to f1():

_main ;Function start
; 2 exit points
; .line 14; "t2.c" f1(1);
CALL _f1
RETURN
; exit point of _main

- in f1() the code for address of parameter is wrong:

_f1 ;Function start
; 2 exit points
; .line 8; "t2.c" f2(&p); //wrong code for address of
parameter
MOVLW ( + 0) <=== shold be (STK00 + 0)
BANKSEL r0x2A
MOVWF r0x2A
;;1 MOVWF r0x27
MOVLW high ( + 0) <=== shold be (STK00 + 0)
;; peep 2 - Removed redundant move
;;1 MOVWF r0x28
MOVWF r0x29
;;99 MOVF r0x27,W
;;100 CLRF r0x2B
MOVF r0x2A,W
MOVWF STK01
MOVF r0x29,W
MOVWF STK00
;;101 MOVF r0x2B,W
MOVLW 0x00
CALL _f2
RETURN
; exit point of _f1

Borut

Discussion

  • Bernhard Held

    Bernhard Held - 2006-02-08
    • labels: --> pic14 target
     
  • Maarten Brock

    Maarten Brock - 2010-12-28
    • summary: bad code with varargs --> pic14 bad code with varargs
     
  • Philipp Klaus Krause

    • Category: --> PIC14
     

Log in to post a comment.

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

Sign up for the SourceForge newsletter:





No, thanks