Question on ORG.SaveRegs / ORG.RestoreRegs in the FPGA Oberon compiler
As a purely pedagogical addendum: A possible student exercise would be to rewrite ORG assuming *no* procedure variables existed in the language: PROCEDURE PrepCall*(VAR x: Item; VAR r: LONGINT); BEGIN (*x.type.form = ORB.Proc*) r := RH; IF RH > 0 THEN SaveRegs(RH); RH := 0 END END PrepCall; PROCEDURE Call*(VAR x: Item; r: LONGINT); BEGIN (*(x.mode = ORB.Const) & (x.type.form = ORB.Proc)*) IF x.r >= 0 THEN Put3(BL, 7, (x.a DIV 4)-pc-1) ELSIF pc - fixorgP < 1000H THEN Put3(BL, 7, ((-x.r) * 100H + x.a) * 1000H + pc-fixorgP); fixorgP := pc-1 ELSE ORS.Mark("fixup impossible") END ; IF x.type.base.form = ORB.NoTyp THEN (*procedure*) RH := 0 ELSE (*function*) IF r > 0 THEN Put0(Mov, r, 0, 0); RestoreRegs(r) END ; x.mode := Reg; x.r := r; RH := r+1 END END Call;
On Mon, 18 Feb 2019 06:38:47 +0100 Andreas Pirklbauer <andreas_pirklbauer@yahoo.com> wrote:
As a purely pedagogical addendum: A possible student exercise would be to rewrite ORG assuming *no* procedure variables existed in the language:
Hi Andreas, Rarely do I receive your posts from the list, seems on account of my email client. Having read PO2013 Compiler Application, and Compiler construction books, still not feeling up to tinkering the compiler. I rather toy with the system, seems easier task, you may see my endeavours, some better then others :) Will delve into compiler books again and try to experiment a little. -- Tomas Kral <thomas.kral@email.cz>
participants (2)
-
Andreas Pirklbauer -
Tomas Kral