koren@hpfelg.HP.COM (Steve Koren) (02/09/90)
Here's one for all you folks intimately familiar with the Amiga I/O
functions. I have a little program that looks like this:
#include <proto/all.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <ctype.h>
#define BUFF_SIZE 4096
unsigned char buff[BUFF_SIZE];
short main(argc, argv)
short argc;
char *argv[];
{
struct FileHandle *in_fh;
short x,
return_code,
start = 1;
for (x=start; x<argc; x++) {
if ((in_fh = (struct FileHandle *)
Open(argv[x], MODE_OLDFILE)) == NULL) {
exit(1);
} else {
Read((BPTR)in_fh, buff, BUFF_SIZE);
Close((BPTR)in_fh);
}
}
}
It could probably be simplified further, but I didn't bother. Anyhow, it
works just great if I 1) comment out the proto/all.h line and 2) link with
amiga.lib. However, if I include the proto/all.h file, and link with
only lc.lib like this:
blink from lib:cres.o fail5.o to ram:fail5 lib lib:lc.lib
the resulting executable guru's every time at the Read() line. I have
tried allocating the buffer with AllocMem to get 4-byte boundry
alignment, but that didn't seem to matter.
I also have found that any attempts to link with DEFINE __main=__tinymain
will crash when a Read() is encountered using the #pragma.
Anyone know what gives?
- stevenew@udel.edu (Darren New) (02/13/90)
In article <13920043@hpfelg.HP.COM> koren@hpfelg.HP.COM (Steve Koren) writes: >It could probably be simplified further, but I didn't bother. Anyhow, it >works just great if I 1) comment out the proto/all.h line and 2) link with >amiga.lib. However, if I include the proto/all.h file, and link with >only lc.lib like this: I've found a bug in LC5.04 that misgenerates the moving-into-registers code with the debug switches that DON'T flush registers on line boundries. That is, -d5 and -d3 work, but -d4 and -d2 generate code to move from somewhere to D2 instead of somewhere to D0 with pragmas. Look that your arguments (use CPR in mixed mode) are getting in the right registers. -- Darren