[comp.sys.apollo] Help! Pascal Bug Overwhelms Programmer!

krowitz@RICHTER.MIT.EDU (David Krowitz) (12/07/88)

I've run into a Pascal bug has baffled me. I'm writing a large
Pascal program to control a color page scanner. It calls a
seperately compiled library of routines which handle the
scanner hardware. One of these routines which the main program
calls fills a user-supplied buffer with data from the scanner
and returns the length of the buffer in bytes (ie. how much
data was returned by the call).

When I compile the main program with -OPT 3 -CPU ANY and bind
it to the subroutine library (also compiled with -OPT 3 -CPU ANY),
the program works just fine. It's a tad slow, however, since I
have to do a lot of 32-bit integer divisions to process the
data coming in from the scanner, and the -CPU ANY switch does
the arithmetic in software. If I recompile the main program
with -CPU 3000 -OPT 3 (leaving the subroutine library alone), and
then re-bind the program, the program fails! A write statement
place immediately after the call to the routine which returns
the data from the scanner tells me that the length of the
buffer is different than it was when the main program was
compiled with -CPU ANY. If I use the -EXP switch to look at
the psuedo assembly code, I can see that the subroutine library
is being called with the same sequence.

Does anyone have any ideas on how optimizing a main program can
change the values being returned from a seperately compiled
subroutine?


 -- David Krowitz

krowitz@richter.mit.edu   (18.83.0.109)
krowitz%richter@eddie.mit.edu
krowitz%richter@athena.mit.edu
krowitz%richter.mit.edu@mitvma.bitnet
(in order of decreasing preference)