<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
The Astrobe compiler does use a frame pointer. Given the local variable 'a' declared as:<br>
<br>
VAR<br>
a: ARRAY OF INTEGER;<br>
<br>
The code generated by NEW(a, 10) is as follows:<br>
<br>
MOV r10,10<br>
STR r10,[fp,-8]<br>
MOV r10,r10 lsl 2<br>
SUB sp,sp,r10<br>
STR sp,[fp,-4]<br>
<br></blockquote><div><br> <br>I see, that is similar to what I was expecting.<br>If my understanding is correct, [fp, -8] and [fp, -4] represent an array descriptor, where you store the length and address on the stack respectively. SP is decremented by length*element size to make space for the array.Very neat!</div><div>Is [fp,-4] the beginning or the end of the array "a"?<br></div><div><br></div><div>I have checked "An Oberon Compiler for the ARM Processor" p. 26 and it seems like in that compiler dynamic arrays are allocated on the heap:<br><br>PROCEDURE P;<br> VAR k: INTEGER;<br> a: ARRAY OF INTEGER;<br>BEGIN NEW(a, 10); a[k] := 100<br>END P;<br><br>The code generated by NEW(a, 10) is as follows:<br><br> SUB R11 FP 8 adr a<br> MOV R10 R0 10 len<br> MOV R9 R0 4 element size <br> BL 0 NEW (updated by loader)<br> <br><br>Do you know if that system had a garbage collector? I am surprised by that implementation, I thought it was doing something like your Astrobe compiler.<br></div><div><br></div><div>Regards, <br></div><div>Luca<br></div></div></div></div>