Compiling a simple program for CP/M

Post Reply
reifsnyderb
New member
Posts: 9
Joined: Tue May 07, 2024 2:59 pm

Compiling a simple program for CP/M

Post by reifsnyderb »

Hello,

I am working on a CP/M card for the Atari 1090XL. Thus far, I've got CP/M running and need to develop a few utilities so as to use the system within this particular environment. Last evening, I installed the latest version of z88dk and tried to get an example program to compile. This program was compiled by another and I believe used a different compiler.

Here's the program I am trying to compile....

Code: Select all

#include <stdio.h>
#include <string.h>
#include <cpm.h>

unsigned char buffer[128];

int main(int argc, char **argv) {
    int i;

    cpm_fcb.ex = cpm_fcb.s1 = cpm_fcb.s2 = cpm_fcb.rc = 0;
    memcpy(&cpm_fcb.f, "FOO     BAR", 11);

    printf("Opening file\n");
    if (cpm_make_file(&cpm_fcb) == 0xff) {
        printf("Error opening file, file exists?\n");
        return 1;
    }

    printf("Setting DMA\n");
    cpm_set_dma(buffer);

    printf("Filling buffer\n");
    for (i=0; i<128; i++)
        buffer[i] = i;

    printf("Writing buffer\n");
    if (cpm_write_sequential(&cpm_fcb)) {
        printf("Error writing to disk\n");
        return 1;
    }

    printf("Closing file\n");
    if (cpm_close_file(&cpm_fcb) == 0xff) {
        printf("Error closing file\n");
        return 1;
    }

    printf("Done.\n");
    return 0;
}

When attempting to compile, I receive the following error:

write.c:10:12: fatal error: Unknown symbol: cpm_fcb

Any thoughts or corrections as how to get this to work with z88dk?

Thanks!

Brian
User avatar
dom
Well known member
Posts: 2317
Joined: Sun Jul 15, 2007 10:01 pm

Re: Compiling a simple program for CP/M

Post by dom »

It looks like you've got some code that either uses some routines from either cpmish or from the mos-sdk - it looks these function calls (cpm_make_file etc) are just fairly thin wrappers around bdos calls.

Although you can do a similar thing with z88dk, it's much easier to just use routines from stdio.h (so fopen/fclose) or from fcntl.h (open/close)
reifsnyderb
New member
Posts: 9
Joined: Tue May 07, 2024 2:59 pm

Re: Compiling a simple program for CP/M

Post by reifsnyderb »

dom wrote: Tue May 07, 2024 3:45 pm It looks like you've got some code that either uses some routines from either cpmish or from the mos-sdk - it looks these function calls (cpm_make_file etc) are just fairly thin wrappers around bdos calls.

Although you can do a similar thing with z88dk, it's much easier to just use routines from stdio.h (so fopen/fclose) or from fcntl.h (open/close)
Thanks! I think cpmish was used. I'll go the standard route and convert everything to fopen/fclose.
Post Reply