]> Shamusworld >> Repos - rmac/commitdiff
Fix for bug #165: apply checks when transforming adda to lea, and also negate value...
authorggn <ggn.dbug@gmail.com>
Thu, 16 Jul 2020 13:15:54 +0000 (16:15 +0300)
committerShamus Hammons <jlhamm@acm.org>
Fri, 17 Jul 2020 23:20:15 +0000 (18:20 -0500)
docs/rmac.rst
mach.c

index d937ff57bd4d40b89c8b034b37a30dd8fc2cad8b..246475a1111d48008d7a3546b3c71d0b7d598e0e 100644 (file)
@@ -4,8 +4,8 @@ RMAC
 =====================
 Reference Manual
 ================
-version 2.0.8
-=============
+version 2.0.18
+==============
 
 © and notes
 ===========
@@ -17,7 +17,7 @@ the accuracy of printed or duplicated material after the date of publication and
 disclaims liability for changes, errors or omissions.*
 
 
-*Copyright © 2011-2019, Reboot*
+*Copyright © 2011-2020, Reboot*
 
 *All rights reserved.*
 
@@ -902,12 +902,12 @@ code if the debugging code is referenced, as in:
 
                lea    string,a0            ; AO -> message
                jsr    debug                ; print a message
-               its                         ; and return
+               rts                         ; and return
         string: dc.b  "Help me, Spock!",0  ; (the message)
                     .
                     .
                     .
-               .iif ^^defined debug, .include "debug.s"
+               .iif ^^referenced debug, .include "debug.s"
 
 The **jsr** statement references the symbol debug. Near the end of the source file, the
 "**.iif**" statement includes the file "**debug.s**" if the symbol debug was referenced.
@@ -1532,10 +1532,10 @@ The assembler provides "creature comforts" when it processes 68000 mnemonics:
    (*!*) on their first column.
  
  * In GPU/DSP code sections, you can use JUMP (Rx) in place of JUMP T, (Rx) and JR
-  (Rx) in place of JR T,(Rx).
+   (Rx) in place of JR T,(Rx).
 
  * RMAC tests all GPU/DSP restrictions and corrects them wherever possible (such as
-  inserting a NOP instruction when needed).
+   inserting a NOP instruction when needed).
 
  * The *(Rx+N)* addressing mode for GPU/DSP instructions is optimized to *(Rx)*
    when *N* is zero.
diff --git a/mach.c b/mach.c
index 1309fae048d9843349977e95a2f5fad0e5e0031f..eec74f72b2d2c9d9343adf319049fe057827e88a 100644 (file)
--- a/mach.c
+++ b/mach.c
@@ -465,11 +465,16 @@ int m_adda(WORD inst, WORD siz)
                                // Immediate is between 1 and 8 so let's convert to addq
                                return m_addq(B16(01010000, 00000000), siz);
        if (CHECK_OPTS(OPT_ADDA_LEA))
-               if (a0exval > 8)
+               if (a0exval > 8 && (a0exval+0x8000)<0x10000)
                {
-                       // Immediate is larger than 8 so let's convert to lea
+                       // Immediate is larger than 8 and word size so let's convert to lea
                        am0 = ADISP;    // Change addressing mode
                        a0reg = a1reg;  // In ADISP a0reg is used instead of a1reg!
+                       if (!(inst & (1 << 14)))
+                       {
+                               // We have a suba #x,AREG so let's negate the value
+                               a0exval = -a0exval;
+                       }
                        return m_lea(B16(01000001, 11011000), SIZW);
                }
        }