Intel 80286, 80287 manual Ebde

Models: 80287 80286

1 515
Download 515 pages 45.04 Kb
Page 465
Image 465

NUMERIC PROGRAMMING EXAMPLES

iAPX286 MACRO ASSEMBLER

80287 Floating-Point to 18-Dig.it ASCII Conversion

10: 12: 38 09/25/83 PAGE

LOC

DB..}

LINE

 

 

134

0012

 

135

 

 

136

0012 EBOODO

137

0015

81308

138

0017

2EBAB70200

139

ODIC

3CFE

140

ODIE

7528

141

 

 

142

 

 

143

 

 

144

0020 C20AOO

145

 

 

146

 

 

147

 

 

148

0023

 

149

 

 

150

0023

ODDS

151

0025

EB02

152

 

 

153

 

 

154

 

 

155

0027

 

156

 

 

157

0027

BOFE

158

 

 

159

0029

 

160

 

 

161

0029

C9

162

002A

07

163

00213

C20AOO

164

 

 

165

 

 

166

 

 

167

002E

 

168

 

169

 

 

170

SOURCE

call

tos_status

Look at status of ST(O)

 

b 1, ax

Get

descriptor

frOm table

 

a1,status_table[bx]

Look

for empty

STeO)

 

OIL INVALID

ST(O) is empty! Return the status value.

RE'move infinity from stack and exit.

fstp

st (0)

;

OK to leave fstp running

Jm,

short

exit_proc

 

String space is too small! Return invalld code

 

 

OIL INVALID

 

 

 

 

 

 

 

leave

 

i

RestorE.' stack

pop

es

 

 

ret

parms_size

 

ST(O) is NAN or indefinite. Store the value in memory and look at the fraction field to separate indefinite from an ordinary NAN.

002E

DI37EFO

171

0031

A801

172

0033

98

173

0034

74F3

174

0086

DBDoeo

175

17.

0039

285EF6

177

003C

OBSEF4

178

003F

OB5EF2

179

0042

OB5EFO

180

0045

75E2

181

0047

B003

182

183

0049

EBDE

184

 

 

185

fstp

fraction

 

 

test

ai, MINUS

 

 

fwait

 

 

 

JZ

exit.JIroc

 

mov

bx.OCOOOH

 

sub

bx.word ptr fraction+6

 

bx. word

ptr

fraction+4

 

bx. word

ptr

fraction+2

or

bx. word

ptr

fraction

Jnz

9xit..JH·OC

 

 

al, INDEFINITE

Jmp

exit.JIroc

 

Remove value from stack for examination Look at sign bit

Insure stoT'e is done

Can't be indefinite if positive

Match against upper 16 bits· of fraction CompaT'e bits 63-48

Bits 32-47 must be zero Bits,l'31-16 must be zero Bits 15-0 must be zero

Set return value for indefinite value

 

 

18.

 

 

187

0048

 

188

 

189

0048

06

190

191

004C

eS100aoo

192

0050

884EOB

193

19'

0053

B3F902

195

0056

7CCF

19.

0058

49

197

198

0059

83F912

199

Dose

7603

200

DOSE B91200

201

202

OD61

 

203

 

204

0061

3C06

205

20.

0063

?DBE

207

0065

3C04

208

209

0067

7DCS

210

 

 

211

 

 

212

 

 

213

Allocate stack space for local variables and establish parameter addressibility.

not_empty:

 

 

push

 

Save working register

enter

10cal_size.O

FOT'mat stOiC II

"

mov

cx. field_size

Check for enough string space

<m,

cx.2

 

Jl

small_string

 

do<

"c x. BCD_DIGITS

AdJust for sign character

<m,

See if string is too large for BCD

J"

size_ok

 

 

c x. BCD_DIGITS

Else set maximum string size

size_ok:

 

 

<m,

aI. INFINITY

Look for infinity

".

found_i nfi n i ty

Return status value for + or - inf,

 

<m,

al. NAN

Look for NAN or INDEFINITE

JO'

NAN_or _indefinite

 

Set default return values and check that the number is normalized.

0069 D9El

21.

006B

8800

215

21.

0060

33CO

217

006F 8B7EOE

218

0072

8905

219

0074

BB5E06

220

0077

8907

221

0079 eOFAFC

222

007C

7828

223

D07E

SOFAFA

22.

225

0081

732C

226

 

 

227

 

dx. ax

mov

ax. ax

di. denormal.JItr

mov

word ptr [di.:J, ax

 

bx. power.JItr

<m,

word ptr [bx]. ax

dl. ZERO

J.'

real_zero

<m,

dl. DENORMAL

J ••

found_denormal

Use positive value onll,l

sign bit in 011 has true sign of value Save retuT'n value for later

Form a constant Zero denormal count

Zero power of ten value

Test for zero

Skip power code if value is

Look for a denormal value

Handle it specially

Figure 4-6.

Floating-Point to ASCII Conversion Routine (Cont'd.)

4-9

Page 465
Image 465
Intel 80286, 80287 manual Ebde