From 34c67698ef188cf9764fc8a79424a9e64b1850ef Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 15 Feb 2019 23:01:33 +0100 Subject: [PATCH 1/2] Generate the proper function prologues for big stack frames. --- mach/i80/ncg/mach.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mach/i80/ncg/mach.c b/mach/i80/ncg/mach.c index 30682eb82..968ececbe 100644 --- a/mach/i80/ncg/mach.c +++ b/mach/i80/ncg/mach.c @@ -49,16 +49,18 @@ void con_mult(sz) word sz; void prolog(full nlocals) { - if (nlocals == 0) + int16_t adjustment = -nlocals; + + if (adjustment == 0) fprintf(codefile, "\tcall .pro0\n"); - else if (nlocals == 2) + else if (adjustment == -2) fprintf(codefile, "\tcall .pro2\n"); - else if (nlocals == 4) + else if (adjustment == -4) fprintf(codefile, "\tcall .pro4\n"); - else if (nlocals < 0x100) - fprintf(codefile, "\tcall .probyte\n\t.data1 %d\n", -nlocals); + else if ((adjustment >= -128) && (adjustment <= 127)) + fprintf(codefile, "\tcall .probyte\n\t.data1 %d\n", adjustment); else - fprintf(codefile, "\tcall .proword\n\t.data2 %d\n", -nlocals); + fprintf(codefile, "\tcall .proword\n\t.data2 %d\n", adjustment); } void mes(type) word type; From 4474d6433aa3a40ba27164b76d2092ea9c81686b Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 15 Feb 2019 23:03:01 +0100 Subject: [PATCH 2/2] Loading large constants now computes the stack offset correctly. --- mach/i80/ncg/table | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mach/i80/ncg/table b/mach/i80/ncg/table index ad5290043..b9a2b49dc 100644 --- a/mach/i80/ncg/table +++ b/mach/i80/ncg/table @@ -350,12 +350,13 @@ pat lol ($1<0) && ($1>=0-STACKHELPERS) yields de pat lol - uses dereg + uses dereg, hlreg={const2, $1} gen dad lb mov e, {m} inx hl mov d, {m} + yields de pat loe uses hlreg