]> Shamusworld >> Repos - rmac/blobdiff - mach.c
Extended switch -s to also warn about automatically applied 68000 optimisations....
[rmac] / mach.c
diff --git a/mach.c b/mach.c
index a108f4440ce21cd68616696bfdd5fe0756e4ba26..b3e36c7dc382c93b84599a1979f8da85920c7280 100644 (file)
--- a/mach.c
+++ b/mach.c
@@ -3,7 +3,7 @@
 // MACH.C - Code Generation
 // Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
 // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
-// Source Utilised with the Kind Permission of Landon Dyer
+// Source utilised with the kind permission of Landon Dyer
 //
 
 #include "mach.h"
@@ -13,6 +13,7 @@
 #include "token.h"
 #include "procln.h"
 #include "riscasm.h"
+#include "rmac.h"
 
 #define DEF_KW
 #include "kwtab.h"
@@ -307,7 +308,7 @@ int m_shi(WORD inst, WORD siz)
        }
        else
        {
-               fixup(FU_QUICK, sloc, a0expr);
+               AddFixup(FU_QUICK, sloc, a0expr);
                D_word(inst);
        }
 
@@ -372,7 +373,7 @@ int m_dbra(WORD inst, WORD siz)
        }
        else
        {
-               fixup(FU_WORD | FU_PCREL | FU_ISBRA, sloc, a1expr);
+               AddFixup(FU_WORD | FU_PCREL | FU_ISBRA, sloc, a1expr);
                D_word(0);
        }
 
@@ -439,10 +440,12 @@ int m_move(WORD inst, WORD size)
        int siz = (int)size;
 
        // Try to optimize to MOVEQ
-       if (siz == SIZL && am0 == IMMED && am1 == DREG
+       if (optim_flag && siz == SIZL && am0 == IMMED && am1 == DREG
                && (a0exattr & (TDB|DEFINED)) == DEFINED && a0exval + 0x80 < 0x100)
        {
                m_moveq((WORD)0x7000, (WORD)0);
+               if (sbra_flag)
+                       warn("move.l #size,dx converted to moveq");
        }
        else
        {
@@ -489,7 +492,7 @@ int m_moveq(WORD inst, WORD siz)
        // Arrange for future fixup 
        if (!(a0exattr & DEFINED))
        {
-               fixup(FU_BYTE | FU_SEXT, sloc + 1, a0expr);
+               AddFixup(FU_BYTE | FU_SEXT, sloc + 1, a0expr);
                a0exval = 0; 
        }
        else if (a0exval + 0x100 >= 0x200)
@@ -516,7 +519,7 @@ int m_movep(WORD inst, WORD siz)
                D_word(inst);
 
                if (am1 == AIND)
-                       D_word(0);
+                       D_word(0)
                else 
                        ea1gen(siz);
        }
@@ -526,7 +529,7 @@ int m_movep(WORD inst, WORD siz)
                D_word(inst);
 
                if (am0 == AIND)
-                       D_word(0);
+                       D_word(0)
                else 
                        ea0gen(siz);
        }
@@ -545,18 +548,23 @@ int m_br(WORD inst, WORD siz)
        if (a0exattr & DEFINED)
        {
                if ((a0exattr & TDB) != cursect)
+//{
+//printf("m_br(): a0exattr = %X, cursect = %X, a0exval = %X, sloc = %X\n", a0exattr, cursect, a0exval, sloc);
                        return error(rel_error);
+//}
 
                v = a0exval - (sloc + 2);
 
                // Optimize branch instr. size
                if (siz == SIZN)
                {
-                       if (v != 0 && v + 0x80 < 0x100)
+                       if (optim_flag && v != 0 && v + 0x80 < 0x100)
                        {
                                // Fits in .B 
                                inst |= v & 0xFF;
                                D_word(inst);
+                               if (sbra_flag)
+                                       warn("Bcc.w/BSR.w converted to .s");
                                return 0;
                        }
                        else
@@ -596,7 +604,7 @@ int m_br(WORD inst, WORD siz)
        if (siz == SIZB)
        {
                // .B 
-               fixup(FU_BBRA | FU_PCREL | FU_SEXT, sloc, a0expr);
+               AddFixup(FU_BBRA | FU_PCREL | FU_SEXT, sloc, a0expr);
                D_word(inst);
                return 0;
        }
@@ -604,7 +612,7 @@ int m_br(WORD inst, WORD siz)
        {
                // .W 
                D_word(inst);
-               fixup(FU_WORD | FU_PCREL | FU_LBRA | FU_ISBRA, sloc, a0expr);
+               AddFixup(FU_WORD | FU_PCREL | FU_LBRA | FU_ISBRA, sloc, a0expr);
                D_word(0);
        }
 
@@ -629,7 +637,7 @@ int m_addq(WORD inst, WORD siz)
        }
        else
        {
-               fixup(FU_QUICK, sloc, a0expr);
+               AddFixup(FU_QUICK, sloc, a0expr);
                D_word(inst);
        }