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

#1063 bad pic14 code for address of parameter

open
nobody
PIC14
5
2013-07-16
2006-02-13
Borut Ražem
No

1 - code sample:
-------------------------------
void
f2(int *p1)
{
int t = *p1;
}

void
f1(int p1)
{
f2(&p1); // <== bad asm code for address of parameter
}

void
main (void)
{
f1 (0x1234);
}
-------------------------------
Already included in src\regression\ptrarg.c pic14
regression test

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

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

4 - no error message, bad code generated for f1():
_f1 ;Function start
MOVF STK00,W
BANKSEL r0x25
MOVWF r0x25
MOVWF STK01
MOVF r0x25,W
MOVWF STK00
MOVLW 0x00
CALL _f2
RETURN
; exit point of _f1

The bigest problem is that the lo byte of the parameter
is passed in STK00 and high byte in W register, so how
can we get the address of parameter?! :-(

Borut

Discussion

  • Borut Ražem
    Borut Ražem
    2006-02-14

    • labels: --> pic14 target
     
    • Category: --> PIC14