From: cpg Date: Sun, 11 Jun 2000 23:36:16 +0000 (+0000) Subject: added file I/O test program X-Git-Tag: V2.12.0~3456 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=22a7951bde848aa60abb4dff0f9e99b6609524ea;p=cc65 added file I/O test program git-svn-id: svn://svn.cc65.org/cc65/trunk@56 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/testcode/lib/ft.c b/testcode/lib/ft.c new file mode 100644 index 000000000..e62a32517 --- /dev/null +++ b/testcode/lib/ft.c @@ -0,0 +1,108 @@ +/* + * simple file i/o test + * + * 12-Jun-2000, Christian Groessler + * + * please compile with + * cl65 -tsystem ft.c getsp.s -o ft.com + * + * The program asks for a filename (if it hasn't + * got one from argv). I then opens the file, + * reads the the first 16 bytes and displays them + * (as hex values). + * The values of sp (cc65 runtime stack pointer) + * are displayed at some places. The displayed + * value should always be the same. + */ + +#include +#include +#include +#include +#include + +extern int getsp(void); /* is provided in getsp.s */ + +#ifdef __ATARI__ /* Atari's fd indirection table */ +extern char fd_index[]; +struct fd_t { + char usage; + char iocb; + char dev; + char flag; +}; +extern struct fd_t fd_table[]; +#endif /* #ifdef __ATARI__ */ + +int main(int argc,char **argv) +{ + char *filename,*x; + char buf[20]; + int i,l,lr; + int fd; + int csp; + + if (argc >= 2) { + filename = *(argv+1); + } + else { + printf("\nfilename: "); + x = fgets(buf,19,stdin); + printf("\n"); + if (!x) { + printf("nothing read\n"); + return(0); + } +#if 0 + l = strlen(x); + printf("read: "); + for (i=0; i