A newbie guestion which again I presume is my fault but can't figure it
out.

1) When compiling a multi file project do I pass all the sdcc
parameters
to both the separate compilations and the final link or what?

2) It seems that the compiler or linker is allocation some internal
variables that it uses on top of HC08 registers. Like:

This C-fragment:

        while (1) {
        char* p="Hello\n";
        char c;
        while (c=*(p++))
                putf(c);
                }
        return 0;


Gets compiled to this (taken from the .lst file), and it makes sense:


                            132
;------------------------------------------------------------
                            133 ;hello.c:16: int main(int argn,char**
args) {
                            134 ;      
-----------------------------------------
                            135 ;        function main
                            136 ;      
-----------------------------------------
                          148 ;hello.c:27: char* p="Hello\n";
                            149 ;hello.c:29: while (c=*(p++))
   0013 A6s00               150         lda     #>__str_0
   0015 B7*00               151         sta     *_main_sloc0_1_0
   0017 A6r00               152         lda     #__str_0
   0019 B7*01               153         sta     *(_main_sloc0_1_0 + 1)
   001B                     154 00101$:
   001B 55*00               155         ldhx    *_main_sloc0_1_0
   001D F6                  156         lda     ,x
   001E AF 01               157         aix     #1
   0020 B7*02               158         sta     *_main_sloc1_1_0
   0022 35*00               159         sthx    *_main_sloc0_1_0
   0024 B6*02               160         lda     *_main_sloc1_1_0
   0

But the final disassembly from the S-record file shows:

E034:   A6 E0        LDA     #$E0               ; 224 
E036:   B7 00        STA     $00                ; 0 
E038:   A6 98        LDA     #$98               ; 152 
E03A:   B7 01        STA     $01                ; 1 
E03C:   55 00        LDHX    $00                ; 0 
E03E:   F6           LDA     ,X                 ; 
E03F:   AF 01        AIX     #1                 ; $0001 
E041:   B7 02        STA     $02                ; 2 
E043:   35 00        STHX    $00                ; 0 
E045:   B6 02        LDA     $02                ; 2 

So if you look at instructions at E036 and E03A you see that the linker
has allocated
the main_sloc0_1_0 on top of Port A and Port B data registers at 0000
and 0001

I know this is most likely just a compile/link parameter issue but have
searched and
tried everything I've found for two hours now.

I compile this with:

sdcc -mhc08 -c  --code-loc 0xE000 --stack-loc 0x00FF --xstack-loc 0x300
--data-loc 0x0100 --idata-loc 0x080 --xram-loc 0x200 --idata-loc 0x0040
hello.c 
dcc -mhc08 -c printf.c
sdcc -mhc08 --code-loc 0xE000 --stack-loc 0x00FF --xstack-loc 0x300
--data-loc 0x0100 --idata-loc 0x080 --xram-loc 0x200 -o hello.S19 
hello.rel printf.rel

Nothing from printf.c is used/referenced but I'm given the lines
verbatim in case it matters.

br Kusti






>>> "Maarten Brock" <[EMAIL PROTECTED]> 26.1.2008 11:52 >>>
Hi,

SDCC cannot pass all parameters in registers and it does 
not automatically pass them on the stack. Instead 
parameters are allocated in memory.

For function pointers this can not work so the pointed 
functions must be declared reentrant, either with the 
keyword 'reentrant' or by compiling the whole project 
with --stack-auto.

HTH,
Maarten

> Hi,
> 
> I'm compiling a small test program that consist of two source 
files.
> I've uploaded the files as a zip archive to
> 
> http://www.sparetimelabs.com/sdccbug.zip 
> 
> and attached them as well.
> 
> My problem is that I get this error message:
> 
> ?ASlink-Warning-Undefined Global '_putf_PARM_2' referenced by module
> 'printf'
> 
> where '_putf_PARM_2' is a compiler generated variable.
> 
> I'm compiling them with a script (included in the archive as file
> 'makeit' ) as follows :
> 
> ------------------------------------------------------------
> echo Compile hello.c
> sdcc -mhc08 -c hello.c
> 
> echo Compile printf.c
> sdcc -mhc08 -c printf.c
> 
> echo Link hello.c
> sdcc -mhc08 --code-loc 0xE000 --stack-loc 0x00FF --xstack-loc 0x300
> --data-loc 
> 0x0100 --idata-loc 0x080 --xram-loc 0x200 -o hello.S19  hello.rel
> printf.rel
> ------------------------------------------------------------
> 
> This produces a link warning for a compiler generated variable the
> compiler
> uses to pass a parameter. And disassembling the generated code I see
> that indeed the variable is not referenced properly.
> 
> The output from the script above is:
> 
> ------------------------------------------------------------
> Compile hello.c
> Compile printf.c
> Link hello.c
> 
> ?ASlink-Warning-Undefined Global '_putf_PARM_2' referenced by module
> 'printf'
> ------------------------------------------------------------
> 
> 
> My SDCC version is:
> 
> ------------------------------------------------------------
> sdcc -v
> SDCC :
mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08
> 2.7.4 
> #4988 (Jan  9 2008) (Mac OS X i386)
> ------------------------------------------------------------
> 
> 
> Looking at the usage of the putf function  in 'printf.c'
> I see that it is not the most common garden variety function call:
> 
> ------------------------------------------------------------
> typedef void (*putcf) (void*,char);
> ...
> void tfp_format(void* putp,putcf putf,char *fmt, va_list va)
> ...
> putf(putp,ch);
> ------------------------------------------------------------
> 
> So it is a call to a function through a function pointer...
> could this be a compiler bug or am I doing something wrong?
> 
> Needles to say Ive compiled/linked and run this code
> previously without any problems with gcc.
> 
> br Kusti
> 
> 
> 
> 
> 
> 
> 
> 
> s
> 



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ 
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net 
https://lists.sourceforge.net/lists/listinfo/sdcc-user

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to