diff options
author | Robert de Bath <rdebath@poboxes.com> | 1996-11-03 22:33:35 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2013-10-23 23:33:35 +0200 |
commit | c218c617b5be443b7968308506969ad2b726d73c (patch) | |
tree | 0051f396af56133d24fcf2ab757fabc78c1a09bf /dis88 | |
parent | 0936b9aeab611665645a4e6bafaded7ca76dd189 (diff) | |
parent | 0d2fbe9b1bd284ce2cad55be17e8f2c896031a25 (diff) | |
download | dev86-c218c617b5be443b7968308506969ad2b726d73c.tar.gz |
Import Dev86src-0.0.8.tar.gzv0.0.8
Diffstat (limited to 'dis88')
-rw-r--r-- | dis88/Makefile | 11 | ||||
-rw-r--r-- | dis88/dis.h | 4 | ||||
-rw-r--r-- | dis88/disfp.c | 2 | ||||
-rw-r--r-- | dis88/dishand.c | 83 | ||||
-rw-r--r-- | dis88/dismain.c | 64 | ||||
-rw-r--r-- | dis88/disrel.c | 5 | ||||
-rw-r--r-- | dis88/distabs.c | 16 |
7 files changed, 131 insertions, 54 deletions
diff --git a/dis88/Makefile b/dis88/Makefile index f0b7a05..0df3b02 100644 --- a/dis88/Makefile +++ b/dis88/Makefile @@ -24,7 +24,8 @@ # the initialization data in the lookup tables. It should not # be necessary to alter the formats of the tables. -CC=bcc +#CC=bcc +#CFLAGS=-O -A-l -A$*.lst CFLAGS=-O LDFLAGS= @@ -35,10 +36,8 @@ all: dis88 dis88: $(OBJ) $(CC) $(LDFLAGS) -o dis88 $(OBJ) -install: /usr/bin/dis88 - -/usr/bin/dis88: dis88 - install -cs -o bin dis88 $@ +install: dis88 + install -m 755 -s dis88 $(DIST)/usr/bin/dis88 $(OBJ): dis.h a.out.h @@ -46,4 +45,4 @@ a.out.h: ln -s ../libc/include/a.out.h . clean: - rm -f *.bak *.o core dis88 a.out.h + rm -f *.bak *.lst *.o core dis88 a.out.h diff --git a/dis88/dis.h b/dis88/dis.h index 7815e06..aa91312 100644 --- a/dis88/dis.h +++ b/dis88/dis.h @@ -33,7 +33,9 @@ #include "a.out.h" /* Object file format definitions */ #include "ansi.h" -#define MAXSYM 800 /* Maximum entries in symbol table */ +#define MAXSYM ((sizeof(int)-1)*32400/ \ + (sizeof(struct nlist)+sizeof(struct reloc))) + /* Maximum entries in symbol table */ extern struct nlist /* Array to hold the symbol table */ symtab[MAXSYM]; diff --git a/dis88/disfp.c b/dis88/disfp.c index c6dc0da..0ba5a8e 100644 --- a/dis88/disfp.c +++ b/dis88/disfp.c @@ -148,7 +148,7 @@ inhand(j) return; } - printf("%s\t%d\n",optab[j].text,k); + printf("%s\t$%02x\n",optab[j].text,k); objout(); diff --git a/dis88/dishand.c b/dis88/dishand.c index 5983972..833fa2c 100644 --- a/dis88/dishand.c +++ b/dis88/dishand.c @@ -82,8 +82,8 @@ badseq(j,k) /* Invalid-sequence routine */ register int j, k; { - printf("\t.byte\t0x%02.2x\t\t| invalid code sequence\n",j); - printf("\t.byte\t0x%02.2x\n",k); + printf("\t.byte\t$%02.2x\t\t| invalid code sequence\n",j); + printf("\t.byte\t$%02.2x\n",k); } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -107,7 +107,7 @@ dfhand(j) segflg = 0; - printf("\t.byte\t0x%02.2x",j); + printf("\t.byte\t$%02.2x",j); if (optab[j].min || optab[j].max) putchar('\n'); @@ -178,7 +178,10 @@ aohand(j) break; case 4 : FETCH(k); - printf("%s\tal,*0x%02.2x\n",optab[j].text,k); + if( k < 16 ) + printf("%s\tal,*%d\n",optab[j].text,k); + else + printf("%s\tal,*$%02.2x\n",optab[j].text,k); break; case 5 : FETCH(m); @@ -187,7 +190,12 @@ aohand(j) 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); + { + if( k < 100 || k > 65436 ) + printf("%s\tax,#%d\n",optab[j].text, (short)k); + else + printf("%s\tax,#$%04x\n",optab[j].text,k); + } break; default : dfhand(j); @@ -214,6 +222,7 @@ sjhand(j) register int k; int m; + unsigned short dest; objini(j); @@ -225,10 +234,11 @@ sjhand(j) k = 0; k |= m; + dest = (PC + k + 1); 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)); + lookup((long) dest,N_TEXT,LOOK_REL,-1L), + (long) dest); objout(); @@ -305,7 +315,7 @@ imhand(j) { FETCH(m); if (m & 0x80) - n = 0xff00; + n = -0xFF; else n = 0; offset = n | m; @@ -349,10 +359,18 @@ imhand(j) case 1 : case 2 : if (mod == 1) + { strcat(a,"*"); + sprintf(b,"%d(", (short)offset); + } else + { strcat(a,"#"); - sprintf(b,"%d(",offset); + if( offset < 100 || offset > 65436 ) + sprintf(b,"%d(", (short)offset); + else + sprintf(b,"$%04x(",offset); + } strcat(a,b); strcat(a,REGS1[rm]); strcat(a,")"); @@ -364,10 +382,18 @@ imhand(j) strcat(a,","); if (iflag) + { strcat(a,"#"); + if( immed < 100 || immed > 65436 ) + sprintf(b,"%d", (short)immed); + else + sprintf(b,"$%04x",immed); + } else + { strcat(a,"*"); - sprintf(b,"%d",immed); + sprintf(b,"%d",immed); + } strcat(a,b); printf("%s\n",a); @@ -514,12 +540,12 @@ cihand(j) FETCH(m); FETCH(n); - printf("#0x%04.4x,",((n << 8) | m)); + printf("#$%04.4x,",((n << 8) | m)); FETCH(m); FETCH(n); - printf("#0x%04.4x\n",((n << 8) | m)); + printf("#$%04.4x\n",((n << 8) | m)); objout(); @@ -555,7 +581,12 @@ mihand(j) if (lookext((long)(k),(PC - 1),b)) printf("#%s\n",b); else - printf("#%d\n",k); + { + if( k < 100 || k > 65436 ) + printf("#%d\n",(short)k); + else + printf("#$%04x\n",k); + } } else { @@ -637,12 +668,17 @@ tqhand(j) if (lookext((long)(k),(PC - 1),b)) printf("#%s\n",b); else - printf("#%d\n",k); + { + if( k < 100 || k > 65436 ) + printf("#%d\n",(short)k); + else + printf("#$%04x\n",k); + } } else { if (m & 80) - m |= 0xff00; + m |= -0xFF; printf("*%d\n",m); } @@ -733,7 +769,12 @@ mmhand(j) if (lookext((long)(k),(PC - 1),b)) printf("#%s\n",b); else - printf("#%d\n",k); + { + if( k < 100 || k > 65436 ) + printf("#%d\n",(short)k); + else + printf("#$%04x\n",k); + } } else { @@ -843,7 +884,7 @@ iohand(j) FETCH(k); - printf("%s\t0x%02.2x\n",optab[j].text,k); + printf("%s\t$%02.2x\n",optab[j].text,k); objout(); @@ -865,6 +906,7 @@ ljhand(j) register int k; int m, n; + unsigned short dest; objini(j); @@ -872,10 +914,11 @@ ljhand(j) FETCH(n); k = (n << 8) | m; + dest = PC + k + 1; 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)); + lookup((long)dest,N_TEXT,LOOK_LNG,(PC - 1L)), + (long)dest); objout(); @@ -952,7 +995,7 @@ mahand(j) if (lookext((long)(k),(PC - 1),b)) printf(",#%s\n",b); else - printf(",#%d\n",k); + printf(",#$%04x\n",k); } else { diff --git a/dis88/dismain.c b/dis88/dismain.c index f9ec6c5..dc150de 100644 --- a/dis88/dismain.c +++ b/dis88/dismain.c @@ -37,6 +37,7 @@ static char *OFILE = NULL; /* Points to output file name */ static char *PRG; /* Name of invoking program */ static unsigned long zcount; /* Consecutive "0" byte count */ int objflg = 0; /* Flag: output object bytes */ +int force = 0; /* Flag: override some checks */ #define unix 1 #define i8086 1 @@ -134,7 +135,7 @@ objdump(c) {/* * * * * * * * * * START OF objdump() * * * * * * * * * */ - register int k; + register int k,j; int retval = 0; if (objptr == OBJMAX) @@ -168,13 +169,31 @@ objdump(c) for (k = 0; k < objptr; ++k) { - printf("0x%02.2x",objbuf[k]); + printf("$%02.2x",objbuf[k]); if (k < (objptr - 1)) putchar(','); - else - putchar('\n'); } + for (k = objptr; k < OBJMAX; ++k) + printf(" "); + + printf(" | \""); + + for (k = 0; k < objptr; ++k) + { + if (objbuf[k] > ' ' && objbuf[k] <= '~' ) + putchar(objbuf[k]); + else switch(objbuf[k]) + { + case '\t': printf("\\t"); break; + case '\n': printf("\\n"); break; + case '\f': printf("\\f"); break; + case '\r': printf("\\r"); break; + default: putchar('.'); break; + } + } + printf("\"\n"); + objptr = 0; return (retval); @@ -355,10 +374,7 @@ distext() printf("| File is executable\n\n"); if (HDR.a_flags & A_SEP) - { - printf("| File has split I/D space, and may have\n"); - printf("| extraneous instructions in text segment\n\n"); - } + printf("| File has split I/D space\n\n"); prolog(); @@ -370,7 +386,9 @@ distext() for (PC = 0L; PC < HDR.a_text; ++PC) { - j = getchar() & 0xff; + j = getchar(); + if( j == EOF ) break; + j &= 0xFF; if ((j == 0) && ((PC + 1L) == HDR.a_text)) { ++PC; @@ -392,7 +410,7 @@ Fetch() if( symptr>=0 && getlab(N_TEXT) != NULL ) { --PC; return -1; } /* #define FETCH(p) ++PC; p = getchar() & 0xff; objbuf[objptr++] = p */ - p = getchar() & 0xff; + p = getchar(); objbuf[objptr++] = p; return p; } @@ -426,6 +444,7 @@ disdata() unsigned long end; putchar('\n'); + if( HDR.a_data == 0 ) return; if (HDR.a_flags & A_SEP) { @@ -476,6 +495,8 @@ static void disbss() putchar('\n'); + if( HDR.a_bss == 0 ) return; + if (HDR.a_flags & A_SEP) end = HDR.a_data + HDR.a_bss; else @@ -539,6 +560,9 @@ main(argc,argv) else ++objflg; break; + case 'f' : + force++; + break; default : usage(PRG); } @@ -573,22 +597,28 @@ main(argc,argv) if (BADMAG(HDR)) { - sprintf(a,"input file %s not in object format",IFILE); - fatal(PRG,a); + if (!force) + { + sprintf(a,"input file %s not in object format",IFILE); + fatal(PRG,a); + } + + memset(&HDR, '\0', sizeof(struct exec)); + HDR.a_text = 0x10000L; } - if (HDR.a_cpu != A_I8086) + if (HDR.a_cpu != A_I8086 && !force) { sprintf(a,"%s is not an 8086/8088 object file",IFILE); fatal(PRG,a); } if (HDR.a_hdrlen <= A_MINHDR) + { HDR.a_trsize = HDR.a_drsize = 0L; HDR.a_tbase = HDR.a_dbase = 0L; -/* AST emergency patch - HDR.a_lnums = HDR.a_toffs = 0L; -*/ + /* HDR.a_lnums = HDR.a_toffs = 0L; */ + } reloff = HDR.a_text /* Compute reloc data offset */ + HDR.a_data @@ -628,8 +658,6 @@ main(argc,argv) read(fd, (char *) &symtab[symptr],sizeof(struct nlist)); symptr--; } - else - fprintf(stderr,"%s: warning: no symbols\n",PRG); close(fd); diff --git a/dis88/disrel.c b/dis88/disrel.c index 37f3221..3d19e7a 100644 --- a/dis88/disrel.c +++ b/dis88/disrel.c @@ -1,11 +1,16 @@ static char *copyright = "@(#) Copyright (C) 1987 G. M. Harding, all rights reserved"; +#ifdef __linux__ +char *release = + "released with Dev86 for Linux, based on minix 2.1"; +#else static char *sccsid = "@(#) disrel.c, Ver. 2.1 created 00:00:00 87/09/01"; char *release = "release 2.1 (MINIX)"; +#endif /* ** diff --git a/dis88/distabs.c b/dis88/distabs.c index 283fe42..5e11da2 100644 --- a/dis88/distabs.c +++ b/dis88/distabs.c @@ -107,7 +107,7 @@ struct opcode optab[] = /* Table of opcode data */ OR, aohand, 2, 2, /* 0x0c */ OR, aohand, 3, 3, /* 0x0d */ "\tpush\tcs", sbhand, 1, 1, /* 0x0e */ - NULL, dfhand, 0, 0, /* 0x0f */ + "\t.code\t386", sbhand, 1, 1, /* 0x0f */ ADC, aohand, 2, 4, /* 0x10 */ ADC, aohand, 2, 4, /* 0x11 */ ADC, aohand, 2, 4, /* 0x12 */ @@ -192,10 +192,10 @@ struct opcode optab[] = /* Table of opcode data */ NULL, dfhand, 0, 0, /* 0x61 */ NULL, dfhand, 0, 0, /* 0x62 */ NULL, dfhand, 0, 0, /* 0x63 */ - NULL, dfhand, 0, 0, /* 0x64 */ - NULL, dfhand, 0, 0, /* 0x65 */ - NULL, dfhand, 0, 0, /* 0x66 */ - NULL, dfhand, 0, 0, /* 0x67 */ + "\tseg\tfs", sbhand, 1, 1, /* 0x64 */ + "\tseg\tgs", sbhand, 1, 1, /* 0x65 */ + "\tuse\top32", sbhand, 1, 1, /* 0x66 */ + "\tuse\tadr32", sbhand, 1, 1, /* 0x67 */ NULL, dfhand, 0, 0, /* 0x68 */ NULL, dfhand, 0, 0, /* 0x69 */ NULL, dfhand, 0, 0, /* 0x6a */ @@ -514,7 +514,7 @@ lookup(addr,type,kind,ext) return (getnam(best.i)); if (kind == LOOK_ABS) - sprintf(b,"0x%05.5x",addr); + sprintf(b,"$%04lx",addr); else { long x = addr - (PC - kind); @@ -625,7 +625,7 @@ mtrans(c,m,type) strcat(a,"*"); else strcat(a,"#"); - sprintf(b,"%d(",offset); + sprintf(b,"%d(", (short)offset); strcat(a,b); strcat(a,REGS1[rm]); strcat(a,")"); @@ -661,7 +661,7 @@ mtrans(c,m,type) strcpy(a,"*"); else strcpy(a,"#"); - sprintf(b,"%d(",offset); + sprintf(b,"%d(", (short)offset); strcat(a,b); strcat(a,REGS1[rm]); strcat(a,")"); |