|
|
1.1 root 1: #
2: /*
3: *
4: * UNIX debugger
5: *
6: */
7:
8: #include "defs.h"
9: SCCSID(@(#)opset.c 2.3);
10:
11: STRING errflg;
12: L_INT dot;
13: INT dotinc;
14: L_INT var[];
15:
16:
17: /* instruction printing */
18:
19: /*
20: * Argument access types
21: */
22: #define ACCA (8<<3) /* address only */
23: #define ACCR (1<<3) /* read */
24: #define ACCW (2<<3) /* write */
25: #define ACCM (3<<3) /* modify */
26: #define ACCB (4<<3) /* branch displacement */
27: #define ACCI (5<<3) /* XFC code */
28:
29: /*
30: * Argument data types
31: */
32: #define TYPB 0 /* byte */
33: #define TYPW 1 /* word */
34: #define TYPL 2 /* long */
35: #define TYPQ 3 /* quad */
36: #define TYPF 4 /* floating */
37: #define TYPD 5 /* double floating */
38:
39:
40: TYPE struct optab *OPTAB;
41: struct optab {
42: char *iname;
43: char val;
44: char nargs;
45: char argtype[6];
46: } optab[];
47: #define SYSTAB struct systab
48: SYSTAB {
49: int argc;
50: char *sname;
51: } systab[];
52: STRING regname[];
53: STRING fltimm[];
54: POS type, space, incp;
55:
56: int ioptab[256]; /* index by opcode to optab */
57:
58: mkioptab() {/* set up ioptab */
59: REG OPTAB p=optab; while (p->iname) {ioptab[p->val&LOBYTE]=p-optab; p++;}
60: }
61:
62: extern char *fmtr;
63: extern char *fmtR;
64:
65: printins(f,idsp,ins)
66: #ifndef vax
67: REG INT ins;
68: #else
69: REG L_INT ins;
70: #endif
71: {
72: short i,b,mode; char **r; long d; char *fmat;
73: REG char * ap;
74: REG OPTAB ip;
75: #ifndef vax
76: struct {char b2,b3,b0,b1;};
77: #else
78: struct {char b0,b1,b2,b3;};
79: #endif
80:
81: type=DSYM; space=idsp;
82: ins &= LOBYTE;
83: ip=optab+ioptab[ins]; printf("%s%8t",ip->iname); incp=1;
84: ap=ip->argtype;
85: for (i=0; i<ip->nargs; i++,ap++) {
86: var[i]=0x80000000;
87: if (i!=0) printc(',');
88: top:
89: if (*ap&ACCB) b= 0xAF + ((*ap&7)<<5); /* branch displacement */
90: else {b=bchkget(inkdot(incp),idsp); ++incp;}
91: if (b&0300) {/* not short literal */
92: r= ®name[b&0xF]; mode= b >>= 4;
93: mid:
94: switch ((int)mode) {
95: case 4: /* [r] */ printf("[%s]",*r); goto top;
96: case 5: /* r */ printf("%s",*r); break;
97: case 7: /* -(r) */ printc('-');
98: base:
99: case 6: /* (r) */ printf("(%s)",*r); break;
100: case 9: /* *(r)+ */ printc('*');
101: case 8: /* (r)+ */
102: if (r==(regname+0xF)) {/* PC: immediate or absolute */
103: printc('$'); if (b==9) goto abs;
104: mode=((*ap&7)<<1)+0xA; goto mid;
105: }
106: printf("(%s)+",*r); break;
107: case 0xB: printc('*');
108: case 0xA: d=bchkget(inkdot(incp),idsp); ++incp;
109: if (d&0x80) d -= 0x100; fmat=fmtr;
110: disp:
111: var[i]=d;
112: if (r==(regname+0xF) && b>=0xA) var[i] += dot+incp;
113: psymoff(var[i],type,"");
114: if (r!=regname+0xF) goto base;
115: break;
116: case 0xD: printc('*');
117: case 0xC: d=0;
118: d.b0 = bchkget(inkdot(incp),idsp); ++incp;
119: d.b1 = bchkget(inkdot(incp),idsp); ++incp;
120: if (d&0x8000) d -= 0x10000; fmat=fmtr;
121: goto disp;
122: case 0xF: printc('*');
123: case 0xE:
124: abs:
125: d.b0 = bchkget(inkdot(incp),idsp); ++incp;
126: d.b1 = bchkget(inkdot(incp),idsp); ++incp;
127: d.b2 = bchkget(inkdot(incp),idsp); ++incp;
128: d.b3 = bchkget(inkdot(incp),idsp); ++incp;
129: fmat=fmtR; goto disp;
130: }
131: } else {/* short literal */
132: var[i]=b;
133: if ((*ap&7)==TYPF || (*ap&7)==TYPD) printf("$%s",fltimm[b]);
134: else printf("$%r",b);
135: }
136: }
137: if (ins==0xCF || ins==0xAF || ins==0x8F) {/* CASEx instr */
138: for (i=0; i<=var[2]; ++i) {
139: printc(EOR); printf(" %R: ",i+var[1]);
140: d=get(inkdot(incp+i+i),idsp)&0xFFFF;
141: if (d&0x8000) d -= 0x10000;
142: psymoff(inkdot(incp)+d,type,"");
143: }
144: incp += var[2]+var[2]+2;
145: }
146: dotinc=incp;
147: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.