[comp.os.minix] fix for dis88 using 1.1 compiler

bob@dhw68k.cts.com (Bob Best) (10/31/88)

For the benefit of users who are,
1) temporarily (permanently?!) stuck with the 1.1 Minix compiler,
2) willing to massacre their dis88 sources,
3) desperate for the use of an excellent disassembler,
I have included patches that should allow successful compilation
of a dis88 binary.

Bob
-------------------------patches for dis88 on 1.1 Minix compiler-------
Index: disfp.c
*** /bram0/dis88.old/./disfp.c	Mon Oct 10 21:00:12 1988
--- ./disfp.c	Sun Oct 30 11:10:04 1988
***************
*** 148,154 ****
        return;
        }
  
!    printf("%s\t%d\n",optab[j].text,k);
  
     objout();
  
--- 148,157 ----
        return;
        }
  
!    if (j <= 0x7f)
! 	   printf("%s\t%d\n",optab1[j].text,k);
!    else
! 	   printf("%s\t%d\n",optab2[j-0x80].text,k);
  
     objout();
  

Index: dishand.c
*** /bram0/dis88.old/./dishand.c	Mon Oct 10 21:00:14 1988
--- ./dishand.c	Sun Oct 30 11:10:04 1988
***************
*** 108,119 ****
     segflg = 0;
  
     printf("\t.byte\t0x%02.2x",j);
  
-    if (optab[j].min || optab[j].max)
-       putchar('\n');
-    else
-       printf("\t\t| unimplemented opcode\n");
- 
  }/* * * * * * * * * * * END OF dfhand() * * * * * * * * * * */
  
   /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
--- 108,126 ----
     segflg = 0;
  
     printf("\t.byte\t0x%02.2x",j);
+    if (j <= 0x7f) {
+ 	   if (optab1[j].min || optab1[j].max)
+ 	      putchar('\n');
+ 	   else
+ 	      printf("\t\t| unimplemented opcode\n");
+    }
+    else {
+ 	   if (optab2[j-0x80].min || optab2[j-0x80].max)
+ 	      putchar('\n');
+ 	   else
+ 	      printf("\t\t| unimplemented opcode\n");
+    }
  
  }/* * * * * * * * * * * END OF dfhand() * * * * * * * * * * */
  
   /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
***************
*** 140,146 ****
      || (j == 0x3e))                             /* seg ds   */
        segflg = 2;
  
!    printf("%s\n",optab[j].text);
  
     objout();
  
--- 147,156 ----
      || (j == 0x3e))                             /* seg ds   */
        segflg = 2;
  
!    if (j <= 0x7f)
! 	   printf("%s\n",optab1[j].text);
!    else
! 	   printf("%s\n",optab2[j-0x80].text);
  
     objout();
  
***************
*** 172,193 ****
        case 1 :
        case 2 :
        case 3 :
!          printf("%s\t",optab[j].text);
           FETCH(k);
           printf("%s\n",mtrans(j,k,TR_STD));
           break;
        case 4 :
           FETCH(k);
!          printf("%s\tal,*0x%02.2x\n",optab[j].text,k);
           break;
        case 5 :
           FETCH(m);
           FETCH(n);
           k = (n << 8) | m;
!          if (lookext((long)(k),(PC - 1),b))
!             printf("%s\tax,#%s\n",optab[j].text,b);
!          else
!             printf("%s\tax,#0x%04.4x\n",optab[j].text,k);
           break;
        default :
           dfhand(j);
--- 182,217 ----
        case 1 :
        case 2 :
        case 3 :
! 	 if (j <= 0x7f)
! 		 printf("%s\t",optab1[j].text);
! 	 else
! 		 printf("%s\t",optab2[j-0x80].text);
           FETCH(k);
           printf("%s\n",mtrans(j,k,TR_STD));
           break;
        case 4 :
           FETCH(k);
! 	 if (j <= 0x7f)
! 		 printf("%s\tal,*0x%02.2x\n",optab1[j].text,k);
! 	 else
! 		 printf("%s\tal,*0x%02.2x\n",optab2[j-0x80].text,k);
           break;
        case 5 :
           FETCH(m);
           FETCH(n);
           k = (n << 8) | m;
!          if (lookext((long)(k),(PC - 1),b)) {
! 		 if (j <= 0x7f)
! 		    printf("%s\tax,#%s\n",optab1[j].text,b);
! 		 else
! 		    printf("%s\tax,#%s\n",optab2[j-0x80].text,b);
! 	 }
!          else {
! 		 if (j <= 0x7f)
! 		    printf("%s\tax,#0x%04.4x\n",optab1[j].text,k);
! 		 else
! 		    printf("%s\tax,#0x%04.4x\n",optab2[j-0x80].text,k);
! 	 }
           break;
        default :
           dfhand(j);
***************
*** 226,234 ****
  
     k |= m;
  
!    printf("%s\t%s\t\t| loc %05.5lx\n",optab[j].text,
!     lookup((PC + k + 1L),N_TEXT,LOOK_REL,-1L),
!     (PC + k + 1L));
  
     objout();
  
