Path: csiph.com!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: Hans-Peter Diettrich Newsgroups: comp.compilers Subject: Re: Memory organisation of the Z80 Turbo Pascal compiler Date: Thu, 30 Sep 2021 11:15:32 +0200 Organization: Compilers Central Lines: 39 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <21-10-001@comp.compilers> References: <21-09-014@comp.compilers> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="39613"; mail-complaints-to="abuse@iecc.com" Keywords: history Posted-Date: 01 Oct 2021 15:59:18 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com In-Reply-To: <21-09-014@comp.compilers> Content-Language: de-DE Xref: csiph.com comp.compilers:2709 On 9/29/21 1:40 PM, Lasse Hillerøe Petersen wrote: > I have been thinking about the old TurboPascal compiler (actually about > its predecessor COMPAS Pascal, which I used long ago, but I believe the > original Z80 CP/M TurboPascal was exactly the same in this regard.) > > In the TP 2.0 manual it says: > "The recursion stack is used only by recursive procedures and > functions, i.e. procedures and functions compiled with the > A compiler directive passive (~A-}). On entry to a recursive > subprogram it copies its workspace onto the recursion stack, > and on exit the entire workspace is restored to its original > state. The default initial value of RecurPtr at the beginning > of a program, is 1 K ($400) bytes below the CPU stack pointer." The famous GfA-Basic for Atari ST and Amiga used a similar strange handling of local variables as global variables. On entry of a subroutine all "local" variables were saved on the stack and restored on exit. In between all references within the entire code used the local variables of that subroutine instance in the global workspace. This way every variable of a unique name and type had a fixed address at runtime. [...] > Other than the copying (which may be considered inefficient, but only > applies to recursive procedures) and the possible issue with passing > references ending up pointing to the wrong variable, what would be the > pros and cons of this method? I don't remember whether GfA Basic included pointers or distinct ref/val parameters. At least it was a damn fast framework on those 68k processors, in detail compared to 8086 processors of that time. A con of the GfA method was found in the later PC version that used the traditional and compatible way of storing local variables in the stackframe. This broke some legacy code, sooner or later, and I ended up with a set of subroutines that could not be converted into any other language. Unfortunately this was the tricky analysis of complex conditional expressions in IF (WHILE...) statements of my C decompiler :-( DoDi