[comp.lang.pascal] 8K-problem with VS Pascal

RCIVDAB%HDETUD1.TUDELFT.NL@uga.cc.uga.edu ( Dim Biesheuvel) (05/08/91)

A user is converting a large (90K) Pascal program, which takes too much
time with Turbo Pascal on his pc, to VS Pascal on the IBM mainframe.
After several other problems he now runs into error message
    AMPT902S Routine exceeds 8K limit
The manual suggests breaking up the routine in smaller ones, but,
while this is done to a great extent, the error persists.
The question is: what is costing so much coding space, so that 2 base
registers are not sufficient? Are array-sizes and the numbers of arrays
in a routine of influence on this part?
Any suggestions on how to avoid this problem? We would be grateful.

Dim Biesheuvel
Rekencentrum
Technische Universiteit Delft

jfr@locus.com (Jon Rosen) (05/10/91)

In article <26812@adm.brl.mil> RCIVDAB%HDETUD1.TUDELFT.NL@uga.cc.uga.edu ( Dim Biesheuvel) writes:
>A user is converting a large (90K) Pascal program, which takes too much
>time with Turbo Pascal on his pc, to VS Pascal on the IBM mainframe.
>After several other problems he now runs into error message
>    AMPT902S Routine exceeds 8K limit
>The manual suggests breaking up the routine in smaller ones, but,
>while this is done to a great extent, the error persists.
>The question is: what is costing so much coding space, so that 2 base
>registers are not sufficient? Are array-sizes and the numbers of arrays
>in a routine of influence on this part?

Having NO idea what the program looks like in Turbo- or VS-Pascal, I
can't really answer the question authoritatively except to say that
array sizes should have nothing to do with it... VS Pascal allocates
all data either on its simulated stack or using GETMAINs out of
regular free memory storage... It does not allocate variables in
its code space (this is to insure reentrancy and recursive capability).
I have not heard of an 8K limit on stack variable and I know there is
no such limit on dynamic variables... This should certainly be 
specificied in the Programmer's Manual...
 
If you really think the arrays are a problem, you can certainly fix
it by making them dynamic (i.e., pointer-based)... Just postfix
a caret (up-arrow) to each reference in the program and prefix
a caret in the declaration and make sure to do a New at the start
of the program...  I have made many static arrays dynamic just
to get around memory problems in Turbo Pascal with a simple editing
session... In pascal this works much better than trying to do the
same thing in C, for instance...
 
If this error still occurs, then some routine is still generating
more than 8K of code... You can use the LIST operand on the compile
to look at the assembler... this will tell you WHY the program is
exceeding memory... You wil be able to see statement by statement
the generated code...
 
Good luck,

Jon Rosen