<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>I wrote a comment on the original Microsoft dev blog (for a
non-Pascal community), maybe it's of interest here, too ...<br>
<br>
</p>
<div class="comment-content" id="comment-text-140963">
<p>In normal Pascal procedure calls, such a vector of stack frame
addresses is not needed. A standard Pascal runtime knows all the
time about the current stack frame address of – say – the
procedure which is currently active at static level n. This
information is called the DISPLAY VECTOR and there is no need to
copy the display vector on procedure calls, because it is stored
at a well-known location inside the runtime. You only have to
replace the stack frame addresses of the current static level,
when you enter or leave a procedure (and maybe set the new
current static level). </p>
<p>What makes things more complicated, are procedure and function
PARAMETERS (in Pascal), that is: procedures that are passed as
parameters to other procedures. In this case, it is indeed
necessary to COPY THE COMPLETE DISPLAY VECTOR, because it is not
possible to predict what static level the procedure (which is
passed as a parameter) has. So maybe the ENTER instruction is
meant for such use cases.</p>
<p>Some of the old Pascal compilers didn’t allow procedure
parameters (or implemented them badly) due to these
difficulties.<br>
To see, if your (Pascal or Algol) compiler implemented procedure
parameters correctly, you can use the “Man or Boy” test: <a
href="https://en.wikipedia.org/wiki/Man_or_boy_test"
target="_blank" class="moz-txt-link-freetext">https://en.wikipedia.org/wiki/Man_or_boy_test</a></p>
</div>
<p></p>
<p><br>
</p>
<div class="moz-cite-prefix">Am 12.12.2023 um 17:48 schrieb Anthony
Walter via fpc-pascal:<br>
</div>
<blockquote type="cite"
cite="mid:CAHmPLWVquZ2_pzic5wjc+BrPp7rtbvgnkvA=+tufU_zdyxYvpA@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div>Iwas reading this article today on the Microsoft
website about the mysterious x86 ENTER instruction. The
article states that it's primary purpose is to support Pascal
and similar compilers to allow for preserving local
variables on the stack when using with nested functions.</div>
<div><br>
</div>
<div>Here is the article:</div>
<div><br>
</div>
<a
href="https://devblogs.microsoft.com/oldnewthing/20231211-00/?p=109126"
moz-do-not-send="true" class="moz-txt-link-freetext">https://devblogs.microsoft.com/oldnewthing/20231211-00/?p=109126</a><br>
<div><br>
</div>
<div>Do any of the compiler devs know if Pascal programs for the
x86 instruction set are using ENTER and its second argument to
the best possible effect? I am curious.</div>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
fpc-pascal maillist - <a class="moz-txt-link-abbreviated" href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal">https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a>
</pre>
</blockquote>
</body>
</html>