From: David Given Date: Sat, 8 Sep 2018 20:42:06 +0000 (+0200) Subject: Added hi[] and lo[] functions to the assembler; fix things enough that we now X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=75308901bc39915266e56bf4a9a183e2fdcc8d25;p=ack.git Added hi[] and lo[] functions to the assembler; fix things enough that we now get to the point of failing to link programs. --- diff --git a/mach/mips/as/mach2.c b/mach/mips/as/mach2.c index 9c81ed9a8..48fce7760 100644 --- a/mach/mips/as/mach2.c +++ b/mach/mips/as/mach2.c @@ -5,6 +5,9 @@ %token OP_LI %token OP_LA +%token HI +%token LO + %type gpr fpr %type e16 e9 %type u25 u20 u16 u5 u3 @@ -14,6 +17,8 @@ %type fcond %type extmsblsb insmsblsb +%type hilo +%type extabsexp #include "definitions.y" diff --git a/mach/mips/as/mach3.c b/mach/mips/as/mach3.c index d75845e7b..519bb02e3 100644 --- a/mach/mips/as/mach3.c +++ b/mach/mips/as/mach3.c @@ -76,6 +76,8 @@ 0, OP_LI, 0, "li", 0, OP_LA, 0, "la", +0, HI, RELOMIPSHI, "hi", +0, LO, RELOMIPS, "lo", #include "tokens.y" diff --git a/mach/mips/as/mach4.c b/mach/mips/as/mach4.c index fddeb25c7..7b2e7e2e0 100644 --- a/mach/mips/as/mach4.c +++ b/mach/mips/as/mach4.c @@ -31,6 +31,20 @@ emit4(0x34000000 | (reg<<16) | (reg<<21) | (val & 0xffff)); /* ori reg, reg, value */ } +extabsexp + : absexp + | hilo ASC_LPAR expr ASC_RPAR + { + newrelo($3.typ, $1 | FIXUPFLAGS); + $$ = $3.val; + } + ; + +hilo + : HI { $$ = $1; } + | LO { $$ = $1; } + ; + gpr: GPR fpr: FPR @@ -40,7 +54,11 @@ fmt3 | OP__DOT_W { $$ = 4; } | OP__DOT_L { $$ = 5; } | OP__DOT_PS { $$ = 6; } -fmt: fmt3 { $$ = $1 + 16; } + ; + +fmt + : fmt3 { $$ = $1 + 16; } + ; fcond : OP__DOT_F { $$ = 0; } @@ -59,9 +77,10 @@ fcond | OP__DOT_NGE { $$ = 13; } | OP__DOT_LE { $$ = 14; } | OP__DOT_NGT { $$ = 15; } + ; e16 - : absexp + : extabsexp { /* Allow signed or unsigned 16-bit values. */ if (($1 < -0x8000) || ($1 > 0xffff)) @@ -99,7 +118,7 @@ u20 ; u16 - : absexp + : extabsexp { if (($1 < 0) || ($1 > 0xffff)) serror("16-bit unsigned value out of range"); diff --git a/mach/mips/libem/c_ud_i.s b/mach/mips/libem/c_ud_i.s index e9c9dda19..c0dc10b32 100644 --- a/mach/mips/libem/c_ud_i.s +++ b/mach/mips/libem/c_ud_i.s @@ -4,16 +4,16 @@ .sect .data .sect .bss -.data - +.sect .text .define .c_ud_i .c_ud_i: /* Input: f0 * Output: r2 * Only at and f31 may be used. */ - li at, hi(.fd_80000000) - ldc1 f31, lo(.fd_800000000)(at) + + ori at, zero, hi[.fd_80000000] + ldc1 f31, lo[.fd_80000000] (at) c.le.d 0, f31, f0 bc1t toobig nop diff --git a/mach/mips/libem/c_uf_i.s b/mach/mips/libem/c_uf_i.s index ac0642fc7..6dd9f2360 100644 --- a/mach/mips/libem/c_uf_i.s +++ b/mach/mips/libem/c_uf_i.s @@ -4,28 +4,28 @@ .sect .data .sect .bss -.data - +.sect .text .define .c_uf_i .c_uf_i: /* Input: f0 * Output: r2 * Only at and f31 may be used. */ - li at, hi(.fd_80000000) - lwc1 f31, lo(.fd_800000000)(at) - c.le.f 0, f31, f0 + + ori at, zero, hi[.ff_80000000] + lwc1 f31, lo[.ff_80000000] (at) + c.le.s 0, f31, f0 bc1t toobig nop - trunc.w.f f0, f0 + trunc.w.s f0, f0 mfc1 r2, f0 jr ra nop toobig: - sub.f f0, f0, f31 - trunc.w.f f0, f0 + sub.s f0, f0, f31 + trunc.w.s f0, f0 mfc1 r2, f0 addiu r2, r2, 0x8000 jr ra diff --git a/mach/mips/libem/trp.s b/mach/mips/libem/trp.s index 7801d471c..58187079e 100644 --- a/mach/mips/libem/trp.s +++ b/mach/mips/libem/trp.s @@ -8,6 +8,6 @@ li r3, 20 ! ECASE = 20 in h/em_abs.h ! FALLTHROUGH to .trp -.trap: - syscall +.trp: + syscall 0