Added hi[] and lo[] functions to the assembler; fix things enough that we now
get to the point of failing to link programs.
This commit is contained in:
		
							parent
							
								
									379c1a4a3c
								
							
						
					
					
						commit
						75308901bc
					
				
					 6 changed files with 43 additions and 17 deletions
				
			
		| 
						 | 
				
			
			@ -5,6 +5,9 @@
 | 
			
		|||
%token <y_word> OP_LI
 | 
			
		||||
%token <y_word> OP_LA
 | 
			
		||||
 | 
			
		||||
%token <y_word> HI
 | 
			
		||||
%token <y_word> LO
 | 
			
		||||
 | 
			
		||||
%type <y_word> gpr fpr
 | 
			
		||||
%type <y_word> e16 e9
 | 
			
		||||
%type <y_word> u25 u20 u16 u5 u3
 | 
			
		||||
| 
						 | 
				
			
			@ -14,6 +17,8 @@
 | 
			
		|||
%type <y_word> fcond
 | 
			
		||||
 | 
			
		||||
%type <y_word> extmsblsb insmsblsb
 | 
			
		||||
%type <y_word> hilo
 | 
			
		||||
%type <y_valu> extabsexp
 | 
			
		||||
 | 
			
		||||
#include "definitions.y"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,6 +8,6 @@
 | 
			
		|||
	li	r3, 20			! ECASE = 20 in h/em_abs.h
 | 
			
		||||
	! FALLTHROUGH to .trp
 | 
			
		||||
 | 
			
		||||
.trap:
 | 
			
		||||
	syscall
 | 
			
		||||
.trp:
 | 
			
		||||
	syscall 0
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue