-
Notifications
You must be signed in to change notification settings - Fork 1
/
disfp.c
157 lines (117 loc) · 5.61 KB
/
disfp.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
static char *sccsid =
"@(#) disfp.c, Ver. 2.1 created 00:00:00 87/09/01";
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright (C) 1987 G. M. Harding, all rights reserved *
* *
* Permission to copy and redistribute is hereby granted, *
* provided full source code, with all copyright notices, *
* accompanies any redistribution. *
* *
* This file contains handler routines for the numeric op- *
* codes of the 8087 co-processor, as well as a few other *
* opcodes which are related to 8087 emulation. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "dis.h" /* Disassembler declarations */
#define FPINT0 0xd8 /* Floating-point interrupts */
#define FPINT1 0xd9
#define FPINT2 0xda
#define FPINT3 0xdb
#define FPINT4 0xdc
#define FPINT5 0xdd
#define FPINT6 0xde
#define FPINT7 0xdf
/* Test for floating opcodes */
#define ISFLOP(x) \
(((x) >= FPINT0) && ((x) <= FPINT7))
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This is the handler for the escape family of opcodes. *
* These opcodes place the contents of a specified memory *
* location on the system bus, for access by a peripheral *
* or by a co-processor such as the 8087. (The 8087 NDP is *
* accessed only via bus escapes.) Due to a bug in the *
* PC/IX assembler, the "esc" mnemonic is not recognized; *
* consequently, escape opcodes are disassembled as .byte *
* directives, with the appropriate mnemonic and operand *
* included as a comment. FOR NOW, those escape sequences *
* corresponding to 8087 opcodes are treated as simple *
* escapes. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void
eshand(j)
register int j; /* Pointer to optab[] entry */
{/* * * * * * * * * * START OF eshand() * * * * * * * * * */
register char *a;
register int k;
objini(j);
FETCH(k);
a = mtrans((j & 0xfd),(k & 0xc7),TR_STD);
mtrunc(a);
printf("\t.byte\t0x%02.2x\t\t| esc\t%s\n",j,a);
for (k = 1; k < objptr; ++k)
printf("\t.byte\t0x%02.2x\n",objbuf[k]);
}/* * * * * * * * * * * END OF eshand() * * * * * * * * * * */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This is the handler routine for floating-point opcodes. *
* Since PC/IX must accommodate systems with and without *
* 8087 co-processors, it allows floating-point operations *
* to be initiated in either of two ways: by a software *
* interrput whose type is in the range 0xd8 through 0xdf, *
* or by a CPU escape sequence, which is invoked by an op- *
* code in the same range. In either case, the subsequent *
* byte determines the actual numeric operation to be per- *
* formed. However, depending on the method of access, *
* either one or two code bytes will precede that byte, *
* and the fphand() routine has no way of knowing whether *
* it was invoked by interrupt or by an escape sequence. *
* Therefore, unlike all of the other handler routines ex- *
* cept dfhand(), fphand() does not initialize the object *
* buffer, leaving that chore to the caller. *
* *
* FOR NOW, fphand() does not disassemble floating-point *
* opcodes to floating mnemonics, but simply outputs the *
* object code as .byte directives. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void
fphand(j)
register int j; /* Pointer to optab[] entry */
{/* * * * * * * * * * START OF fphand() * * * * * * * * * */
register int k;
segflg = 0;
FETCH(k);
printf("\t.byte\t0x%02.2x\t\t| 8087 code sequence\n",
objbuf[0]);
for (k = 1; k < objptr; ++k)
printf("\t.byte\t0x%02.2x\n",objbuf[k]);
/* objout(); FOR NOW */
}/* * * * * * * * * * * END OF fphand() * * * * * * * * * * */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This is the handler for variable software interrupt *
* opcodes. It is included in this file because PC/IX im- *
* plements its software floating-point emulation by means *
* of interrupts. Any interrupt in the range 0xd8 through *
* 0xdf is an NDP-emulation interrupt, and is specially *
* handled by the assembler. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void
inhand(j)
register int j; /* Pointer to optab[] entry */
{/* * * * * * * * * * START OF inhand() * * * * * * * * * */
register int k;
objini(j);
FETCH(k);
if (ISFLOP(k))
{
fphand(k);
return;
}
printf("%s\t$%02x\n",optab[j].text,k);
objout();
}/* * * * * * * * * * * END OF inhand() * * * * * * * * * * */