Intel 80287, 80286 manual Intel Programming Numeric Applications, ·7. Sample ASM286 Program

Models: 80287 80286

1 515
Download 515 pages 45.04 Kb
Page 438
Image 438

intel" PROGRAMMING NUMERIC APPLICATIONS

"iAPX286 MACRO ASSEMBLER EXAMPLE_ASM286_PROGRAM

SERIES-I I I iAPX286 MACRO ASSEMBLER X10B ASSEMBLY OF MODULE EXAMPLE_ASM286_PROGRAM OBJECT MODULE PLACED IN : F6: 287EXP, OBJ

ASSEMBLER INVOKED BY: ASM286.86: F6: 287EXP. SRC XREF

LOC OBJ

LINE

SOURCE

1name example_ASM28b_pT'ogram

2Define initialization routine

3extl'n init287: faT'

4

SAllocate 'space foT' data

6 data se!Jment T'W public

0000

3E03

7

control_287

dw

033eh

0002

????

8

n - of

- ,

dU/

?

0004

( 100

9

,_array

dd

100 dup (1)

 

????????

 

 

 

 

 

 

)

 

 

 

 

 

0194 ????????

10

sum_squaT'es

d d

?

0198

????????

11

sum_indexes

dd

?

019C

????????

12

sum

,

dd

?

 

 

13

data

ends

 

 

 

 

14

 

 

 

 

15; Allocate CPU stack spaclt

16stack stackseg 400

 

 

 

17

; Begi"n

 

 

 

 

 

 

Ie

code

 

 

 

 

 

19

code

segment

eT'

public

 

 

 

20

 

assume

ds:

data. 55: stack. es: nothing

0000

 

 

21

start:

mov

ax. data

0000

B8----

 

22

 

0003

8ED8

 

23

 

mov

ds. ax

0005

B8----

R

24

 

mov

ax. stack

0008

8EDO

 

25

 

 

ss. ax

OOOA BCFEFF

R

26

 

 

sp. sta.ckstsrt stack

'Z7

28Assume x_array and "_of_x are initialized

29this pprogram zeroes n_of_lC

 

 

 

30

Prepare the 80287 or its emulator.

 

 

 

 

 

31

 

 

OOOD 9AOOOO----

E

32

 

call

init287

 

 

 

0012

D92EOOOO

R

33

 

fldclll

control_287

 

 

 

 

 

 

34

j Clear

three

reg isters to hold

running

sums

 

 

 

 

35

 

0016

D9EE

 

36

 

fldz

 

 

 

 

0018

D9EE

 

37

 

fld z

 

 

 

 

001A

D9EE

 

38

 

fld z

 

 

 

 

 

 

 

39

Setup CX as loop counter imd

 

 

 

 

 

 

40

 

 

 

 

 

 

41

SI as index to x_array

 

 

 

001C

8BOE0200

R

42

 

mov

c lC. n - of -,

 

 

 

0020

F7E9

 

43

 

imul

 

 

 

 

0022 8BFO'

 

44

 

mov

si. ax

 

 

 

 

 

 

45

; Sl now contains index of last element + 1

 

 

 

 

46

 

 

 

 

47

; Loop thru lC_array. accumulat.ing ~ums

 

 

0024

 

 

48

sum_next:

 

 

 

 

0024

83EE04

 

49

 

sub

si. type x_array

backup

one

element

0027

D9840400

R

50

 

fld

x_array[siJ

push it

on

the stac k

002B

DCC3

 

51

 

fadd

st(3)' st

add into sum of x

002D

D9CO

 

52

 

fld

st

duplicate x

on top

002F

DCC8

 

53

 

fmul

st . st

square

it

 

0031

DEC2

 

54

 

faddp

st(2). st

add into sum of (index+x)

 

 

 

55

 

 

 

and discard

0033

FFOE0200

R

56

 

dec

 

reduce index for next iteration

0037

E2EB

 

57

 

loop

 

 

; continue

 

 

 

58

; Pop running sums into memory

 

 

 

 

 

 

59

 

 

 

0039

 

 

60

pop_results:

 

 

 

 

0039

D91E9401

 

61

 

fstp

sum_squares

 

 

 

003D

D91E9801

 

Qc.

 

.tc.t.!"I

sum indexes

 

 

 

0041

D91E9COl

R

63

 

fstp

 

 

 

 

0045 9B

 

64

 

fwai t

 

 

 

 

 

 

 

65

 

 

 

 

 

 

 

 

 

66

Etc.

 

 

 

 

 

 

 

 

67

 

 

 

 

 

 

 

 

68

 

 

 

 

 

 

 

 

 

69

code

ends

start

 

 

 

 

 

 

70

 

end

 

 

 

Figure 2·7. Sample ASM286 Program

2-46

Page 438
Image 438
Intel 80287, 80286 manual Intel Programming Numeric Applications, ·7. Sample ASM286 Program