iAPX2Bb
MACRO
ASSEMBLER
LOC
OBJ
COCA O'9EO
ooce
D9Cl
DOCE
D96EFC
0001
D9FC
0003
8946FC
0006
D9bEFC
0009
D9CA
DaDa
08E2
DODD
BB46FE
OOEO
D9FD
00E2
D9FO
00E4
C9
ODES
DEE1
OOE7
Dcca
00E9
C3
NUMERIC PROGRAMMING EXAMPLES
Calculate
the
value
of
10**ax
LINE
SOURCE
5.
-Fchs
60
n.
st(
1)
61
fIldcw
word
ptr
6.
f'rndint
63
mav
word
ptr
6'
fidew
wOl'd
ptr
65
Fxch
st(2)
66
hub
st,
st(2)
67
mov
ax,
Cbp-2J
68
flscale
6.
f'2xml
70
l
...
v.
71
fsubl'
7.
flmul
st.
steOl
73
rot
7.
75
get_power
_10
endp
76
77
code
ends
78
en.
[bp-4J
[bp-4],
ax
[bp-4J
12: 11:
08
09/25/83
PAGE
I
COPV
power
value
in
base
two
Set
new
control
word
value
TOS
=
I:
-inf
< I
<=
X.
I
is
an
int~g~r
I
R~5tor~
original
rounding
control
I TOS
..
X.
91(U
""
-1.0.
51(2)
'" I
TOS. F -
..
X-I:
a <
..
TOS <
1.
a
Restore
power
of
ten
TOS
...
F/2:
a <
..
TOS
<
0.5
TOS
'"
2**(F/21
-
1.
0
I
Restore
stack
J
Form
2**(F/2)
Form
2**F
j
OK
to
leave
fmul
running
A8SEMBL V COMPLETE,
NO
WARNINGS,
NO
ERRORS
iAPX28b
MACRO
ASSEMBLER
Det~rmin~
TOS
r~gist~r
cont~nts
12: 12:
13
09/25/83
PAGE
SERtES-I11
iAPX28b
MACRO
ASSEMBLER
XI08
ASSEMBLV
OF
MODULE
TOS_STATUS
OBJECT
MODULE
PLACED
IN
:
F3:
TOS8T. OBJ
ASSEMBLER
INVOKED
BV:
ASM28b.86:
F3:
T09ST.
AP2
LaC
OBJ
0000
0000
09E5
0002
9BDFEO
0005
8AC4
0007
250740
OOOA
COEC03
0000
OAC4
OOOF
B400
0011
C3
LINE
SOURCE
1 +1
$title("D~t~rmine
TOS
register
contents")
2
3
This
subr.outine
will
return
a
value
from
0-15
in
AX
corres,ponding
4
to
the
contents
of
80287
T09.
All
re!listlH's
are
transparent
and
no
5
errors
are
possible
The
return
value
corresponds
to
c3,c2,cl.cO
6
of
FXAM
instruction.
7
8
tos_status
•
10
11
12
13
I.
15
16
17
18
,.
20
21
22
23
2.
25
26
27
28
2.
30
stack
code
code
pub
lic
fxam
fstsw
mov
an.
,hr
mov
ret
stacks8g
6
se!lment
proc
a.
OIl.
ah
al,4007h
ah,3
OIl.
ah
ah.O
endp
ends
end
)
Allocate
space
on
the
stack
pub
1
ic
)
Get
register
contents
status
)
Get
status
Put
bit
10-8
into
bits
2-0
Mask
out
bits
c3,c2.c1.cO
)
Put
bit
c3
into
bit
11
J
Put
c3
into
bit
3
I
Clear
return
value
ASSEMBLV COMPLETE,
NO
WARNINGS,
NO
ERRORS
Fi!!~lrA
4-~~
Flnllting-Point
to
ASCII
Conversion
Routine
(Cont'd.l
Function. Partitioning
Three separate modules implement the conversion. Most of the work of the conversion
is
done
in
the
module
FLOATING_TO_ASCII. The other modules are provided separately, because they have a
more general use.
One of them, GET_POWER_IO,
is
also used
by
the ASCII
to
floating-point conver-
sion routine. The other small module, TOS_STATUS,
will
identify what, if anything,
is
in
the top of
the numeric register stack.
4-14