source: trunk/minix/commands/dis88/dishand.c@ 11

Last change on this file since 11 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 25.1 KB
Line 
1static char *sccsid =
2 "@(#) dishand.c, Ver. 2.1 created 00:00:00 87/09/01";
3
4 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
5 * *
6 * Copyright (C) 1987 G. M. Harding, all rights reserved *
7 * *
8 * Permission to copy and redistribute is hereby granted, *
9 * provided full source code, with all copyright notices, *
10 * accompanies any redistribution. *
11 * *
12 * This file contains the source code for most of the spe- *
13 * cialized handler routines of the disassembler program. *
14 * (The file disfp.c contains handler routines specific to *
15 * the 8087 numeric co-processor.) Each handler routine *
16 * interprets the opcode byte (and subsequent data bytes, *
17 * if any) of a particular family of opcodes, and is re- *
18 * sponsible for generating appropriate output. All of the *
19 * code in this file is highly MACHINE-SPECIFIC, and would *
20 * have to be rewritten for a different CPU. The handler *
21 * routines are accessed only via pointers in the optab[] *
22 * array, however, so machine dependencies are confined to *
23 * this file, its sister file "disfp.c", and the data file *
24 * "distabs.c". *
25 * *
26 * All of the code in this file is based on the assumption *
27 * of sixteen-bit integers. *
28 * *
29 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
30
31#include "dis.h" /* Disassembler declarations */
32
33int segflg; /* Segment-override flag */
34
35unsigned char objbuf[OBJMAX]; /* Buffer for object code */
36
37int objptr; /* Index into objbuf[] */
38
39unsigned long PC; /* Current program counter */
40
41
42 /* * * * * * MISCELLANEOUS SUPPORTING ROUTINES * * * * * */
43
44
45void
46objini(j) /* Object code init routine */
47
48 register int j;
49
50{
51 if ((segflg == 1) || (segflg == 2))
52 segflg *= 3;
53 else
54 segflg = 0;
55 objptr = 0;
56 objbuf[objptr++] = (unsigned char)(j);
57}
58
59
60void
61objout() /* Object-code output routine */
62
63{
64 register int k;
65
66 if ( ! objflg )
67 return;
68 else
69 {
70 printf("\t|");
71 if (symptr >= 0)
72 printf(" %05.5lx:",(PC + 1L - (long)(objptr)));
73 for (k = 0; k < objptr; ++k)
74 printf(" %02.2x",objbuf[k]);
75 putchar('\n');
76 }
77}
78
79
80void
81badseq(j,k) /* Invalid-sequence routine */
82
83 register int j, k;
84
85{
86 printf("\t.byte\t0x%02.2x\t\t| invalid code sequence\n",j);
87 printf("\t.byte\t0x%02.2x\n",k);
88}
89
90
91 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
92 * *
93 * This routine is the first of several opcode-specific *
94 * handlers, each of which is dedicated to a particular *
95 * opcode family. A pointer to a handler routine is con- *
96 * tained in the second field of each optab[] entry. The *
97 * dfhand() routine is the default handler, invoked when *
98 * no other handler is appropriate (generally, when an in- *
99 * valid opcode is encountered). *
100 * *
101 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
102
103void
104dfhand(j)
105
106 register int j; /* Pointer to optab[] entry */
107
108{/* * * * * * * * * * START OF dfhand() * * * * * * * * * */
109
110 segflg = 0;
111
112 printf("\t.byte\t0x%02.2x",j);
113
114 if (optab[j].min || optab[j].max)
115 putchar('\n');
116 else
117 printf("\t\t| unimplemented opcode\n");
118
119}/* * * * * * * * * * * END OF dfhand() * * * * * * * * * * */
120
121
122 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
123 * *
124 * This is the single-byte handler, invoked whenever a *
125 * one-byte opcode is encountered. *
126 * *
127 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
128
129void
130sbhand(j)
131
132 register int j; /* Pointer to optab[] entry */
133
134{/* * * * * * * * * * START OF sbhand() * * * * * * * * * */
135
136 objini(j);
137
138 if (j == 0x2e) /* seg cs */
139 segflg = 1;
140
141 if ((j == 0x26) /* seg es */
142 || (j == 0x36) /* seg ss */
143 || (j == 0x3e)) /* seg ds */
144 segflg = 2;
145
146 printf("%s\n",optab[j].text);
147
148 objout();
149
150}/* * * * * * * * * * * END OF sbhand() * * * * * * * * * * */
151
152
153 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
154 * *
155 * This is the handler for most of the processor's regular *
156 * arithmetic operations. *
157 * *
158 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
159
160void
161aohand(j)
162
163 register int j; /* Pointer to optab[] entry */
164
165{/* * * * * * * * * * START OF aohand() * * * * * * * * * */
166
167 register int k;
168 int m, n;
169 char b[64];
170
171 objini(j);
172
173 switch (j & 7)
174 {
175 case 0 :
176 case 1 :
177 case 2 :
178 case 3 :
179 printf("%s\t",optab[j].text);
180 FETCH(k);
181 printf("%s\n",mtrans(j,k,TR_STD));
182 break;
183 case 4 :
184 FETCH(k);
185 printf("%s\tal,*0x%02.2x\n",optab[j].text,k);
186 break;
187 case 5 :
188 FETCH(m);
189 FETCH(n);
190 k = (n << 8) | m;
191 if (lookext((long)(k),(PC - 1),b))
192 printf("%s\tax,#%s\n",optab[j].text,b);
193 else
194 printf("%s\tax,#0x%04.4x\n",optab[j].text,k);
195 break;
196 default :
197 dfhand(j);
198 break;
199 }
200
201 objout();
202
203}/* * * * * * * * * * * END OF aohand() * * * * * * * * * * */
204
205
206 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
207 * *
208 * This is the handler for opcodes which perform short *
209 * (eight-bit) relative jumps. *
210 * *
211 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
212
213void
214sjhand(j)
215
216 register int j; /* Pointer to optab[] entry */
217
218{/* * * * * * * * * * START OF sjhand() * * * * * * * * * */
219
220 register int k;
221 int m;
222
223 objini(j);
224
225 FETCH(m);
226
227 if (m & 0x80)
228 k = 0xff00;
229 else
230 k = 0;
231
232 k |= m;
233
234 printf("%s\t%s\t\t| loc %05.5lx\n",optab[j].text,
235 lookup((PC + k + 1L),N_TEXT,LOOK_REL,-1L),
236 (PC + k + 1L));
237
238 objout();
239
240}/* * * * * * * * * * * END OF sjhand() * * * * * * * * * * */
241
242
243 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
244 * *
245 * This is the handler for a loosely-knit family of op- *
246 * codes which perform arithmetic and logical operations, *
247 * and which take immediate data. The routine's logic is *
248 * rather complex, so, in an effort to avoid additional *
249 * complexity, the search for external references in the *
250 * relocation table has been dispensed with. Eager hackers *
251 * can try their hand at coding such a search. *
252 * *
253 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
254
255void
256imhand(j)
257
258 register int j; /* Pointer to optab[] entry */
259
260{/* * * * * * * * * * START OF imhand() * * * * * * * * * */
261
262 unsigned long pc;
263 register int k;
264 int offset, oflag, immed, iflag, mod, opi, w, rm;
265 int m, n;
266 static char a[100], b[30];
267
268 objini(j);
269
270 FETCH(k);
271
272 pc = PC + 1;
273
274 offset = 0;
275 mod = (k & 0xc0) >> 6;
276 opi = (k & 0x38) >> 3;
277 w = j & 1;
278 rm = k & 7;
279
280 if ((j & 2)
281 && ((opi == 1)
282 || (opi == 4)
283 || (opi == 6)))
284 {
285 badseq(j,k);
286 return;
287 }
288
289 strcpy(a,OPFAM[opi]);
290
291 if ( ! w )
292 strcat(a,"b");
293
294 if ((oflag = mod) > 2)
295 oflag = 0;
296
297 if ((mod == 0) && (rm == 6))
298 {
299 FETCH(m);
300 FETCH(n);
301 offset = (n << 8) | m;
302 }
303 else if (oflag)
304 if (oflag == 2)
305 {
306 FETCH(m);
307 FETCH(n);
308 offset = (n << 8) | m;
309 }
310 else
311 {
312 FETCH(m);
313 if (m & 0x80)
314 n = 0xff00;
315 else
316 n = 0;
317 offset = n | m;
318 }
319
320 switch (j & 3)
321 {
322 case 0 :
323 case 2 :
324 FETCH(immed);
325 iflag = 0;
326 break;
327 case 1 :
328 FETCH(m);
329 FETCH(n);
330 immed = (n << 8) | m;
331 iflag = 1;
332 break;
333 case 3 :
334 FETCH(immed);
335 if (immed & 0x80)
336 immed &= 0xff00;
337 iflag = 0;
338 break;
339 }
340
341 strcat(a,"\t");
342
343 switch (mod)
344 {
345 case 0 :
346 if (rm == 6)
347 strcat(a,
348 lookup((long)(offset),N_DATA,LOOK_ABS,pc));
349 else
350 {
351 sprintf(b,"(%s)",REGS0[rm]);
352 strcat(a,b);
353 }
354 break;
355 case 1 :
356 case 2 :
357 if (mod == 1)
358 strcat(a,"*");
359 else
360 strcat(a,"#");
361 sprintf(b,"%d(",offset);
362 strcat(a,b);
363 strcat(a,REGS1[rm]);
364 strcat(a,")");
365 break;
366 case 3 :
367 strcat(a,REGS[(w << 3) | rm]);
368 break;
369 }
370
371 strcat(a,",");
372 if (iflag)
373 strcat(a,"#");
374 else
375 strcat(a,"*");
376 sprintf(b,"%d",immed);
377 strcat(a,b);
378
379 printf("%s\n",a);
380
381 objout();
382
383}/* * * * * * * * * * * END OF imhand() * * * * * * * * * * */
384
385
386 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
387 * *
388 * This is the handler for various "mov"-type opcodes *
389 * which use the mod, reg, and r/m fields of the second *
390 * code byte in a standard, straightforward way. *
391 * *
392 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
393
394void
395mvhand(j)
396
397 int j; /* Pointer to optab[] entry */
398
399{/* * * * * * * * * * START OF mvhand() * * * * * * * * * */
400
401 register int k, m = j;
402
403 objini(j);
404
405 FETCH(k);
406
407 if ((m == 0x84) || (m == 0x85) /* Kind of kludgey */
408 || (m == 0xc4) || (m == 0xc5)
409 || (m == 0x8d))
410 if (m & 0x40)
411 m |= 0x03;
412 else
413 m |= 0x02;
414
415 printf("%s\t%s\n",optab[j].text,mtrans(m,k,TR_STD));
416
417 objout();
418
419}/* * * * * * * * * * * END OF mvhand() * * * * * * * * * * */
420
421
422 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
423 * *
424 * This is the handler for segment-register "mov" opcodes. *
425 * *
426 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
427
428void
429mshand(j)
430
431 register int j; /* Pointer to optab[] entry */
432
433{/* * * * * * * * * * START OF mshand() * * * * * * * * * */
434
435 register int k;
436
437 objini(j);
438
439 FETCH(k);
440
441 if (k & 0x20)
442 {
443 badseq(j,k);
444 return;
445 }
446
447 printf("%s\t%s\n",optab[j].text,mtrans(j,k,TR_SEG));
448
449 objout();
450
451}/* * * * * * * * * * * END OF mshand() * * * * * * * * * * */
452
453
454 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
455 * *
456 * This is the handler for pops, other than single-byte *
457 * pops. (The 8088 allows popping into any register, or *
458 * directly into memory, accessed either immediately or *
459 * through a register and an index.) *
460 * *
461 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
462
463void
464pohand(j)
465
466 register int j; /* Pointer to optab[] entry */
467
468{/* * * * * * * * * * START OF pohand() * * * * * * * * * */
469
470 char *a;
471 register int k;
472
473 objini(j);
474
475 FETCH(k);
476
477 if (k & 0x38)
478 {
479 badseq(j,k);
480 return;
481 }
482
483 printf("%s\t",optab[j].text);
484
485 a = mtrans((j & 0xfd),k,TR_STD);
486
487 mtrunc(a);
488
489 printf("%s\n",a);
490
491 objout();
492
493}/* * * * * * * * * * * END OF pohand() * * * * * * * * * * */
494
495
496 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
497 * *
498 * This is the handler routine for intersegment calls and *
499 * jumps. Its output is never symbolic, because the host *
500 * linker does not allow symbolic intersegment address *
501 * references except by means of symbolic constants, and *
502 * any such constants in the symbol table, even if they *
503 * are of the appropriate value, may be misleading. In *
504 * compiled code, intersegment references should not be *
505 * encountered, and even in assembled code, they should *
506 * occur infrequently. If and when they do occur, however, *
507 * they will be disassembled in absolute form. *
508 * *
509 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
510
511void
512cihand(j)
513
514 int j; /* Pointer to optab[] entry */
515
516{/* * * * * * * * * * START OF cihand() * * * * * * * * * */
517
518 register int m, n;
519
520 objini(j);
521
522 printf("%s\t",optab[j].text);
523
524 FETCH(m);
525 FETCH(n);
526
527 printf("#0x%04.4x,",((n << 8) | m));
528
529 FETCH(m);
530 FETCH(n);
531
532 printf("#0x%04.4x\n",((n << 8) | m));
533
534 objout();
535
536}/* * * * * * * * * * * END OF cihand() * * * * * * * * * * */
537
538
539 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
540 * *
541 * This is the handler for "mov" opcodes with immediate *
542 * data. *
543 * *
544 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
545
546void
547mihand(j)
548
549 register int j; /* Pointer to optab[] entry */
550
551{/* * * * * * * * * * START OF mihand() * * * * * * * * * */
552
553 register int k;
554 int m, n;
555 char b[64];
556
557 objini(j);
558
559 printf("%s",optab[j].text);
560
561 if (j & 8)
562 {
563 FETCH(m);
564 FETCH(n);
565 k = ((n << 8) | m);
566 if (lookext((long)(k),(PC - 1),b))
567 printf("#%s\n",b);
568 else
569 printf("#%d\n",k);
570 }
571 else
572 {
573 FETCH(m);
574 printf("*%d\n",m);
575 }
576
577 objout();
578
579}/* * * * * * * * * * * END OF mihand() * * * * * * * * * * */
580
581
582 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
583 * *
584 * This is the handler for a family of quick-move opcodes. *
585 * *
586 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
587
588void
589mqhand(j)
590
591 int j; /* Pointer to optab[] entry */
592
593{/* * * * * * * * * * START OF mqhand() * * * * * * * * * */
594
595 unsigned long pc;
596 register int m, n;
597
598 objini(j);
599
600 pc = PC + 1;
601
602 FETCH(m);
603 FETCH(n);
604
605 m = (n << 8) | m;
606
607 printf("%s\t",optab[j].text);
608
609 if (j & 2)
610 printf("%s,%s\n",
611 lookup((long)(m),N_DATA,LOOK_ABS,pc),
612 REGS[(j & 1) << 3]);
613 else
614 printf("%s,%s\n",
615 REGS[(j & 1) << 3],
616 lookup((long)(m),N_DATA,LOOK_ABS,pc));
617
618 objout();
619
620}/* * * * * * * * * * * END OF mqhand() * * * * * * * * * * */
621
622
623 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
624 * *
625 * This is the handler for a family of quick-test opcodes. *
626 * *
627 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
628
629void
630tqhand(j)
631
632 int j; /* Pointer to optab[] entry */
633
634{/* * * * * * * * * * START OF tqhand() * * * * * * * * * */
635
636 register int m, n;
637 int k;
638 char b[64];
639
640 objini(j);
641
642 printf("%s\t%s,",optab[j].text,REGS[(j & 1) << 3]);
643
644 FETCH(m);
645
646 if (j & 1)
647 {
648 FETCH(n);
649 k = ((n << 8) | m);
650 if (lookext((long)(k),(PC - 1),b))
651 printf("#%s\n",b);
652 else
653 printf("#%d\n",k);
654 }
655 else
656 {
657 if (m & 80)
658 m |= 0xff00;
659 printf("*%d\n",m);
660 }
661
662 objout();
663
664}/* * * * * * * * * * * END OF tqhand() * * * * * * * * * * */
665
666
667 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
668 * *
669 * This is the handler for multiple-byte "return" opcodes. *
670 * The 8088 allows returns to take an optional 16-bit ar- *
671 * gument, which reflects the amount to be added to SP *
672 * after the pop of the return address. The idea is to *
673 * facilitate the use of local parameters on the stack. *
674 * After some rumination, it was decided to disassemble *
675 * any such arguments as absolute quantities, rather than *
676 * rummaging through the symbol table for possible corre- *
677 * sponding constants. *
678 * *
679 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
680
681void
682rehand(j)
683
684 int j; /* Pointer to optab[] entry */
685
686{/* * * * * * * * * * START OF rehand() * * * * * * * * * */
687
688 register int m, n;
689
690 objini(j);
691
692 FETCH(m);
693 FETCH(n);
694
695 m = (n << 8) | m;
696
697 printf("%s\t#0x%04.4x\n",optab[j].text,m);
698
699 objout();
700
701}/* * * * * * * * * * * END OF rehand() * * * * * * * * * * */
702
703
704 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
705 * *
706 * This is the handler for "mov" opcodes involving memory *
707 * and immediate data. *
708 * *
709 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
710
711void
712mmhand(j)
713
714 register int j; /* Pointer to optab[] entry */
715
716{/* * * * * * * * * * START OF mmhand() * * * * * * * * * */
717
718 char *a;
719 register int k;
720 char b[64];
721
722 objini(j);
723
724 FETCH(k);
725
726 if (k & 0x38)
727 {
728 badseq(j,k);
729 return;
730 }
731
732 printf("%s",optab[j].text);
733
734 if ( ! (j & 1) )
735 putchar('b');
736
737 a = mtrans((j & 0xfd),(k & 0xc7),TR_STD);
738
739 mtrunc(a);
740
741 printf("\t%s,",a);
742
743 if (j & 1)
744 {
745 FETCH(j);
746 FETCH(k);
747 k = (k << 8) | j;
748 if (lookext((long)(k),(PC - 1),b))
749 printf("#%s\n",b);
750 else
751 printf("#%d\n",k);
752 }
753 else
754 {
755 FETCH(k);
756 printf("*%d\n",k);
757 }
758
759 objout();
760
761}/* * * * * * * * * * * END OF mmhand() * * * * * * * * * * */
762
763
764 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
765 * *
766 * This is the handler for the 8088 family of shift and *
767 * rotate instructions. *
768 * *
769 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
770
771void
772srhand(j)
773
774 register int j; /* Pointer to optab[] entry */
775
776{/* * * * * * * * * * START OF srhand() * * * * * * * * * */
777
778 char *a;
779 register int k;
780
781 objini(j);
782
783 FETCH(k);
784
785 if ((k & 0x38) == 0x30)
786 {
787 badseq(j,k);
788 return;
789 }
790
791 printf("%s",OPFAM[((k & 0x38) >> 3) + 16]);
792
793 if ( ! (j & 1) )
794 putchar('b');
795
796 a = mtrans((j & 0xfd),(k & 0xc7),TR_STD);
797
798 mtrunc(a);
799
800 printf("\t%s",a);
801
802 if (j & 2)
803 printf(",cl\n");
804 else
805 printf(",*1\n");
806
807 objout();
808
809}/* * * * * * * * * * * END OF srhand() * * * * * * * * * * */
810
811
812 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
813 * *
814 * This is the handler for the ASCII-adjust opcodes. *
815 * *
816 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
817
818void
819aahand(j)
820
821 register int j; /* Pointer to optab[] entry */
822
823{/* * * * * * * * * * START OF aahand() * * * * * * * * * */
824
825 register int k;
826
827 objini(j);
828
829 FETCH(k);
830
831 if (k != 0x0a)
832 {
833 badseq(j,k);
834 return;
835 }
836
837 printf("%s\n",optab[j].text);
838
839 objout();
840
841}/* * * * * * * * * * * END OF aahand() * * * * * * * * * * */
842
843
844 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
845 * *
846 * This is the handler for port I/O opcodes which specify *
847 * the port address as an immediate operand. *
848 * *
849 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
850
851void
852iohand(j)
853
854 register int j; /* Pointer to optab[] entry */
855
856{/* * * * * * * * * * START OF iohand() * * * * * * * * * */
857
858 register int k;
859
860 objini(j);
861
862 FETCH(k);
863
864 printf("%s\t0x%02.2x\n",optab[j].text,k);
865
866 objout();
867
868}/* * * * * * * * * * * END OF iohand() * * * * * * * * * * */
869
870
871 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
872 * *
873 * This is the handler for opcodes which perform long *
874 * (sixteen-bit) relative jumps and calls. *
875 * *
876 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
877
878void
879ljhand(j)
880
881 register int j; /* Pointer to optab[] entry */
882
883{/* * * * * * * * * * START OF ljhand() * * * * * * * * * */
884
885 register int k;
886 int m, n;
887
888 objini(j);
889
890 FETCH(m);
891 FETCH(n);
892
893 k = (n << 8) | m;
894
895 printf("%s\t%s\t\t| loc %05.5lx\n",optab[j].text,
896 lookup((PC + k + 1L),N_TEXT,LOOK_LNG,(PC - 1L)),
897 (PC + k + 1L));
898
899 objout();
900
901}/* * * * * * * * * * * END OF ljhand() * * * * * * * * * * */
902
903
904 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
905 * *
906 * This is the handler for a pair of oddball opcodes (0xf6 *
907 * and 0xf7) which perform miscellaneous arithmetic opera- *
908 * tions not dealt with elsewhere. *
909 * *
910 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
911
912void
913mahand(j)
914
915 register int j; /* Pointer to optab[] entry */
916
917{/* * * * * * * * * * START OF mahand() * * * * * * * * * */
918
919 char *a;
920 register int k;
921 char b[64];
922
923 objini(j);
924
925 FETCH(k);
926
927 a = mtrans((j & 0xfd),(k & 0xc7),TR_STD);
928
929 mtrunc(a);
930
931 switch (((k = objbuf[1]) & 0x38) >> 3)
932 {
933 case 0 :
934 printf("\ttest");
935 break;
936 case 1 :
937 badseq(j,k);
938 return;
939 case 2 :
940 printf("\tnot");
941 break;
942 case 3 :
943 printf("\tneg");
944 break;
945 case 4 :
946 printf("\tmul");
947 break;
948 case 5 :
949 printf("\timul");
950 break;
951 case 6 :
952 printf("\tdiv");
953 break;
954 case 7 :
955 printf("\tidiv");
956 break;
957 }
958
959 if ( ! (j & 1) )
960 putchar('b');
961
962 printf("\t%s",a);
963
964 if (k & 0x38)
965 putchar('\n');
966 else
967 if (j & 1)
968 {
969 FETCH(j);
970 FETCH(k);
971 k = (k << 8) | j;
972 if (lookext((long)(k),(PC - 1),b))
973 printf(",#%s\n",b);
974 else
975 printf(",#%d\n",k);
976 }
977 else
978 {
979 FETCH(k);
980 printf(",*%d\n",k);
981 }
982
983 objout();
984
985}/* * * * * * * * * * * END OF mahand() * * * * * * * * * * */
986
987
988 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
989 * *
990 * This is the handler for miscellaneous jump, call, push, *
991 * and increment/decrement opcodes (0xfe and 0xff) which *
992 * are not dealt with elsewhere. *
993 * *
994 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
995
996void
997mjhand(j)
998
999 register int j; /* Pointer to optab[] entry */
1000
1001{/* * * * * * * * * * START OF mjhand() * * * * * * * * * */
1002
1003 char *a;
1004 register int k;
1005
1006 objini(j);
1007
1008 FETCH(k);
1009
1010 a = mtrans((j & 0xfd),(k & 0xc7),TR_STD);
1011
1012 mtrunc(a);
1013
1014 switch (((k = objbuf[1]) & 0x38) >> 3)
1015 {
1016 case 0 :
1017 printf("\tinc");
1018 if ( ! (j & 1) )
1019 putchar('b');
1020 putchar('\t');
1021 break;
1022 case 1 :
1023 printf("\tdec");
1024 if ( ! (j & 1) )
1025 putchar('b');
1026 putchar('\t');
1027 break;
1028 case 2 :
1029 if (j & 1)
1030 printf("\tcall\t@");
1031 else
1032 goto BAD;
1033 break;
1034 case 3 :
1035 if (j & 1)
1036 printf("\tcalli\t@");
1037 else
1038 goto BAD;
1039 break;
1040 case 4 :
1041 if (j & 1)
1042 printf("\tjmp\t@");
1043 else
1044 goto BAD;
1045 break;
1046 case 5 :
1047 if (j & 1)
1048 printf("\tjmpi\t@");
1049 else
1050 goto BAD;
1051 break;
1052 case 6 :
1053 if (j & 1)
1054 printf("\tpush\t");
1055 else
1056 goto BAD;
1057 break;
1058 case 7 :
1059 BAD :
1060 badseq(j,k);
1061 return;
1062 }
1063
1064 printf("%s\n",a);
1065
1066 objout();
1067
1068}/* * * * * * * * * * * END OF mjhand() * * * * * * * * * * */
1069
1070
1071
Note: See TracBrowser for help on using the repository browser.