Orlando Llanes wrote:
On Mon, 12 Oct 1998, Frank Heckenbach wrote:
This seems to be a bug in fact. They are declared "local" in the assembler output (or shouldn't they be global for some reason, Peter?).
I meant at a low level within the unit. In my example, a variable was
declared in the unit, and another variable declared in the asm file. The unit had access to the asm's variables, but not vice versa.
Yes, I think that's this problem. If you compile a unit with `-S', you'll find that global variables in the implementation (as well as global variables in a program) are `local' instead of `global' or `comm'.
Frank Heckenbach wrote:
Orlando Llanes wrote:
On Mon, 12 Oct 1998, Frank Heckenbach wrote:
This seems to be a bug in fact. They are declared "local" in the assembler output (or shouldn't they be global for some reason, Peter?).
I meant at a low level within the unit. In my example, a variable was
declared in the unit, and another variable declared in the asm file. The unit had access to the asm's variables, but not vice versa.
Yes, I think that's this problem. If you compile a unit with `-S', you'll find that global variables in the implementation
... where it _must_ be like this ...
(as well as global variables in a program)
... where we should discuss about ...
are `local' instead of `global' or `comm'.
Global variables of the program must be in the data (and not in the stack) segment in order to circumvent limitations of the stack size. Normally, there is no need to make them visible to the linker because programs cannot be "used" (imported) by other Pascal programs, modules, or units. (In C, such variables are declared `static'.)
If you want to make a global variable of the program visible to the linker (and thus to external assembler routines), you can use the following trick:
Program Test;
Var Foo: external Integer; Foo: Integer;
begin end.
This produces a `comm' variable without `local'.
The first declaration of `Foo' tells the compiler that there is some external integer variable `Foo'. The second one allocates storage for this variable, remembering that it must be accessible from the external world.
Okay like this?
Peter