Use size-dependant no. of words, with OPEN_MAX as default for fd_set size.
[minix3.git] / commands / dis88 / disfp.c
blobc6dc0da1b98802bbe0120161ad12727dba9ab76e
1 static char *sccsid =
2 "@(#) disfp.c, Ver. 2.1 created 00:00:00 87/09/01";
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 handler routines for the numeric op- *
13 * codes of the 8087 co-processor, as well as a few other *
14 * opcodes which are related to 8087 emulation. *
15 * *
16 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
18 #include "dis.h" /* Disassembler declarations */
20 #define FPINT0 0xd8 /* Floating-point interrupts */
21 #define FPINT1 0xd9
22 #define FPINT2 0xda
23 #define FPINT3 0xdb
24 #define FPINT4 0xdc
25 #define FPINT5 0xdd
26 #define FPINT6 0xde
27 #define FPINT7 0xdf
29 /* Test for floating opcodes */
30 #define ISFLOP(x) \
31 (((x) >= FPINT0) && ((x) <= FPINT7))
33 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
34 * *
35 * This is the handler for the escape family of opcodes. *
36 * These opcodes place the contents of a specified memory *
37 * location on the system bus, for access by a peripheral *
38 * or by a co-processor such as the 8087. (The 8087 NDP is *
39 * accessed only via bus escapes.) Due to a bug in the *
40 * PC/IX assembler, the "esc" mnemonic is not recognized; *
41 * consequently, escape opcodes are disassembled as .byte *
42 * directives, with the appropriate mnemonic and operand *
43 * included as a comment. FOR NOW, those escape sequences *
44 * corresponding to 8087 opcodes are treated as simple *
45 * escapes. *
46 * *
47 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
49 void
50 eshand(j)
52 register int j; /* Pointer to optab[] entry */
54 {/* * * * * * * * * * START OF eshand() * * * * * * * * * */
56 register char *a;
57 register int k;
59 objini(j);
61 FETCH(k);
63 a = mtrans((j & 0xfd),(k & 0xc7),TR_STD);
65 mtrunc(a);
67 printf("\t.byte\t0x%02.2x\t\t| esc\t%s\n",j,a);
69 for (k = 1; k < objptr; ++k)
70 printf("\t.byte\t0x%02.2x\n",objbuf[k]);
72 }/* * * * * * * * * * * END OF eshand() * * * * * * * * * * */
74 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
75 * *
76 * This is the handler routine for floating-point opcodes. *
77 * Since PC/IX must accommodate systems with and without *
78 * 8087 co-processors, it allows floating-point operations *
79 * to be initiated in either of two ways: by a software *
80 * interrput whose type is in the range 0xd8 through 0xdf, *
81 * or by a CPU escape sequence, which is invoked by an op- *
82 * code in the same range. In either case, the subsequent *
83 * byte determines the actual numeric operation to be per- *
84 * formed. However, depending on the method of access, *
85 * either one or two code bytes will precede that byte, *
86 * and the fphand() routine has no way of knowing whether *
87 * it was invoked by interrupt or by an escape sequence. *
88 * Therefore, unlike all of the other handler routines ex- *
89 * cept dfhand(), fphand() does not initialize the object *
90 * buffer, leaving that chore to the caller. *
91 * *
92 * FOR NOW, fphand() does not disassemble floating-point *
93 * opcodes to floating mnemonics, but simply outputs the *
94 * object code as .byte directives. *
95 * *
96 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
98 void
99 fphand(j)
101 register int j; /* Pointer to optab[] entry */
103 {/* * * * * * * * * * START OF fphand() * * * * * * * * * */
105 register int k;
107 segflg = 0;
109 FETCH(k);
111 printf("\t.byte\t0x%02.2x\t\t| 8087 code sequence\n",
112 objbuf[0]);
114 for (k = 1; k < objptr; ++k)
115 printf("\t.byte\t0x%02.2x\n",objbuf[k]);
117 /* objout(); FOR NOW */
119 }/* * * * * * * * * * * END OF fphand() * * * * * * * * * * */
121 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
123 * This is the handler for variable software interrupt *
124 * opcodes. It is included in this file because PC/IX im- *
125 * plements its software floating-point emulation by means *
126 * of interrupts. Any interrupt in the range 0xd8 through *
127 * 0xdf is an NDP-emulation interrupt, and is specially *
128 * handled by the assembler. *
130 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
132 void
133 inhand(j)
135 register int j; /* Pointer to optab[] entry */
137 {/* * * * * * * * * * START OF inhand() * * * * * * * * * */
139 register int k;
141 objini(j);
143 FETCH(k);
145 if (ISFLOP(k))
147 fphand(k);
148 return;
151 printf("%s\t%d\n",optab[j].text,k);
153 objout();
155 }/* * * * * * * * * * * END OF inhand() * * * * * * * * * * */