--- 250,263 ----
  
     k |= m;
  
!    if (j <= 0x7f)
! 	   printf("%s\t%s\t\t| loc %05.5lx\n",optab1[j].text,
! 	    lookup((PC + k + 1L),N_TEXT,LOOK_REL,-1L),
! 	    (PC + k + 1L));
!    else
! 	   printf("%s\t%s\t\t| loc %05.5lx\n",optab2[j-0x80].text,
! 	    lookup((PC + k + 1L),N_TEXT,LOOK_REL,-1L),
! 	    (PC + k + 1L));
  
     objout();
  
***************
*** 405,411 ****
        else
           m |= 0x02;
  
!    printf("%s\t%s\n",optab[j].text,mtrans(m,k,TR_STD));
  
     objout();
  
--- 434,443 ----
        else
           m |= 0x02;
  
!    if (j <= 0x7f)
! 	   printf("%s\t%s\n",optab1[j].text,mtrans(m,k,TR_STD));
!    else
! 	   printf("%s\t%s\n",optab2[j-0x80].text,mtrans(m,k,TR_STD));
  
     objout();
  
***************
*** 436,442 ****
        return;
        }
  
!    printf("%s\t%s\n",optab[j].text,mtrans(j,k,TR_SEG));
  
     objout();
  
--- 468,477 ----
        return;
        }
  
!    if (j <= 0x7f)
! 	   printf("%s\t%s\n",optab1[j].text,mtrans(j,k,TR_SEG));
!    else
! 	   printf("%s\t%s\n",optab2[j-0x80].text,mtrans(j,k,TR_SEG));
  
     objout();
  
***************
*** 471,477 ****
        return;
        }
  
!    printf("%s\t",optab[j].text);
  
     a = mtrans((j & 0xfd),k,TR_STD);
  
--- 506,515 ----
        return;
        }
  
!    if (j <= 0x7f)
! 	   printf("%s\t",optab1[j].text);
!    else
! 	   printf("%s\t",optab2[j-0x80].text);
  
     a = mtrans((j & 0xfd),k,TR_STD);
  
***************
*** 509,515 ****
  
     objini(j);
  
!    printf("%s\t",optab[j].text);
  
     FETCH(m);
     FETCH(n);
--- 547,556 ----
  
     objini(j);
  
!    if (j <= 0x7f)
! 	   printf("%s\t",optab1[j].text);
!    else
! 	   printf("%s\t",optab2[j-0x80].text);
  
     FETCH(m);
     FETCH(n);
***************
*** 545,551 ****
  
     objini(j);
  
!    printf("%s",optab[j].text);
  
     if (j & 8)
        {
--- 586,595 ----
  
     objini(j);
  
!    if (j <= 0x7f)
! 	   printf("%s",optab1[j].text);
!    else
! 	   printf("%s",optab2[j-0x80].text);
  
     if (j & 8)
        {
***************
*** 592,598 ****
  
     m = (n << 8) | m;
  
!    printf("%s\t",optab[j].text);
  
     if (j & 2)
        printf("%s,%s\n",
--- 636,645 ----
  
     m = (n << 8) | m;
  
!    if (j <= 0x7f)
! 	   printf("%s\t",optab1[j].text);
!    else
! 	   printf("%s\t",optab2[j-0x80].text);
  
     if (j & 2)
        printf("%s,%s\n",
***************
*** 626,632 ****
  
     objini(j);
  
!    printf("%s\t%s,",optab[j].text,REGS[(j & 1) << 3]);
  
     FETCH(m);
  
--- 673,682 ----
  
     objini(j);
  
!    if (j <= 0x7f)
! 	   printf("%s\t%s,",optab1[j].text,REGS[(j & 1) << 3]);
!    else
! 	   printf("%s\t%s,",optab2[j-0x80].text,REGS[(j & 1) << 3]);
  
     FETCH(m);
  
***************
*** 680,686 ****
  
     m = (n << 8) | m;
  
!    printf("%s\t#0x%04.4x\n",optab[j].text,m);
  
     objout();
  
--- 730,739 ----
  
     m = (n << 8) | m;
  
!    if (j <= 0x7f)
! 	   printf("%s\t#0x%04.4x\n",optab1[j].text,m);
!    else
! 	   printf("%s\t#0x%04.4x\n",optab2[j-0x80].text,m);
  
     objout();
  
***************
*** 714,720 ****
        return;
        }
  
!    printf("%s",optab[j].text);
  
     if ( ! (j & 1) )
        putchar('b');
--- 767,776 ----
        return;
        }
  
!    if (j <= 0x7f)
! 	   printf("%s",optab1[j].text);
!    else
! 	   printf("%s",optab2[j-0x80].text);
  
     if ( ! (j & 1) )
        putchar('b');
***************
*** 817,823 ****
        return;
        }
  
!    printf("%s\n",optab[j].text);
  
     objout();
  
--- 873,882 ----
        return;
        }
  
!    if (j <= 0x7f)
! 	   printf("%s\n",optab1[j].text);
!    else
! 	   printf("%s\n",optab2[j-0x80].text);
  
     objout();
  
