Fix an incorrect instruction, and incredibly broken li handling.
authorDavid Given <dg@cowlark.com>
Wed, 12 Sep 2018 21:59:09 +0000 (23:59 +0200)
committerDavid Given <dg@cowlark.com>
Wed, 12 Sep 2018 21:59:09 +0000 (23:59 +0200)
mach/mips/as/instructions.dat
mach/mips/as/mach4.c

index 98c4dbb..10619f8 100644 (file)
 010011<RS-><RT->00000<FD->001101 "suxc1" FD=fpr ',' RT=gpr '(' RS=gpr ')'
 111001<RS-><FT-><IMM-----------> "swc1" FT=fpr ',' IMM=e16 '(' RS=gpr ')'
 010011<RS-><RT->00000<FD->001000 "swxc1" FD=fpr ',' RT=gpr '(' RS=gpr ')'
-010001<F-->00000<FS-><FD->001001 "trunc" ".l" F=fmt FS=fpr ',' FD=fpr
-010001<F-->00000<FS-><FD->001101 "trunc" ".w" F=fmt FS=fpr ',' FD=fpr
+010001<F-->00000<FS-><FD->001001 "trunc" ".l" F=fmt FD=fpr ',' FS=fpr
+010001<F-->00000<FS-><FD->001101 "trunc" ".w" F=fmt FD=fpr ',' FS=fpr
 
 # Generic coprocessor instructions.
 
index 443ca1e..0befb2d 100644 (file)
@@ -2,10 +2,12 @@
        | OP_LI GPR ',' extabsexp
        {
                word_t reg = $2;
-               word_t val = $4;
+               uint32_t val = $4;
 
-               if ((val < -0x8000) || (val > 0xffff))
+               if (((int32_t)val >= -0x8000) && ((int32_t)val <= 0x7fff))
                        emit4(0x24000000 | (reg<<16) | (val & 0xffff)); /* addiu reg, zero, value */
+               else if (val <= 0xffff)
+                       emit4(0x34000000 | (reg<<16) | val); /* ori reg, zero, value */
                else
                {
                        emit4(0x3c000000 | (reg<<16) | (val>>16)); /* lui reg, value */
@@ -16,7 +18,7 @@
        {
                word_t reg = $2;
                word_t type = $4.typ & S_TYP;
-               word_t val = $4.val;
+               uint32_t val = $4.val;
 
                if (type != S_ABS)
                        newrelo($4.typ, RELO2HI | FIXUPFLAGS);