Re: C source to access DOS disks under CP/M



In article <1122244918.391525.91120@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
s_dubrovich@xxxxxxxxx says...
>
>
>
>Anonymous Guy wrote:
>> Lines: 51
>> Path:
g2news1.google.com!news3.google.com!news.glorb.com!news-feed01.roc.ny.
>frontiernet.net!nntp.frontiernet.net!news-out.usenet.com!spool6-east.superfee
d
>.net!spool6-east.superfeed.net!not-for-mail
>> Newsgroups: comp.os.cpm
>> Xref: g2news1.google.com comp.os.cpm:2297
>>
>>
>> On 2005-07-23 Tom Anderson said:
>>
>> > I found this in a zip file named cc04.zip. I don't recall where
>> > I got it. I attempted to compile it under Aztec C 3.2 for CPM/86,
>> > and got an undefined symbol error. The Aztec linker failed to
>> > generate a CMD file. I then tried DR-C. The source compiled into
>> > an OBJ file. Link86 generated a CMD file but also undefined symbol
>> > messages. The CMD file will execute under CP/M-86, but fails to
>> > access the disk drives.
>> >
>> > I am no programmer, but maybe someone who is would like to look
>> > at this C source, and see if they can get it to run properly.
>> >
>> > Here it is: RDMSDOS.C
>> >
>> > /*
>> > This program reads/writes MS-DOS formatted disks, using the CPM
>> > bios routines. The data is converted to/from C (non-ascii) files.
>> > The code is written so that it can be compiled with Small-C, but
>> > uses K&R standard I/O whenever possible. ^^^^^^^
>> ^^^^^^^^^^^^
>> There's your first clue, son. Looks like you might have
>> used the wrong C compilers.
>>
>> > Author: Bob Alverson
>> > Cincinnati, OH 45231
>> > 1.1 9 DEC 83 Add ability to read all four IBM formats
>>
>> In this case, "all four IBM formats" means:
>>
>> 5.25-inch SS/DD, 8 sectors/track
>> 5.25-inch SS/DD, 9 sectors/track
>> 5.25-inch DS/DD, 8 sectors/track
>> 5.25-inch DS/DD, 9 sectors/track
>>
>> Still, the program could definitely be useful under CP/M-86,
>> if it could be made to compile properly.
>>
>> Steve Dubrovich? Richard Brady? John Elliot? Anyone...???
>>
>Um, well, back to the build path problem. It would help to have the
>stdio.h that was paired to this file. I suspect this is a smallc for
>cpm-80 program. DRI-C.exe link86 can't resolve toupper(), bdos(),
>bios(). SmallC for cpm86 hasn't <stdio.h>. MIX-C is backward
>compatible with K&R, and it does build without error with it, but of
>course the program errors out on: readsec(trk, sec, buf), because the
>bdos & bios fn's don't know cpm86 interrupt entry, just msDos.
>
>I'm working on nasm .bin -> .cmd and I don't care to be distracted with
>this at the moment. As far as nasm .bin -> .cmd, I have the header
>record build utility done and proved the concept, I've a couple of
>things to explore before I release what I've got. Interrested?
>

Thanks for the informative responses. I am using DRC.CMD under CPM/86 for
IBMPC v1.1, which I am running from an 8 Mb partition on an Everex 386/33.

I added #include "bios.h, #include "dos.h", and #include "ctype.h"
to rdmsdos.c.
Dos.h eliminated the undefined symbol message for bdos.
Bios.h eliminated the us message for bios.
Ctype.h eliminated the us message for toupper.

The result was 1. a compiler error message "stdio.h:67:illegal operator in
constant expression". This was using DRC's stdio.h. The compiler generated an
OBJ file which the linker accepted. The resulting CMD file executes to the
point of asking which drive to use. A ^break is required to get back to the
command line.

Result 2. Using Aztec C's stdio.h, the DRC compiler generated an OBJ file with
no error messages, and the linker generated a CMD file with no error messages.
Executing this file results in an immediate return to the C prompt.

Included below is the DRC stdio.h


/*----------------------------------------------------------------------------
DRC 1.11 Standard I/O header, modified to optimize *.cmd file size

Conditionally removes less commonly used library routines.
reduce the resulting *.cmd file size approximately 10k
-----------------------------------------------------------------------------*
/

#include "portab.h"

#define FLOATS FALSE 4/29/99 - Ken Mauro
#define LONGS FALSE constants defined in portab.h
#define STRINGS FALSE
#define UNIX FALSE

#define BUFSIZ 512
#define MAXFILES 16
struct _iobuf {
WORD _fd;
WORD _flag;
BYTE *_base;
BYTE *_ptr;
WORD _cnt;
};

#ifndef FILE
extern struct _iobuf _iob[MAXFILES];
#define FILE struct _iobuf
#endif


#define NULLFILE ((FILE *)0)

#define _IOREAD 0x01
#define _IOWRT 0x02
#define _IOABUF 0x04
#define _IONBUF 0x08
#define _IOERR 0x10
#define _IOEOF 0x20
#define _IOLBUF 0x40
#define _IOSTRI 0x80
#define _IOASCI 0x100

#define stdin (&_iob[0])
#define stdout (&_iob[1])
#define stderr (&_iob[2])

#define clearerr(p) ((p)->_flag &= ~_IOERR)
#define feof(p) ((p)->_flag & _IOEOF)
#define ferror(p) ((p)->_flag & _IOERR)
#define fileno(p) ((p)->_fd)
#define getchar() getc(stdin)
#define putchar(c) putc(c,stdout)
#define putc fputc
#define getc fgetc


#define abs(x) ((x) < 0 ? -(x) : (x))

#define MAX(x,y) (((x) > (y)) ? (x) : (y))
#define MIN(x,y) (((x) < (y)) ? (x) : (y))


/* Defined supplied functions */

extern long atol();

#if FLOATS
extern double atof();
#endif

#ifdef UNIX
extern char *sbrk();
#endif

extern char *calloc() , *malloc() , *realloc() , *zalloc();
extern FILE *fopen(), *fopena(), *fopenb();

/*extern FILE *freopen(), *freopa(), *freopb();*/
/*extern FILE *fdopen();*/
/*extern void perror();*/

extern char *gets(), *fgets();

#ifdef LONGS
extern long lseek();
extern long ftell();
extern long tell();
extern long getl();
extern long putl();
#endif

#ifdef STRINGS
extern char *index(), *rindex(), *strchr(), *strrchr();
#endif

extern char *strcat();
extern char *strncat();
extern char *strcpy();
extern char *strncpy();

#ifdef FLOATS
extern double sqrt();
extern double cos(), sin();
extern double exp(), fabs();
extern double tan(), atan();
extern double log(), log10();
#endif

#ifdef UNIX
extern char *mktemp();
extern char *getpass();
extern char *ttyname();
extern void longjmp();
#endif



Included below is DRC's portab.h


/****************************************************************************
*
* Copyright 1982 by Digital Research Inc. All rights reserved.
*
* This is an include file for assisting the user to write portable
* programs for C. All processor dependencies should be located here.
*
****************************************************************************/
/*
* Standard type definitions
*/
#define BYTE char /* Signed byte */
#define UBYTE char /* Unsigned byte */
#define BOOLEAN int /* 2 valued (true/false) */
#define WORD int /* Signed word (16 bits) */
#define UWORD unsigned int /* unsigned word */

#define LONG long /* signed long (32 bits) */
#define ULONG long /* Unsigned long */

#define REG register /* register variable */
#define LOCAL auto /* Local var on 68000 */
#define EXTERN extern /* External variable */
#define MLOCAL static /* Local to module */
#define GLOBAL /**/ /* Global variable */
#define VOID int /* Void function return */
#define DEFAULT int /* Default size */
#define FLOAT float /* Floating Point */
#define DOUBLE double /* Double precision */


/****************************************************************************/
/* Miscellaneous Definitions: */
/****************************************************************************/
#define FAILURE (-1) /* Function failure return val */
#define SUCCESS (0) /* Function success return val */
#define YES 1 /* "TRUE" */
#define NO 0 /* "FALSE" */
#define FOREVER for(;;) /* Infinite loop declaration */
#define NULL 0 /* Null character value */
#define NULLPTR (char *) 0 /* Null pointer value */
#define EOF (-1) /* EOF Value */
#define TRUE (1) /* Function TRUE value */
#define FALSE (0) /* Function FALSE value */



 




Included below is Aztec C's stdio.h


/* Copyright (C) 1982, 1984 by Manx Software Systems */
#include "portab.h"

#define fgetc getc
#define fputc putc
#define NULL (void *)0
#define EOF -1


#define BUFSIZ 1024
#define MAXSTREAM 20

#define _BUSY 0x01
#define _ALLBUF 0x02
#define _DIRTY 0x04
#define _EOF 0x08
#define _IOERR 0x10
#define _TEMP 0x20 /* temporary file (delete on close) */

typedef struct {
char *_bp; /* current position in buffer */
char *_bend; /* last character in buffer + 1 */
char *_buff; /* address of buffer */
char _flags; /* open mode, etc. */
char _unit; /* token returned by open */
char _bytbuf; /* single byte buffer for unbuffer streams */
int _buflen; /* length of buffer */
char *_tmpname; /* name of file for temporaries */
} FILE;

extern FILE Cbuffs[];
FILE *fopen();
long ftell();

#define stdin (&Cbuffs[0])
#define stdout (&Cbuffs[1])
#define stderr (&Cbuffs[2])
#define getchar() agetc(stdin)
#define putchar(c) aputc(c, stdout)
#define feof(fp) (((fp)->_flags&_EOF)!=0)
#define ferror(fp) (((fp)->_flags&_IOERR)!=0)
#define clearerr(fp) ((fp)->_flags &= ~(_IOERR|_EOF))
#define fileno(fp) ((fp)->_unit)
#define fflush(fp) flsh_(fp,-1)

#define P_tmpdir ""
#define L_tmpnam 40




.



Relevant Pages