Fixed bug: some offsets were just plain wrong
authorceriel <none@none>
Mon, 8 Feb 1993 13:35:44 +0000 (13:35 +0000)
committerceriel <none@none>
Mon, 8 Feb 1993 13:35:44 +0000 (13:35 +0000)
mach/m68k2/as/mach1.c
mach/m68k2/as/mach4.c
mach/m68k2/as/mach5.c

index 88acece..0660aff 100644 (file)
@@ -42,6 +42,7 @@ extern expr_t exp_1,exp_2;
 extern valu_t  rel_1,rel_2;
 #endif
 extern int     model;          /* 68000/68010 */
+extern int     curr_instr;
 
 /* addressing mode bits */
 #define        DTA             0x01
index 9d47a96..114b6b7 100644 (file)
@@ -9,6 +9,11 @@
  */
 
 operation
+       :       { curr_instr = curr_token; }
+               _operation
+       ;
+
+_operation
        :       bcdx DREG ',' DREG
                        {       emit2($1 | $2 | $4<<9);}
        |       bcdx '-' '(' AREG ')' ',' '-' '(' AREG ')'
index 2683190..63c5450 100644 (file)
@@ -8,6 +8,23 @@
  * Motorola 68000/68010 auxiliary functions
  */
 
+static int
+extension_offset()
+{
+       switch(curr_instr) {
+       case MOVEM:
+       case FMOVE:
+       case FMOVEM:
+       case FDYADIC:
+       case FMONADIC:
+       case FSINCOS:
+       case FSCC:
+       case FTST:
+               return 4;
+       }
+       return 2;
+}
+
 ea_1(sz, bits)
 {
        register flag;
@@ -376,7 +393,7 @@ ea5x73(rg, sz)
                /* pc relative with index */
                if (sz == SIZE_NON)
                        sz = SIZE_DEF;
-               exp_2.val -= (DOTVAL + 2);
+               exp_2.val -= (DOTVAL + extension_offset());
                mrg_2 = 073;
                checksize(sz, 2|4);
                index(rg<<12 | (sz&0200)<<4);
@@ -416,10 +433,11 @@ ea707172(sz)
                return;
        }
        if ((exp_2.typ & ~S_DOT) == DOTTYP) {
-               sm = fitw(exp_2.val-(DOTVAL+2));
+               int off = extension_offset();
+               sm = fitw(exp_2.val-(DOTVAL+off));
                sm = small(sm, 2);
                if (sm) {       /* pc relative */
-                       exp_2.val -= (DOTVAL+2);
+                       exp_2.val -= (DOTVAL+off);
                        mrg_2 = 072;
                }
        } else {
@@ -447,13 +465,13 @@ ea6x(rg, ir, sz)
 ea72()
 {
        mrg_2 = 072;
-       exp_2.val -= (DOTVAL + 2);
+       exp_2.val -= (DOTVAL + extension_offset());
 }
 
 ea73(ri, sz)
 {
        mrg_2 = 073;
-       exp_2.val -= (DOTVAL + 2);
+       exp_2.val -= (DOTVAL + extension_offset());
        checksize(sz, 2|4);
        index(ri<<12 | (sz&0200)<<4);
 }