Re: [cc65] Unresolved external in V2.12.0

From: Marc 'BlackJack Rintsch <marc1rintsch.de>
Date: 2009-01-07 10:26:42
On Wednesday 07 January 2009, Halldor Karl Hognason wrote:

> The program is the following (just a simple test):
>
> #include <stdlib.h>
> #define poke(addr,val)     (*(unsigned char*) (addr) = (val))
> int main (void)
> {
>     int i = 0;
>
>     for(i=0; i<4; i++)
>     {
>         poke(0x8000, 8);
>     }
>     return EXIT_SUCCESS;
> }
>
> We call this test.c and now run the following,
>
> cc65 -Oi -t c64 test.c  (success)
> ca65 -t c64 test.s  (success)
> ld65 -t c64 test.o (un-successful, see below)
>
>
> This results in the following error reported by the linker,
>
> ld65.exe: Warning: [builtin config](6): Segment `STARTUP' does not
> exist Unresolved external `incsp2' referenced in:
>   test.s(44)
> Unresolved external `ldaxysp' referenced in:
>   test.s(36)
> Unresolved external `pushax' referenced in:
>   test.s(26)
> Unresolved external `staxysp' referenced in:
>   test.s(28)
> Unresolved external `toslta0' referenced in:
>   test.s(31)
> ld65.exe: Error: 5 unresolved external(s) found - cannot create
> output file
>
> […]
>
> Now, back to the one with a for-loop.
> When I look into the ASM source, test.s, I see that there in between
> are the ' jsr     pushax','jsr     staxysp','jsr     pushax',' jsr
> toslta0','jsr     ldaxysp',  what are they for ?
> Are they macros for swapping between or pushing on stack  A,X,Y ?

Subroutines for dealing with the software stack that is used for 
arguments and local variables, `i` in this case.

> .segment        "CODE"
> .proc   _main: near
> .segment        "CODE"
>         ldx     #$00
>         txa
>         jsr     pushax

Here is `i` initialized to 0 for example.

> I would really appreciate if somebody could have a look at this, I
> suspect this has something todo with the macros, most probably
> nothing todo with the ca65, more probably me beeing a newbie here
> using the cc65 and not seeing something.

If you insist on calling the tools yourself you have to give the startup 
object file and the standard library for the target to ``ld65``::

  ld65 -t c64 c64.o test.o c64.lib

But all this is simplified by ``cl65``::

  cl65 -o test.prg test.c

That's all you need to compile, assemble, and link the program for the 
C64 as target machine.

Ciao,
	Marc 'BlackJack' Rintsch
-- 
“Programmers should be paid by the amount of code
 that they avoid writing.”  -- Michael P. Soulier

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Wed Jan 7 10:26:25 2009

This archive was generated by hypermail 2.1.8 : 2009-01-07 10:26:26 CET