***************
*** 843,849 ****
  
     FETCH(k);
  
!    printf("%s\t0x%02.2x\n",optab[j].text,k);
  
     objout();
  
--- 902,911 ----
  
     FETCH(k);
  
!    if (j <= 0x7f)
! 	   printf("%s\t0x%02.2x\n",optab1[j].text,k);
!    else
! 	   printf("%s\t0x%02.2x\n",optab2[j-0x80].text,k);
  
     objout();
  
***************
*** 873,881 ****
  
     k = (n << 8) | m;
  
!    printf("%s\t%s\t\t| loc %05.5lx\n",optab[j].text,
!     lookup((PC + k + 1L),N_TEXT,LOOK_LNG,(PC - 1L)),
!     (PC + k + 1L));
  
     objout();
  
--- 935,948 ----
  
     k = (n << 8) | m;
  
!    if (j <= 0x7f)
! 	   printf("%s\t%s\t\t| loc %05.5lx\n",optab1[j].text,
! 	    lookup((PC + k + 1L),N_TEXT,LOOK_LNG,(PC - 1L)),
! 	    (PC + k + 1L));
!    else
! 	   printf("%s\t%s\t\t| loc %05.5lx\n",optab2[j-0x80].text,
! 	    lookup((PC + k + 1L),N_TEXT,LOOK_LNG,(PC - 1L)),
! 	    (PC + k + 1L));
  
     objout();
  

Index: dismain.c
*** /bram0/dis88.old/./dismain.c	Mon Oct 10 21:00:17 1988
--- ./dismain.c	Sun Oct 30 11:10:04 1988
***************
*** 368,374 ****
           }
        if ((c = getlab(N_TEXT)) != NULL)
           printf("%s",c);
!       f = optab[j].func;
        (*f)(j);
        }
  
--- 368,377 ----
           }
        if ((c = getlab(N_TEXT)) != NULL)
           printf("%s",c);
!       if (j <= 0x7f)
! 	      f = optab1[j].func;
!       else
! 	      f = optab2[j-0x80].func;
        (*f)(j);
        }
  

Index: distabs.c
*** /bram0/dis88.old/./distabs.c	Mon Oct 10 21:00:24 1988
--- ./distabs.c	Sun Oct 30 11:10:04 1988
***************
*** 90,96 ****
     ROL, ROR, RCL, RCR, SAL, SHR, SHL, SAR
     };
  
! struct opcode optab[] =             /* Table of opcode data */
     {
     ADD,              aohand,  2,    4,             /* 0x00  */
     ADD,              aohand,  2,    4,             /* 0x01  */
--- 90,96 ----
     ROL, ROR, RCL, RCR, SAL, SHR, SHL, SAR
     };
  
! struct opcode optab1[] =             /* Table of opcode data */
     {
     ADD,              aohand,  2,    4,             /* 0x00  */
     ADD,              aohand,  2,    4,             /* 0x01  */
***************
*** 220,225 ****
--- 220,228 ----
     "\tjnl",          sjhand,  2,    2,             /* 0x7d  */
     "\tjng",          sjhand,  2,    2,             /* 0x7e  */
     "\tjg",           sjhand,  2,    2,             /* 0x7f  */
+    };
+ struct opcode optab2[] =             /* Table of opcode data */
+    {
     AMBIG,            imhand,  3,    5,             /* 0x80  */
     AMBIG,            imhand,  4,    6,             /* 0x81  */
     AMBIG,            imhand,  3,    5,             /* 0x82  */

Index: makefile
*** /bram0/dis88.old/./makefile	Mon Oct 10 21:00:25 1988
--- ./makefile	Sun Oct 30 11:10:04 1988
***************
*** 23,31 ****
  # be necessary to alter the formats of the tables.
  
  OBJ = disrel.s dismain.s distabs.s dishand.s disfp.s
! 
  dis88 : $(OBJ)
! 	cc -o dis88 $(OBJ)
  
  
  disrel.s : disrel.c
--- 23,31 ----
  # be necessary to alter the formats of the tables.
  
  OBJ = disrel.s dismain.s distabs.s dishand.s disfp.s
! CFLAGS =
  dis88 : $(OBJ)
! 	cc -i -o dis88 $(OBJ)
  
  
  disrel.s : disrel.c

Index: dis.h
*** /bram0/dis88.old/./dis.h	Mon Oct 10 21:00:11 1988
--- ./dis.h	Sun Oct 30 11:10:04 1988
***************
*** 58,64 ****
     };
  
  extern struct opcode    /* Array to hold the opcode table   */
!   optab[256];
  
   /*
     +---------------------------------------------
--- 58,66 ----
     };
  
  extern struct opcode    /* Array to hold the opcode table   */
!   optab1[128];
! extern struct opcode    /* Array to hold the opcode table   */
!   optab2[128];
  
   /*
     +---------------------------------------------

-- 
Bob Best
uucp: ...{trwrb,hplabs}!felix!dhw68k!bob	InterNet: bob@dhw68k.cts.com