Major WDC linker issues

Once again an other issue. This time it’s about the WDC linker that seems not to be able link against C library. I already have sent a few email and ticket support to the wdc team. Still no response since my first enquiry 2 months ago. It’s been a while now that the direct to the freesdk have been removed.

So here is the source code that is having the problem and need to be linked with c.lib or cs.lib (small model) :

main.c

typedef    unsigned char    byte;
typedef    unsigned short    word;

typedef struct padStatus{
    byte right:1;
    byte left:1;
    byte down:1;
    byte up:1;
    byte start:1;    // Enter
    byte select:1;    // Space
    byte Y:1;    // X
    byte B:1;    // C
    //--------------------------------
    byte Dummy:4;
    byte R:1;    // Z
    byte L:1;    // A
    byte X:1;     // S
    byte A:1;    // D
} padStatus;

padStatus readPad(byte padNumber) {
    word test;
    // TODO fix usage of padStatus structure
    padStatus *status;

    // TODO move ot dedicated function
    // enable pad ready
    *(byte*)0x4200 = 0x01;

    // check if pad is READY !!!
    padNumber = padNumber << 1;
    test = (word) *(byte*)0x4218+padNumber << 8;
    test |= (word) *(byte*)0x4219+padNumber;

    status = (padStatus *) &test;

    return *status;
}

void main(void) {
    padStatus pad1;

    // Infinite loop
    while(1) {
        pad1 = readPad((byte) 0);

        if(pad1.up == 1) {
            *(byte*) 0x2100 = 0x00; // disable background
        } else {
                   *(byte*) 0x2100 = 0x0f; // enable background
        }
    }
}

This can be compiled with this command line :

wdc816cc -wl -wp -MS -MO -SOP main.c

The -MS is for specifying the Small code layout. So it should be linked with the “cs.lib”. But the here is the output of the linker:

wdcln -V -W -LC:\65xx_FreeSDK\lib\cs  main.obj -O test.smc
WDC 65C816 Linker Version EVALCOPY Jan 18 2006 17:36:51
   Copyright (C) 1992-2006 The Western Design Center, Inc.
Undefined symbol: __~mov

The __~mov symbol cannot be resolved but it is in the cs.lib. So I think that the linked dont link correctly. If anyone got any any idea on why. Feel free to leave a comment.

++ Lint

PS : I’m still working on the two effect and debug text output, expact an update in a few days.

FIXED !!! Look at the comments !!!

5 Responses to “Major WDC linker issues”

  1. lint Says:

    The freesdk is available here on WDC site : http://westerndesigncenter.com/wdc/Evaluation_Kit/freesdk.exe

  2. Gato Says:

    I’ve never been able to use any of their “standard C” lib. I’m trying to make my own, but I’m trying to find an easier way than the ugly “lda 3+4+2, s” syntax” (and the documentation isn’t really helping).

  3. James D. Says:

    Some of the older and less intelligent linkers didn’t make multiple passes through libraries, they just linked in a single pass. The solution was to link against the problem library multiple times.

  4. lint Says:

    Thanks guys … i got the problem fixed … it was really stupid. Here is my new linker :

    wdcln -HB -MN -V -T -P00 -C0000,8000 -vm -N main.obj -LC:\65xx_FreeSDK\lib\cs -O kungfu.smc

    The problem was due to the fact that the lib include by the -L option need to be specified after all the objec that you are going to likn together. Thanks James d. you make me trying that.

  5. Gato Says:

    Have you been able to add a library function in your code?
    I tried a simple “memcpy”. I include and write memcpy(a,b,1);
    It compiles without problem, but the function code is missing. It only jumps to an empty function.