]> Shamusworld >> Repos - rmac/blobdiff - eagen0.c
Removed -w flag, added +o[n], ~o[n] switches to control individual optimisations...
[rmac] / eagen0.c
index c3feb2c0baaba382f51a72cfc1be110b31b406cc..7ec6ccb0fcf28cdbca6156b8982e802bd0cc1f41 100644 (file)
--- a/eagen0.c
+++ b/eagen0.c
@@ -4,7 +4,7 @@
 //            Generated Code for eaN (Included twice by "eagen.c")
 // 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
 //
 
 int eaNgen(WORD siz)
@@ -39,6 +39,35 @@ int eaNgen(WORD siz)
                        if (tdb)
                                rmark(cursect, sloc, tdb, MWORD, NULL);
 
+                       if ((v == 0) && optim_flags[OPT_INDIRECT_DISP])
+                       {
+                               // If expr is 0, size optimise the opcode.
+                               // Generally the lower 6 bits of the opcode
+                               // for expr(ax) are 101rrr where rrr=the
+                               // number of the register, then followed by
+                               // a word containing 'expr'. We need to change
+                               // that to 010rrr.
+                               if ((siz & 0x8000) == 0)
+                               {
+                                       chptr_opcode[0] &= ((0xFFC7 >> 8) & 255); // mask off bits
+                                       chptr_opcode[1] &= 0xFFC7 & 255;          // mask off bits
+                                       chptr_opcode[0] |= ((0x0010 >> 8) & 255); // slap in 010 bits
+                                       chptr_opcode[1] |= 0x0010 & 255;          // slap in 010 bits
+                               }
+                               else
+                               {
+                                       // Special case for move ea,ea:
+                                       // there are two ea fields there and
+                                       // we get a signal if it's the second ea field
+                                       // from m_ea - siz's 16th bit is set
+                                       chptr_opcode[0] &= ((0xFE3F >> 8) & 255); // mask off bits
+                                       chptr_opcode[1] &= 0xFE3F & 255;          // mask off bits
+                                       chptr_opcode[0] |= ((0x0080 >> 8) & 255); // slap in 010 bits
+                                       chptr_opcode[1] |= 0x0080 & 255;          // slap in 010 bits
+                               }
+                               return OK;
+                       }
+
                        if (v + 0x8000 >= 0x18000)
                                return error(range_error);
 
@@ -114,7 +143,7 @@ int eaNgen(WORD siz)
                        if (v + 0x80 >= 0x100)
                                return error(range_error);
 
-                       w |= v & 0xff;
+                       w |= v & 0xFF;
                        D_word(w);
                }
                else