]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Tester disassembler indirect operand reads, prevents crashes when disassembling instr...
authorToni Wilen <twilen@winuae.net>
Sat, 16 May 2020 12:38:57 +0000 (15:38 +0300)
committerToni Wilen <twilen@winuae.net>
Sat, 16 May 2020 12:38:57 +0000 (15:38 +0300)
cputest/adis/decode_ea.c
cputest/adis/defs.h
cputest/adis/globals.c
cputest/adis/opcode_handler_cpu.c
cputest/adis/opcode_handler_fpu.c
cputest/adis/opcode_handler_mmu.c
cputest/adis/util.c
cputest/main.c

index 3f4b39edaa658fcbbd99001bd1f307338814f4e7..ca50a77aedaea2f2145807ecc4676d2d73a73f8f 100644 (file)
@@ -52,9 +52,9 @@ uint decode_ea (char *to, ushort mode, ushort reg, UWORD access, ushort first_ex
 {
 static ULONG maybe_jmptable_ref = UNSET;  /* for jump table disassembly */
 ULONG ref;
-register UWORD first_ext_w;
+UWORD first_ext_w;
 
-first_ext_w = *(code + first_ext);
+first_ext_w = lw(code + first_ext);
 switch (mode)
   {
   /********************** data register direct ************************/
@@ -81,7 +81,7 @@ switch (mode)
   case 2:
     if (pass3)
       indirect (to, (ushort)(reg + 8));
-    else if ((*code & 0xfff8) == 0x4ed0)  /* jmp (An) */
+    else if ((lw(code) & 0xfff8) == 0x4ed0)  /* jmp (An) */
       {
       if (!FLAGS_RELOC (maybe_jmptable_ref))
         enter_jmptab (maybe_jmptable_ref, 0);  /* jmp table with word entries */
@@ -197,7 +197,7 @@ switch (mode)
       /*********************** absolute long **********************/
 
       case 1:
-        ref = *(ULONG*)(code + first_ext);
+        ref = llu(code + first_ext);
         if (FLAGS_RELOC (current_ref + first_ext * 2))
           {
           if (pass3)
@@ -305,7 +305,7 @@ switch (mode)
                             (first_ext_w & 0x0800) ? ACC_LONG : ACC_WORD);
           else if ((LONG)ref >= (LONG)first_ref && (LONG)ref < (LONG)last_ref)
             {
-            if (*code == 0x4efb)  /* Check for JMP (d8,PC,Xn) */
+            if (lw(code) == 0x4efb)  /* Check for JMP (d8,PC,Xn) */
               {
               enter_jmptab (maybe_jmptable_ref, (ULONG)((BYTE)first_ext_w) + 2);
               }
@@ -348,7 +348,7 @@ switch (mode)
           }
         else if (access & ACC_LONG)
           {
-          ref = *(ULONG*)(code + first_ext);
+          ref = llu(code + first_ext);
           if (FLAGS_RELOC (current_ref + first_ext * 2))
             {
             if (pass2)
@@ -381,8 +381,8 @@ switch (mode)
           {
           if (pass3)
             {
-            sprintf (to, "#$%lx%08lx", *(ULONG*)(code + first_ext),
-                     *(ULONG*)(code + first_ext + 2));
+            sprintf (to, "#$%lx%08lx", llu(code + first_ext),
+                     llu(code + first_ext + 2));
             }
           return (4);
           }
@@ -390,9 +390,9 @@ switch (mode)
           {
           if (pass3)
             {
-            sprintf (to, "#$%lx%08lx%08lx", *(ULONG*)(code + first_ext),
-                     *(ULONG*)(code + first_ext + 2), 
-                     *(ULONG*)(code + first_ext + 4));
+            sprintf (to, "#$%lx%08lx%08lx", llu(code + first_ext),
+                     llu(code + first_ext + 2), 
+                     llu(code + first_ext + 4));
             }
           return (6);
           }
index 9c1e2a38a8274918029c2cb9296f925a9a6e2c83..9882543aff1ad4fa0551010dbb71dda8617fdf90 100644 (file)
@@ -191,6 +191,18 @@ enum
 #define FLAG_TABLE      0x40  /* data is a table */
 #define FLAG_CODE       0x80  /* data is code */
 
+#if 1
+#define FLAGS_BYTE(ref) 0
+#define FLAGS_WORD(ref) 0
+#define FLAGS_LONG(ref) 0
+#define FLAGS_SIGNED(ref) 0
+#define FLAGS_RELOC(ref) 0
+#define FLAGS_CODE(ref) 0
+#define FLAGS_STRING(ref) 0
+#define FLAGS_BAD(ref) 0
+#define FLAGS_ANY(ref) 0
+#define FLAGS_NONE(ref) 0
+#else
 #define FLAGS_BYTE(ref)    (*(flags + (ref) - first_ref) & FLAG_BYTE)
 #define FLAGS_WORD(ref)    (*(flags + (ref) - first_ref) & FLAG_WORD)
 #define FLAGS_LONG(ref)    (*(flags + (ref) - first_ref) & FLAG_LONG)
@@ -212,6 +224,7 @@ enum
 #define FLAGS_STRING_P(ptr)    (*(ptr) & FLAG_STRING)
 #define FLAGS_BAD_P(ptr)       (*(ptr) & (FLAG_CODE | FLAG_RELOC))
 #define FLAGS_ANY_P(ptr)       (*(ptr))
+#endif
 
 /* Marker for jump-tables */
 #ifdef DEBUG
@@ -521,3 +534,7 @@ void print_jmptab_list (void);
 
 /* library.c */
 void enter_library_refs (UBYTE *seg);
+
+UWORD lw(UWORD*);
+ULONG llu(UWORD*);
+LONG lls(UWORD*);
index 5500aa019ca976dda106f9f6429229da7861df78..d7c554a35271c5156fc28e671cf72fb6463902f6 100644 (file)
@@ -96,7 +96,7 @@ BOOL cpu68010 = TRUE,
 BOOL disasm_as_lib = FALSE;         /* -l */
 BOOL ascending_label_numbers = FALSE;   /* -dn */
 BOOL verbose = FALSE;
-BOOL optimize = TRUE;
+BOOL optimize = FALSE;
 BOOL branch_sizes = TRUE;
 BOOL instr_bad;
 BOOL instr_end;
index e5f82f209741632d6c2c2e293d3d0088b920771e..432ebae2bdc9d8c6742d2cd366f2424b544e6001 100644 (file)
@@ -49,7 +49,7 @@ uint EA_to_Rn (struct opcode_entry *op)
 {
 if (pass3)
   str_cpy (dest, reg_names [op->param]);
-return (decode_ea (src, MODE_NUM (*code), REG_NUM (*code), op->access, 1) + 1);
+return (decode_ea (src, MODE_NUM (lw(code)), REG_NUM (lw(code)), op->access, 1) + 1);
 }
 
 /**********************************************************************/
@@ -60,7 +60,7 @@ uint Rn_to_EA (struct opcode_entry *op)
 {
 if (pass3)
   str_cpy (src, reg_names [op->param]);
-return (decode_ea (dest, MODE_NUM (*code), REG_NUM (*code), op->access, 1) + 1);
+return (decode_ea (dest, MODE_NUM (lw(code)), REG_NUM (lw(code)), op->access, 1) + 1);
 }
 
 /**********************************************************************/
@@ -69,7 +69,7 @@ uint op1 (struct opcode_entry *op)
 
 /* handler for 1 op instructions */
 {
-return (decode_ea (src, MODE_NUM(*code), REG_NUM(*code), op->access, 1) + 1);
+return (decode_ea (src, MODE_NUM(lw(code)), REG_NUM(lw(code)), op->access, 1) + 1);
 }
 
 /**********************************************************************/
@@ -80,7 +80,7 @@ uint op1_end (struct opcode_entry *op)
    i.e. jmp rtm */
 {
 instr_end = TRUE;
-return (decode_ea (src, MODE_NUM(*code), REG_NUM(*code), op->access, 1) + 1);
+return (decode_ea (src, MODE_NUM(lw(code)), REG_NUM(lw(code)), op->access, 1) + 1);
 }
 
 /**********************************************************************/
@@ -98,7 +98,7 @@ if (pass3)
   *to++ = (UBYTE)(op->param) + '0';
   *to = 0;
   }
-return (decode_ea (dest, MODE_NUM (*code), REG_NUM (*code), op->access, 1) + 1);
+return (decode_ea (dest, MODE_NUM (lw(code)), REG_NUM (lw(code)), op->access, 1) + 1);
 }
 
 /**********************************************************************/
@@ -111,7 +111,7 @@ if (pass3)
   char *to;
   to = src;
   *to++ = '#';
-  format_x (to, (BYTE)(*code));
+  format_x (to, (BYTE)(lw(code)));
   str_cpy (dest, reg_names [op->param]);
   }
 return (1);
@@ -124,8 +124,8 @@ uint move (struct opcode_entry *op)
 {
 uint used;
 
-used = decode_ea (src, MODE_NUM (*code), REG_NUM (*code), op->access, 1);
-used += decode_ea (dest,((*code >> 6) & 0x7), ((*code >> 9) & 0x7),
+used = decode_ea (src, MODE_NUM (lw(code)), REG_NUM (lw(code)), op->access, 1);
+used += decode_ea (dest,((lw(code) >> 6) & 0x7), ((lw(code) >> 9) & 0x7),
                      op->access, used + 1);
 return (used + 1);
 }
@@ -142,17 +142,17 @@ if (op->param == REG_TO_MEM)
   {
   /* Transfer registers to memory */
   reg_list = src;
-  used = decode_ea (dest, MODE_NUM (*code), REG_NUM (*code), ACC_DATA, 2);
+  used = decode_ea (dest, MODE_NUM (lw(code)), REG_NUM (lw(code)), ACC_DATA, 2);
   }
 else
   {
   reg_list = dest;
-  used = decode_ea (src, MODE_NUM (*code), REG_NUM (*code), ACC_DATA, 2);
+  used = decode_ea (src, MODE_NUM (lw(code)), REG_NUM (lw(code)), ACC_DATA, 2);
   }
 
 if (pass3)
   {
-  format_reg_list (reg_list, *(code + 1), (MODE_NUM (*code) != 4), 0);
+  format_reg_list (reg_list, lw(code + 1), (MODE_NUM (lw(code)) != 4), 0);
   if (*reg_list == 0)
     {
     /* some compilers generate empty reg lists for movem instructions */
@@ -170,7 +170,7 @@ uint imm_b (struct opcode_entry *op)
 
 /* handler for ori.b andi.b eori.b subi.b addi.b cmpi.b callm */
 {
-ULONG instr = *(ULONG*)code;
+ULONG instr = llu(code);
 
 #if 0
 if ((instr & 0xfc0000ff) == 0)  /* if ori.b #0,ea or andi.b #0,ea */
@@ -192,9 +192,9 @@ if (pass3)
   char *to;
   to = src;
   *to++ = '#';
-  format_ux (to, (*(code + 1) & 0xff));
+  format_ux (to, (lw(code + 1) & 0xff));
   }
-return (decode_ea (dest, MODE_NUM(*code), REG_NUM(*code), op->access, 2) + 2);
+return (decode_ea (dest, MODE_NUM(lw(code)), REG_NUM(lw(code)), op->access, 2) + 2);
 }
 
 /**********************************************************************/
@@ -204,7 +204,7 @@ uint imm_w (struct opcode_entry *op)
 /* handler for ori.w andi.w eori.w subi.w addi.w cmpi.w */
 {
 #if 0
-if ((*((ULONG*)code) & 0xfc00ffff) == 0)
+if (llu(code) & 0xfc00ffff) == 0)
   {
   /* ori.w #0,ea and andi.w #0,ea are probably not code */
   instr_bad = TRUE;
@@ -216,9 +216,9 @@ if (pass3)
   char *to;
   to = src;
   *to++ = '#';
-  format_ux (to, *(code + 1));
+  format_ux (to, lw(code + 1));
   }
-return (decode_ea (dest, MODE_NUM(*code), REG_NUM(*code), op->access, 2) + 2);
+return (decode_ea (dest, MODE_NUM(lw(code)), REG_NUM(lw(code)), op->access, 2) + 2);
 }
 
 /**********************************************************************/
@@ -227,10 +227,10 @@ uint imm_l (struct opcode_entry *op)
 
 /* handler for ori.l andi.l eori.l subi.l addi.l cmpi.l */
 {
-register ULONG instr_ext = *(ULONG*)(code + 1);
+ULONG instr_ext = llu(code + 1);
 
 #if 0
-if ((instr_ext == 0) && (*(code) & 0xfc00) == 0)
+if ((instr_ext == 0) && (lw(code) & 0xfc00) == 0)
   {
   /* ori.l #0,ea and andi.l #0,ea are probably not code */
   instr_bad = TRUE;
@@ -263,7 +263,7 @@ else if (pass3)
   else
     format_ulx (to, instr_ext);
   }
-return (decode_ea (dest, MODE_NUM(*code), REG_NUM(*code), op->access, 3) + 3);
+return (decode_ea (dest, MODE_NUM(lw(code)), REG_NUM(lw(code)), op->access, 3) + 3);
 }
 
 /**********************************************************************/
@@ -271,7 +271,7 @@ return (decode_ea (dest, MODE_NUM(*code), REG_NUM(*code), op->access, 3) + 3);
 uint bit_reg (struct opcode_entry *op)
 
 {
-UWORD code_w = *code;
+UWORD code_w = lw(code);
 
 if (pass3)
   str_cpy (src, reg_names [op->param]);
@@ -291,8 +291,8 @@ else
 uint bit_imm (struct opcode_entry *op)
 
 {
-UWORD code_w = *code;
-UWORD data_w = *(code + 1);
+UWORD code_w = lw(code);
+UWORD data_w = lw(code + 1);
 
 #if 0
 if ((data_w & 0xff00) != 0)
@@ -326,14 +326,14 @@ uint srccr (struct opcode_entry *op)
 
 /* ANDI, ORI, EORI to CCR or SR */
 {
-UWORD size = (*code & 0x00C0) >> 6;  /* size: byte=0 word=1 long=2 */
+UWORD size = (lw(code) & 0x00C0) >> 6;  /* size: byte=0 word=1 long=2 */
 /* Only allow word size SR or byte size CCR instructions. */
-if (size == 0 && (*(code + 1) & 0xff00))
+if (size == 0 && (lw(code + 1) & 0xff00))
   return (TRANSFER);
 if (pass3)
   {
-  str_cpy (opcode, opcode_table [*code >> 6].mnemonic);
-  immed (src, (ULONG)(*(code + 1)));
+  str_cpy (opcode, opcode_table [lw(code) >> 6].mnemonic);
+  immed (src, (ULONG)(lw(code + 1)));
   str_cpy (dest, special_regs [!size]);
   }
 return (2);
@@ -364,9 +364,9 @@ uint special (struct opcode_entry *op)
 char *ptr = NULL;
 uint used = 1;
 
-if ((*code & 0x38) == 0x30)
+if ((lw(code) & 0x38) == 0x30)
   {
-  switch (*code & 0xf)
+  switch (lw(code) & 0xf)
     {
     case 0: ptr = "reset";
             break;
@@ -374,7 +374,7 @@ if ((*code & 0x38) == 0x30)
             break;
     case 2: ptr = "stop";
             if (pass3)
-              immed (src, (ULONG)*(code + 1));
+              immed (src, lw(code + 1));
             used = 2;
             break;
     case 3: ptr = "rte";
@@ -387,7 +387,7 @@ if ((*code & 0x38) == 0x30)
             if (pass3)
               {
               src [0] = '#';
-              format_ux (src + 1, (UWORD)*(code + 1));
+              format_ux (src + 1, lw(code + 1));
               }
             used = 2;
             break;
@@ -404,13 +404,13 @@ if ((*code & 0x38) == 0x30)
     str_cpy (opcode, ptr);
   return (used);
   }
-else if ((*code & 0x3e) == 0x3a)          /* MOVEC */
+else if ((lw(code) & 0x3e) == 0x3a)          /* MOVEC */
   {
   short reg_offset;
 
   if (!cpu68010)
     return (TRANSFER);
-  switch (*(code + 1) & 0xfff)
+  switch (lw(code + 1) & 0xfff)
     {
     case 0x000: ptr = special_regs [SFC];
                 break;
@@ -451,74 +451,74 @@ else if ((*code & 0x3e) == 0x3a)          /* MOVEC */
     default : return (TRANSFER);
     }
 
-  reg_offset = (*(code + 1) & 0x8000) ? 8 : 0;
+  reg_offset = (lw(code + 1) & 0x8000) ? 8 : 0;
   if (pass3)
     {
     str_cpy (opcode, "movec");
-    if (*code & 0x1)
+    if (lw(code) & 0x1)
       {
       /* from general register to control register */
       str_cpy (dest, ptr);
-      str_cpy (src, reg_names [((*(code + 1) >> 12) & 0x7) + reg_offset]);
+      str_cpy (src, reg_names [((lw(code + 1) >> 12) & 0x7) + reg_offset]);
       }
     else
       {
       str_cpy (src, ptr);
-      str_cpy (dest, reg_names [((*(code + 1) >> 12) & 0x7) + reg_offset]);
+      str_cpy (dest, reg_names [((lw(code + 1) >> 12) & 0x7) + reg_offset]);
       }
     }
   return (2);
   }
-else if ((*code & 0x30) == 0)
+else if ((lw(code) & 0x30) == 0)
   {
   /* TRAP */
   if (pass3)
     {
     str_cpy (opcode, "trap");
     src [0] = '#';
-    format_ux (src + 1, (UWORD)(*code & 0xf));
+    format_ux (src + 1, lw(code) & 0xf);
     }
   return (1);
   }
-else if ((*code & 0x38) == 0x10)
+else if ((lw(code) & 0x38) == 0x10)
   {
   /* LINK */
   if (pass3)
     {
     str_cpy (opcode, "link");
-    str_cpy (src, reg_names [(*code & 0x7) + 8]);
+    str_cpy (src, reg_names [(lw(code) & 0x7) + 8]);
     dest [0] = '#';
-    format_x (dest + 1, (WORD)*(code + 1));
+    format_x (dest + 1, (WORD)lw(code + 1));
     }
   return (2);
   }
-else if ((*code & 0x38) == 0x18)
+else if ((lw(code) & 0x38) == 0x18)
   {
   /* UNLK */
   if (pass3)
     {
     str_cpy (opcode, "unlk");
-    str_cpy (src, reg_names [(*code & 0x7) + 8]);
+    str_cpy (src, reg_names [(lw(code) & 0x7) + 8]);
     }
   return (1);
   }
-else if ((*code & 0x38) == 0x20)
+else if ((lw(code) & 0x38) == 0x20)
   {
   if (pass3)
     {
     str_cpy (opcode, "move.l");
     str_cpy (dest, special_regs [USP]);
-    str_cpy (src, reg_names [(*code & 0x7) + 8]);
+    str_cpy (src, reg_names [(lw(code) & 0x7) + 8]);
     }
   return (1);
   }
-else if ((*code & 0x38) == 0x28)
+else if ((lw(code) & 0x38) == 0x28)
   {
   if (pass3)
     {
     str_cpy (opcode, "move");
     str_cpy (src, special_regs [USP]);
-    str_cpy (dest, reg_names [(*code & 0x7) + 8]);
+    str_cpy (dest, reg_names [(lw(code) & 0x7) + 8]);
     }
   return (1);
   }
@@ -565,12 +565,12 @@ uint branch (struct opcode_entry *op)
 {
 uint used;
 ULONG ref;
-register LONG offset = (BYTE)(*code & 0xff);
+LONG offset = (BYTE)(lw(code) & 0xff);
 
 if (offset == 0)
   {
   /* word displacement */
-  offset = (WORD)*(code + 1);
+  offset = (WORD)lw(code + 1);
   used = 2;
   }
 else if (offset == -1 && cpu68020)
@@ -578,7 +578,7 @@ else if (offset == -1 && cpu68020)
   /* long displacement */
   if (!cpu68020)
     return (TRANSFER);
-  offset = *(LONG*)(code + 1);
+  offset = lls(code + 1);
   used = 3;
   }
 else
@@ -607,7 +607,7 @@ if (pass3)
 else
   {
   enter_ref (ref, NULL, ACC_CODE);
-  if ((*code & 0xff00) == 0x6000)  /* bra */
+  if ((lw(code) & 0xff00) == 0x6000)  /* bra */
     instr_end = TRUE;  /* NOT on pass3 as it looks better without blank line */
   }
 return (used);
@@ -620,12 +620,12 @@ uint dbranch (struct opcode_entry *op)
 {
 ULONG ref;
 
-//if (*(code + 1) & 0x1)  /* branch to an odd address */
+//if (lw(code + 1) & 0x1)  /* branch to an odd address */
 //  return (TRANSFER);
 
 if (pass3)
-  str_cpy (src, reg_names [*code & 7]);
-ref = current_ref + 2 + (short)(*(code + 1));
+  str_cpy (src, reg_names [lw(code) & 7]);
+ref = current_ref + 2 + (short)(lw(code + 1));
 if (ref < first_ref || ref > last_ref)
   return (TRANSFER);
 if (pass3)
@@ -645,7 +645,7 @@ if (pass3)
   {
   opcode [1] = 's';
   opcode [2] = 0;
-  switch ((*code >> 3) & 0x3)
+  switch ((lw(code) >> 3) & 0x3)
     {
     case 0:  /* Arithmetic shift */
              opcode [0] = 'a';
@@ -663,7 +663,7 @@ if (pass3)
     }
   str_cat (opcode, op->mnemonic);
 
-  if (*code & 0x20)
+  if (lw(code) & 0x20)
     {
     /* shift count is in register */
     str_cpy (src, reg_names [op->param & 0x7]);
@@ -676,7 +676,7 @@ if (pass3)
     format_ux (src + 1, (UWORD)op->param);
     }
 
-  str_cpy (dest, reg_names [REG_NUM (*code)]);
+  str_cpy (dest, reg_names [REG_NUM (lw(code))]);
   }
 return (1);
 }
@@ -692,17 +692,17 @@ char *tmp;
 
 if (pass3)
   {
-  if (*code & 0x8)
+  if (lw(code) & 0x8)
     {
     /* -(Ax) addressing */
-    pre_dec (src, (ushort)(REG_NUM (*code) + 8));
-    pre_dec (dest, (ushort)(((*code >> 9) & 0x7) + 8));
+    pre_dec (src, (ushort)(REG_NUM (lw(code)) + 8));
+    pre_dec (dest, (ushort)(((lw(code) >> 9) & 0x7) + 8));
     }
   else
     {
     /* Dn addressing */
-    str_cpy (src, reg_names [REG_NUM (*code)]);
-    str_cpy (dest, reg_names [((*code >> 9) & 0x7)]);
+    str_cpy (src, reg_names [REG_NUM (lw(code))]);
+    str_cpy (dest, reg_names [((lw(code) >> 9) & 0x7)]);
     }
   }
 
@@ -714,7 +714,7 @@ else
     {
     tmp = dest + strlen (dest);
     *tmp++ = ',';
-    immed (tmp, (ULONG)*(code + 1));
+    immed (tmp, lw(code + 1));
     }
   return (2);
   }
@@ -725,8 +725,8 @@ else
 uint muldivl (struct opcode_entry *op)
 
 {
-UWORD instr1w = *code;
-UWORD instr2w = *(code + 1);
+UWORD instr1w = lw(code);
+UWORD instr2w = lw(code + 1);
 UWORD access = ACC_LONG;
 
 if ((instr2w & 0x800) != 0)
@@ -736,7 +736,7 @@ if (pass3)
   {
   char *tmp_o;
   char *tmp_d;
-  register UWORD dr, dq;
+  UWORD dr, dq;
 
   tmp_o = opcode + 3;
 
@@ -778,10 +778,10 @@ uint bitfield (struct opcode_entry *op)
 {
 uint used;
 UWORD offset, width;
-register char *ptr_ea = NULL, *ptr_dn = NULL;
+char *ptr_ea = NULL, *ptr_dn = NULL;
 
-offset = (*(code + 1) >> 6) & 0x1f;
-width = *(code + 1) & 0x1f;
+offset = (lw(code + 1) >> 6) & 0x1f;
+width = lw(code + 1) & 0x1f;
 
 switch (op->param)
   {
@@ -795,16 +795,16 @@ switch (op->param)
                  break;
   }
 
-used = decode_ea (ptr_ea, MODE_NUM (*code), REG_NUM (*code), ACC_DATA, 2);
+used = decode_ea (ptr_ea, MODE_NUM (lw(code)), REG_NUM (lw(code)), ACC_DATA, 2);
 
 if (pass3)
   {
   ptr_ea = str_cat (ptr_ea, "{");
   if (op->param != SINGLEOP)
-    str_cpy (ptr_dn, reg_names [(*(code + 1) >> 12) & 0x7]);
+    str_cpy (ptr_dn, reg_names [(lw(code + 1) >> 12) & 0x7]);
   }
 
-if (*(code + 1) & 0x800)
+if (lw(code + 1) & 0x800)
   {
   /* Offset specified in register */
   if (offset > 7)
@@ -821,7 +821,7 @@ else if (pass3)
 if (pass3)
   *ptr_ea++ = ':';
 
-if (*(code + 1) & 0x20)
+if (lw(code + 1) & 0x20)
   {
   /* Width specified in register */
   if (width > 7)
@@ -852,8 +852,8 @@ uint scc (struct opcode_entry *op)
 
 {
 if (pass3)
-  str_cat (opcode, conditions [(*code >> 8) & 0xf]);
-return (decode_ea (src, MODE_NUM (*code), REG_NUM (*code), ACC_BYTE, 1) + 1);
+  str_cat (opcode, conditions [(lw(code) >> 8) & 0xf]);
+return (decode_ea (src, MODE_NUM (lw(code)), REG_NUM (lw(code)), ACC_BYTE, 1) + 1);
 }
 
 /**********************************************************************/
@@ -861,33 +861,33 @@ return (decode_ea (src, MODE_NUM (*code), REG_NUM (*code), ACC_BYTE, 1) + 1);
 uint exg (struct opcode_entry *op)
 
 {
-UWORD rx = (*code >> REG2_SHIFT) & 0x7;
+UWORD rx = (lw(code) >> REG2_SHIFT) & 0x7;
 
-if (((*code >> 3) & 0x1f) == 0x8)
+if (((lw(code) >> 3) & 0x1f) == 0x8)
   {
   /* exchange two data registers */
   if (pass3)
     {
     str_cpy (src, reg_names [rx]);
-    str_cpy (dest, reg_names [*code & 0x7]);
+    str_cpy (dest, reg_names [lw(code) & 0x7]);
     }
   }
-else if (((*code >> 3) & 0x1f) == 0x9)
+else if (((lw(code) >> 3) & 0x1f) == 0x9)
   {
   /* exchange two address registers */
   if (pass3)
     {
     str_cpy (src, reg_names [rx + 8]);
-    str_cpy (dest, reg_names [(*code & 0x7) + 8]);
+    str_cpy (dest, reg_names [(lw(code) & 0x7) + 8]);
     }
   }
-else if (((*code >> 3) & 0x1f) == 0x11)
+else if (((lw(code) >> 3) & 0x1f) == 0x11)
   {
   /* exchange an address and a data register */
   if (pass3)
     {
     str_cpy (src, reg_names [rx]);
-    str_cpy (dest, reg_names [(*code & 0x7) + 8]);
+    str_cpy (dest, reg_names [(lw(code) & 0x7) + 8]);
     }
   }
 else
@@ -901,17 +901,17 @@ uint trapcc (struct opcode_entry *op)
 
 {
 if (pass3)
-  str_cat (opcode, conditions [(*code >> 8) & 0xf]);
-if ((*code & 0x7) == 2)
+  str_cat (opcode, conditions [(lw(code) >> 8) & 0xf]);
+if ((lw(code) & 0x7) == 2)
   {
   if (pass3)
-    immed (src, (ULONG)*(code + 1));
+    immed (src, lw(code + 1));
   return (2);
   }
-if ((*code & 0x7) == 3)
+if ((lw(code) & 0x7) == 3)
   {
   if (pass3)
-    immed (src, *(ULONG*)(code + 1));
+    immed (src, llu(code + 1));
   return (3);
   }
 return (1);
@@ -924,7 +924,7 @@ uint chkcmp2 (struct opcode_entry *op)
 {
 if (pass3)
   {
-  if (*(code + 1) & 0x800)
+  if (lw(code + 1) & 0x800)
     {
     /* CHK2 */
     opcode [1] = 'h';
@@ -937,9 +937,9 @@ if (pass3)
     opcode [2] = 'p';
     }
   if (pass3)
-    str_cpy (dest, reg_names [*(code + 1) >> 12]);
+    str_cpy (dest, reg_names [lw(code + 1) >> 12]);
   }
-return (decode_ea (src, MODE_NUM (*code), REG_NUM (*code), op->access, 2) + 2);
+return (decode_ea (src, MODE_NUM (lw(code)), REG_NUM (lw(code)), op->access, 2) + 2);
 }
 
 /**********************************************************************/
@@ -947,15 +947,15 @@ return (decode_ea (src, MODE_NUM (*code), REG_NUM (*code), op->access, 2) + 2);
 uint cas (struct opcode_entry *op)
 
 {
-register char *tmp_s;
+char *tmp_s;
 
 if (pass3)
   {
-  tmp_s = str_cpy (src, reg_names [*(code + 1) & 0x7]);
+  tmp_s = str_cpy (src, reg_names [lw(code + 1) & 0x7]);
   *tmp_s++ = ',';
-  str_cpy (tmp_s, reg_names [(*(code + 1) >> 6) & 0x7]);
+  str_cpy (tmp_s, reg_names [(lw(code + 1) >> 6) & 0x7]);
   }
-return (decode_ea (dest, MODE_NUM (*code), REG_NUM (*code), op->access, 2) + 2);
+return (decode_ea (dest, MODE_NUM (lw(code)), REG_NUM (lw(code)), op->access, 2) + 2);
 }
 
 /**********************************************************************/
@@ -965,13 +965,13 @@ uint cas2 (struct opcode_entry *op)
 {
 if (pass3)
   {
-  sprintf (src, "%s:%s,%s:%s", reg_names [*(code + 1) & 0x7],
-                               reg_names [*(code + 2) & 0x7],
-                               reg_names [(*(code + 1) >> 6) & 0x7],
-                               reg_names [(*(code + 2) >> 6) & 0x7]);
+  sprintf (src, "%s:%s,%s:%s", reg_names [lw(code + 1) & 0x7],
+                               reg_names [lw(code + 2) & 0x7],
+                               reg_names [(lw(code + 1) >> 6) & 0x7],
+                               reg_names [(lw(code + 2) >> 6) & 0x7]);
 
-  sprintf (dest, "(%s):(%s)",  reg_names [*(code + 1) >> 12],
-                               reg_names [*(code + 2) >> 12]);
+  sprintf (dest, "(%s):(%s)",  reg_names [lw(code + 1) >> 12],
+                               reg_names [lw(code + 2) >> 12]);
   }
 return (3);
 }
@@ -983,7 +983,7 @@ uint moves (struct opcode_entry *op)
 {
 char *reg, *ea;
 
-if (*(code + 1) & 0x800)
+if (lw(code + 1) & 0x800)
   {
   reg = src;
   ea = dest;
@@ -995,8 +995,8 @@ else
   }
 
 if (pass3)
-  str_cpy (reg, reg_names [(*(code + 1) >> 12) & 0xf]);
-return (decode_ea (ea, MODE_NUM (*code), REG_NUM (*code), op->access, 2) + 2);
+  str_cpy (reg, reg_names [(lw(code + 1) >> 12) & 0xf]);
+return (decode_ea (ea, MODE_NUM (lw(code)), REG_NUM (lw(code)), op->access, 2) + 2);
 }
 
 /**********************************************************************/
@@ -1024,7 +1024,7 @@ if (pass3)
                    break;
     }
   }
-return (decode_ea (ea, MODE_NUM (*code), REG_NUM (*code), ACC_WORD, 1) + 1);
+return (decode_ea (ea, MODE_NUM (lw(code)), REG_NUM (lw(code)), ACC_WORD, 1) + 1);
 }
 
 /**********************************************************************/
@@ -1034,8 +1034,8 @@ uint cmpm (struct opcode_entry *op)
 {
 if (pass3)
   {
-  post_inc (src, (*code & 0xf));
-  post_inc (dest, ((*code >> 9) & 0xf));
+  post_inc (src, (lw(code) & 0xf));
+  post_inc (dest, ((lw(code) >> 9) & 0xf));
   }
 return (1);
 }
@@ -1049,12 +1049,12 @@ char *dn, *an;
 
 if (pass3)
   {
-  if (*code & 0x40)
+  if (lw(code) & 0x40)
     str_cat (opcode, ".l");
   else
     str_cat (opcode, ".w");
   }
-if (*code & 0x80)
+if (lw(code) & 0x80)
   {
   /* Transfer to memory */
   an = dest;
@@ -1069,8 +1069,8 @@ else
 
 if (pass3)
   {
-  str_cpy (dn, reg_names [(*code >> 9) & 0x7]);
-  disp_an (an, ((*code & 0x7) + 8), *(code + 1));
+  str_cpy (dn, reg_names [(lw(code) >> 9) & 0x7]);
+  disp_an (an, ((lw(code) & 0x7) + 8), lw(code + 1));
   }
 return (2);
 }
@@ -1083,7 +1083,7 @@ uint bkpt (struct opcode_entry *op)
 if (pass3)
   {
   src [0] = '#';
-  format_ux (src + 1, (UWORD)(*code & 0x7));
+  format_ux (src + 1, (UWORD)(lw(code) & 0x7));
   }
 return (1);
 }
@@ -1096,8 +1096,8 @@ uint link_l (struct opcode_entry *op)
 if (pass3)
   {
   dest [0] = '#';
-  format_ulx (dest + 1, *(ULONG*)(code + 1));
-  str_cpy (src, reg_names [REG_NUM (*code) + 8]);
+  format_ulx (dest + 1, llu(code + 1));
+  str_cpy (src, reg_names [REG_NUM (lw(code)) + 8]);
   }
 return (3);
 }
@@ -1109,20 +1109,20 @@ uint move16 (struct opcode_entry *op)
 {
 char *tmp;
 
-if ((*code & 0x20) && ((*(code + 1) & 0x8fff) == 0x8000))
+if ((lw(code) & 0x20) && ((lw(code + 1) & 0x8fff) == 0x8000))
   {  /* post increment mode for src and dest */
   if (pass3)
     {
-    post_inc (src, (*code & 0x7) + 8);
-    post_inc (dest, ((*(code + 1) >> 12) & 0x7) + 8);
+    post_inc (src, (lw(code) & 0x7) + 8);
+    post_inc (dest, ((lw(code + 1) >> 12) & 0x7) + 8);
     }
   return (2);
   }
-else if ((*code & 0x20) == 0)
+else if ((lw(code) & 0x20) == 0)
   {
   if (pass3)
     {
-    if (*code & 0x8)    
+    if (lw(code) & 0x8)    
       {
       tmp = dest;
       decode_ea (src, 7, 1, ACC_LONG, 1);
@@ -1132,10 +1132,10 @@ else if ((*code & 0x20) == 0)
       tmp = src;
       decode_ea (dest, 7, 1, ACC_LONG, 1);
       }
-    if (*code & 0x10)
-      indirect (tmp, (*code & 0x7) + 8);
+    if (lw(code) & 0x10)
+      indirect (tmp, (lw(code) & 0x7) + 8);
     else
-      post_inc (tmp, (*code & 0x7) + 8);
+      post_inc (tmp, (lw(code) & 0x7) + 8);
     }
   return (3);
   }
@@ -1151,11 +1151,11 @@ char *tmp_o;
 
 if (pass3)
   {
-  if (*code & 0x20)
+  if (lw(code) & 0x20)
     tmp_o = str_cpy (opcode, "cpush");
   else
     tmp_o = str_cpy (opcode, "cinv");
-  switch ((*code >> 3) & 0x3)
+  switch ((lw(code) >> 3) & 0x3)
     {
     case 1: *tmp_o++ = 'l'; break;
     case 2: *tmp_o++ = 'p'; break;
@@ -1171,8 +1171,8 @@ if (pass3)
     case 3: str_cpy (src, "bc"); break;
     }
 
-  if (((*code >> 3) & 0x3) != 0x3)      /* not all --> page or line */
-    indirect (dest, (REG_NUM (*code) + 8));
+  if (((lw(code) >> 3) & 0x3) != 0x3)      /* not all --> page or line */
+    indirect (dest, (REG_NUM (lw(code)) + 8));
   }
 return (1);
 }
index 3a7830863d488fbfc39783617b5559b627f015a5..1605503984e83f8a5d8022ffbfd0da921e05f6e4 100644 (file)
@@ -35,11 +35,11 @@ uint fpu (struct opcode_entry *op)
 uint used;
 char *reg_list,
      *ea;
-register char *tmp = NULL;
+char *tmp = NULL;
 uint num_regs;
-register UWORD instr_word1;
-register UWORD instr_word2;
-register UWORD mode;
+UWORD instr_word1;
+UWORD instr_word2;
+UWORD mode;
 
 instr_word1 = *code;
 instr_word2 = *(code + 1);
index 0e3dbb824784532d18c3baa23ec74cf538dac6db..5b2aab57290666dd2e96ec16a32e6720a3a049a4 100644 (file)
@@ -43,7 +43,7 @@
 uint plpa60 (struct opcode_entry *op)
 
 {
-indirect (src, (REG_NUM (*code) + 8));
+indirect (src, (REG_NUM (lw(code)) + 8));
 return (1);
 }
 
@@ -54,15 +54,15 @@ uint pflush40 (struct opcode_entry *op)
 {
 if (pass3)
   {
-  switch ((*code >> 3) & 0x3)
+  switch ((lw(code) >> 3) & 0x3)
     {
     case 0: str_cat (opcode, "n");  break;
     case 1:                        break;
     case 2: str_cat (opcode, "an"); break;
     case 3: str_cat (opcode, "a");  break;
     }
-  if ((*code & 0x10) == 0)
-    indirect (src, (REG_NUM (*code) + 8));
+  if ((lw(code) & 0x10) == 0)
+    indirect (src, (REG_NUM (lw(code)) + 8));
   }
 return (1);
 }
@@ -74,11 +74,11 @@ uint ptest40 (struct opcode_entry *op)
 {
 if (pass3)
   {
-  if (*code & 0x20)
+  if (lw(code) & 0x20)
     str_cat (opcode, "r");
   else
     str_cat (opcode, "w");
-  indirect (src, (REG_NUM (*code) + 8));
+  indirect (src, (REG_NUM (lw(code)) + 8));
   }
 return (1);
 }
@@ -88,13 +88,13 @@ return (1);
 PRIVATE BOOL eval_fc (char *to)
 
 {
-if ((*(code + 1) & 0x0018) == 0x0010)
-  immed (to, (ULONG)(*(code + 1) & 0x7));
-else if ((*(code + 1) & 0x0018) == 0x0008)
-  str_cpy (to, reg_names [*(code + 1) & 0x7]);
-else if ((*(code + 1) & 0x001f) == 0)
+if ((lw(code + 1) & 0x0018) == 0x0010)
+  immed (to, (ULONG)(lw(code + 1) & 0x7));
+else if ((lw(code + 1) & 0x0018) == 0x0008)
+  str_cpy (to, reg_names [lw(code + 1) & 0x7]);
+else if ((lw(code + 1) & 0x001f) == 0)
   str_cpy (to, special_regs [SFC]);
-else if ((*(code + 1) & 0x001f) == 0x0001)
+else if ((lw(code + 1) & 0x001f) == 0x0001)
   str_cpy (to, special_regs [DFC]);
 else return (FALSE);
 return (TRUE);
@@ -106,12 +106,12 @@ uint mmu30 (struct opcode_entry *op)
 
 {
 /* Test for PTEST instruction */
-if (((*(code + 1) & 0xfc00) == 0x9c00) && ((*code & 0x003f) != 0))
+if (((lw(code + 1) & 0xfc00) == 0x9c00) && ((lw(code) & 0x003f) != 0))
   return ptest30 (op);
-else if (!(*(code + 1) & 0x8000))
+else if (!(lw(code + 1) & 0x8000))
   {
   struct opcode_sub_entry *subop;
-  subop = &(mmu_opcode_table [*(code + 1) >> 10]);
+  subop = &(mmu_opcode_table [lw(code + 1) >> 10]);
   if (pass3)
     str_cpy (opcode, subop->mnemonic);
   return ((*subop->handler) (subop));
@@ -124,20 +124,20 @@ return (TRANSFER);
 uint ptest30 (struct opcode_entry *op)
 
 {
-if ((*code & 0x003f) == 0)         /* Check for illegal mode */
+if ((lw(code) & 0x003f) == 0)         /* Check for illegal mode */
   return (TRANSFER);
 
 str_cpy (opcode, "ptestwfc");
-if (*(code + 1) & 0x0200)
+if (lw(code + 1) & 0x0200)
   opcode [5] = 'R';
 if (!eval_fc (dest))     
   return (TRANSFER);
-if (*(code + 1) & 0x0100)
+if (lw(code + 1) & 0x0100)
   {
   str_cat (dest, ",");
-  str_cat (dest, reg_names [(*(code + 1) >> 5) & 0x7]);
+  str_cat (dest, reg_names [(lw(code + 1) >> 5) & 0x7]);
   }
-return (2 + decode_ea (dest, MODE_NUM (*code), REG_NUM (*code), ACC_UNKNOWN, 2));
+return (2 + decode_ea (dest, MODE_NUM (lw(code)), REG_NUM (lw(code)), ACC_UNKNOWN, 2));
 }
 
 /**********************************************************************
@@ -149,21 +149,21 @@ uint pfl_or_ld (struct opcode_sub_entry *op)
 /* Tests for PLOAD instruction first. Otherwise it's a standard
    PFLUSH instruction */
 {
-if ((*(code + 1) & 0x00e0) != 0x0000)
+if ((lw(code + 1) & 0x00e0) != 0x0000)
   return (pflush30 (op));
 
-if ((*code & 0x3f) == 0)
+if ((lw(code) & 0x3f) == 0)
   return (TRANSFER);
 
 str_cpy (opcode, "pload");
-if (*(code + 1) & 0x0200)
+if (lw(code + 1) & 0x0200)
   str_cat (opcode, "r");
 else
   str_cat (opcode, "w");
 
 if (!eval_fc (src))
   return (TRANSFER);
-return (2 + decode_ea (dest, MODE_NUM (*code), REG_NUM (*code), ACC_UNKNOWN, 2));
+return (2 + decode_ea (dest, MODE_NUM (lw(code)), REG_NUM (lw(code)), ACC_UNKNOWN, 2));
 }
 
 /**********************************************************************/
@@ -174,7 +174,7 @@ uint pflush30 (struct opcode_sub_entry *op)
 switch (op->param)
   {
   case 1: /* PFLUSHA */
-          if (*(code + 1) != 0x2400)
+          if (lw(code + 1) != 0x2400)
             return (TRANSFER);
           str_cat (opcode, "a");
           return (2);
@@ -182,15 +182,15 @@ switch (op->param)
           /* EA ignored !?! */
           if (!eval_fc (src))
             return (TRANSFER);
-          immed (dest, (ULONG)((*(code + 1) >> 5) & 0x7));
+          immed (dest, (ULONG)((lw(code + 1) >> 5) & 0x7));
           return (2);
 
   case 6: /* PFLUSH FC,MASK,EA */
           if (!eval_fc (src))
             return (TRANSFER);
           str_cat (src, ",");
-          immed (src + strlen (src), (ULONG)((*(code + 1) >> 5) & 0x7));
-          return (2 + decode_ea (dest, MODE_NUM (*code), REG_NUM (*code),
+          immed (src + strlen (src), (ULONG)((lw(code + 1) >> 5) & 0x7));
+          return (2 + decode_ea (dest, MODE_NUM (lw(code)), REG_NUM (lw(code)),
                                  ACC_UNKNOWN, 2));
   }
 return (TRANSFER);
@@ -204,13 +204,13 @@ uint pmove30 (struct opcode_sub_entry *op)
 char *ea,
      *reg;
 
-if ((*code & 0x003f) == 0)
+if ((lw(code) & 0x003f) == 0)
   return (TRANSFER);
 
-if ((*(code + 1) & 0xff) || ((*(code + 1) & 0x0010) && op->param == MMUSR))
+if ((lw(code + 1) & 0xff) || ((lw(code + 1) & 0x0010) && op->param == MMUSR))
   return (TRANSFER);
 
-if (*(code + 1) & 0x0200)
+if (lw(code + 1) & 0x0200)
   {
   ea = dest;
   reg = src;
@@ -220,9 +220,9 @@ else
   ea = src;
   reg = dest;
   }
-if ((*(code + 1) & 0x0100))
+if ((lw(code + 1) & 0x0100))
   str_cat (opcode, "fd");
 
 str_cpy (reg, special_regs [op->param]);
-return (2 + decode_ea (ea, MODE_NUM (*code), REG_NUM (*code), ACC_LONG, 2));
+return (2 + decode_ea (ea, MODE_NUM (lw(code)), REG_NUM (lw(code)), ACC_LONG, 2));
 }
index 2288acac979489ed1ab0b022fb8d3f7afb4e4ddc..c4694609d0eeb7bfc207ba01a850bfa2eedfc50a 100644 (file)
@@ -86,7 +86,7 @@ return (dest - 1);
 BOOL is_str (char *maybe_string, uint max_len)
 
 {
-register uchar *tmp_str;
+uchar *tmp_str;
 uchar *last_char;
 
 tmp_str = (uchar*) maybe_string;
@@ -104,7 +104,7 @@ int str_len (char *maybe_string, uint max_len)
 
 /* str_len() returns string length or 0 if not a valid string */
 {
-register uchar *tmp_str;
+uchar *tmp_str;
 uchar *last_char;
 
 tmp_str = (uchar*) maybe_string;
@@ -172,8 +172,8 @@ char *format_line (char *to, BOOL commented, int instr_words)
 /* format opcode, src and dest to to */
 {
 char *tmp_str;
-register int i;
-register char reg_space_char = space_char;
+int i;
+char reg_space_char = space_char;
 
 tmp_str = to;
 i = OPCODE_COL;
@@ -284,7 +284,7 @@ if (commented && comment)
       for (i = 0; i < instr_words; i++)
         {
         *to++ = ' ';
-        to = format_ulx_digits (to, *(code + i), 4L);
+        to = format_ulx_digits (to, lw(code + i), 4L);
         }
       }
     }
@@ -464,8 +464,8 @@ return (to);
 void format_reg_list (char *to, ushort list, BOOL incr_list, ushort reglist_offset)
 
 {
-register int i;
-register long mylist;                 /* list in order a7-a0/d7-d0 */
+int i;
+long mylist;                 /* list in order a7-a0/d7-d0 */
 short last_set;
 BOOL regs_used;
 
@@ -644,7 +644,7 @@ void disp_pc_indexed (char *to, ULONG ref, BYTE disp, ushort index_reg,
 if (!old_style)
   *to++ = '(';
 
-if (!((*code & 0xffc0) == 0x4ec0))  /* not jmp */
+if (!((lw(code) & 0xffc0) == 0x4ec0))  /* not jmp */
   to = gen_label_ref (to, ref);
 else if (!(disp == 0 && optimize))
   to = format_x (to, (WORD)disp);
@@ -721,10 +721,10 @@ UWORD full_ext_w,
       post_indexed,
       no_index_reg,
       no_base_reg;
-WORD *next_instr_ext;
+UWORD *next_instr_ext;
 
-full_ext_w = *instr_ext;
-next_instr_ext = (WORD*)instr_ext + 1;
+full_ext_w = lw(instr_ext);
+next_instr_ext = instr_ext + 1;
 
 no_index_reg = (full_ext_w & 0x0040);  /*  %1000000, bit #6 */
 
@@ -754,13 +754,13 @@ if (bd_size == 1)  /* .w? */
     {
     ULONG b_offset = current_ref + ((instr_ext - code)  << 1);
     if (pass2)
-      enter_ref (b_offset + *(next_instr_ext++), NULL, ACC_UNKNOWN);
+      enter_ref (b_offset + (WORD)lw(next_instr_ext++), NULL, ACC_UNKNOWN);
     else
-      to = gen_label_ref (to, b_offset + *(next_instr_ext++));
+      to = gen_label_ref (to, b_offset + (WORD)lw(next_instr_ext++));
     }
   else
     {
-    to = format_x (to, *(next_instr_ext++));
+    to = format_x (to, lw(next_instr_ext++));
     if (!optimize)
       {
       *to++ = '.';
@@ -774,20 +774,20 @@ else if (bd_size == 2)  /* .l? */
   if (FLAGS_RELOC (b_offset + 2))  /* relocated absolute (to a label) */
     {
     if (pass2)
-      enter_ref (*((LONG*)(next_instr_ext)), NULL, ACC_UNKNOWN);
+      enter_ref (lls(next_instr_ext), NULL, ACC_UNKNOWN);
     else
-      to = gen_label_ref (to, *((LONG*)(next_instr_ext)));
+      to = gen_label_ref (to, llu(next_instr_ext));
     }
   else if (mode == 7 && !no_base_reg)  /* pc relative && pc not suppressed? */
     {
     if (pass2)
-      enter_ref (b_offset + *((LONG*)(next_instr_ext)), NULL, ACC_UNKNOWN);
+      enter_ref (b_offset + lls(next_instr_ext), NULL, ACC_UNKNOWN);
     else
-      to = gen_label_ref (to, b_offset + *((LONG*)(next_instr_ext)));
+      to = gen_label_ref (to, b_offset + lls(next_instr_ext));
     }
   else
     {
-    to = format_lx (to, *((LONG*)(next_instr_ext)));
+    to = format_lx (to, llu(next_instr_ext));
     if (!optimize)
       {
       *to++ = '.';
@@ -834,7 +834,7 @@ if (!post_indexed && od_size >= 0)
 if (od_size == 1)  /* .w? */
   {
   *to++ = ',';
-  to = format_x (to, *(next_instr_ext++));
+  to = format_x (to, lw(next_instr_ext++));
   if (!optimize)
     {
     *to++ = '.';
@@ -844,7 +844,7 @@ if (od_size == 1)  /* .w? */
 else if (od_size == 2)  /* .l? */
   {
   *to++ = ',';
-  to = format_lx (to, *((LONG*)(next_instr_ext)));
+  to = format_lx (to, llu(next_instr_ext));
   if (!optimize)
     {
     *to++ = '.';
@@ -997,14 +997,14 @@ uint disasm_instr(UWORD *instr, char *out, int cpu_lvl)
        instr_end = FALSE; /* global variable TRUE at rts, bra, jmp, etc. */
        code = instr;      /* global variable */
 
-       for (op = &(opcode_table[(instr[0]) >> 6]);
+       for (op = &(opcode_table[(lw(instr)) >> 6]);
                size == 0;
                op = &(opcode_table[op->chain]))
        {
                /* Test for validity of ea_mode */
-               if (op->modes & (1 << MODE_NUM(*instr)))
+               if (op->modes & (1 << MODE_NUM(lw(instr))))
                {
-                       if ((MODE_NUM(*instr) == 7) && !(op->submodes & (1 << REG_NUM(*instr))))
+                       if ((MODE_NUM(lw(instr)) == 7) && !(op->submodes & (1 << REG_NUM(lw(instr)))))
                                continue;
 
                        if (pass3 && op->mnemonic != 0)
index d2eaf9b3cb7fddd65e14e95a834f6972e63e54d1..4431325170c5a6560064dfcc24c74ffb1027b072 100644 (file)
@@ -272,6 +272,24 @@ static int is_valid_test_addr_readwrite(uae_u32 a)
                (a >= test_memory_addr && a < test_memory_end);
 }
 
+uae_u16 lw(uae_u16 *p)
+{
+       if (!is_valid_test_addr_read((uae_u32)p) || !is_valid_test_addr_read(((uae_u32)p) + 1))
+               return 0;
+       return *p;
+}
+uae_u32 llu(uae_u16 *p)
+{
+       if (!is_valid_test_addr_read((uae_u32)p) || !is_valid_test_addr_read(((uae_u32)p) + 1))
+               return 0;
+       if (!is_valid_test_addr_read(((uae_u32)p) + 2) || !is_valid_test_addr_read(((uae_u32)p) + 3))
+               return p[0] << 16;
+       return *(uae_u32*)p;
+}
+uae_s32 lls(uae_u16 *p)
+{
+       return (uae_s32)llu(p);
+}
 
 static void endinfo(void)
 {
@@ -1212,6 +1230,13 @@ static void addinfo_bytes(char *name, uae_u8 *src, uae_u32 address, int offset,
 
 extern uae_u16 disasm_instr(uae_u16 *, char *, int);
 
+static short is_valid_word(uae_u8 *p)
+{
+       if (!is_valid_test_addr_read((uae_u32)p) || !is_valid_test_addr_read((uae_u32)p + 1))
+               return 0;
+       return 1;
+}
+
 static void out_disasm(uae_u8 *mem)
 {
        uae_u16 *code;
@@ -1229,7 +1254,7 @@ static void out_disasm(uae_u8 *mem)
        int lines = 0;
        while (lines++ < 7) {
                int v = 0;
-               if (!is_valid_test_addr_read((uae_u32)p) || !is_valid_test_addr_read((uae_u32)p + 1)) {
+               if (!is_valid_word(p)) {
                        sprintf(outbp, "%08x -- INACCESSIBLE --\n", (uae_u32)p);
                        outbp += strlen(outbp);
                        break;
@@ -1240,7 +1265,11 @@ static void out_disasm(uae_u8 *mem)
                        sprintf(outbp, "%08x ", (uae_u32)p);
                        outbp += strlen(outbp);
                        for (int i = 0; i < v; i++) {
-                               uae_u16 v = (p[i * 2 + 0] << 8) | (p[i * 2 + 1]);
+                               uae_u8 *pb = &p[i * 2 + 0];
+                               uae_u16 v = 0;
+                               if (is_valid_word(pb)) {
+                                       v = (pb[0] << 8) | (pb[1]);
+                               }
                                sprintf(outbp, "%04x ", v);
                                outbp += strlen(outbp);
                                if (v == 0x4e71)
@@ -1248,6 +1277,8 @@ static void out_disasm(uae_u8 *mem)
                        }
                        sprintf(outbp, " %s\n", tmpbuffer);
                        outbp += strlen(outbp);
+                       if (!is_valid_word((uae_u8*)(code + offset)))
+                               break;
                        if (v <= 0 || code[offset] == 0x4afc)
                                break;
                        while (v > 0) {
@@ -1256,6 +1287,8 @@ static void out_disasm(uae_u8 *mem)
                                v--;
                        }
                } else {
+                       if (!is_valid_test_addr_read((uae_u32)code))
+                               break;
                        sprintf(outbp, "%08x %02x\n", (uae_u32)code, *((uae_u8*)code));
                        code = (uae_u16*)(((uae_u32)code) + 1);
                        p++;