/* ** 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 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 #include extern int getsp(void); /* is provided in getsp.s */ /* Atari's fd indirection table */ #ifdef __ATARI__ extern char __fd_index[]; struct fd_t { char usage; char iocb; char dev; char flag; }; extern struct fd_t __fd_table[]; #endif 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