.


:




:

































 

 

 

 





:

- Fxxx

(), - .

- Fxxx

, ST(0). ST ,

- Fixxx

, 16- 32-

- Fxxx ST, ST(i)

ST(i) , ST(0) - - .

- Fxxx ST(i), ST

ST(0) , ST(i) - .

- FxxxP ST(i), ST

ST(i) - , ST(0) - . ST(0)

"xxx" :

- ADD -

- SUB -

- SUBR - ,

- MUL -

- DIV -

- DIVR - ,

:

- FSQRT -

- FSCALE - 2

- FPREM -

- FRNDINT -

- FXTRACT -

- FABS -

- FCHS -

FSQRT ST(0).

FSCALE , ST(0). ST(0) , ST(1). :

ST(0) = ST(0) * 2n, -215 <= n <= +215

n - ST(1).

FPREM ST(0) ST(1). ST(0), ST(0).

, " ". C2 :

- 0 - , ST(0), ST(1),

- 1 - ST(0) ,

RNDINT ST(0) RC .

FABS ST(0). , FCHS ST(0) .

:

- (sin, cos, tg,...)

- (arcsin, arccos,...)

- (xy, 2x, 10x, ex)

- (sh, ch, th,...)

- (arsh, arch, arcth,...)

:

- FPTAN

- FPATAN

- FYL2X y*log2(x)

- FYL2XP1 y*log2(x+1)

- F2XM1 2x-1

- FCOS cos(x)

- FSIN sin(x)

- FSINCOS sin(x) cos(x)

FPTAN ST(0), x y, y/x = tg(ST(0)).

y ST(0), x ( ST(1)). FPTAN :

0 <= ST(0) <= pi/4

, :

- sin(z) = 2*(y/x) / (1 + (y/x)2)

- cos(z) = (1 - (y/x)2) / (1 + (y/x)2)

- tg(z/2) = y/x;

- ctg(z/2) = x/y;

- cosec(z) = (1 + (y/x)2) / 2*(y/x)

- sec(z) = (1 + (y/x)2) / (1 - (y/x)2)

z - , ST(0) FPTAN, x y - ST(0) ST(1), .

FPATAN :

z=arctg(ST(0)/ST(1))=arctg(x/y).

x y ST(0) ST(1), . FPATAN :

0 < y < x

ST(0).

FYL2X y*log2(x), x y , , ST(0) ST(1). , . x .

, :

- : log2(x) = FYL2(x)

- : loge(x) = loge(2) * log2(x) = FYL2X(loge(2), x) = FYL2X(FLDLN2, x)

- : log10(x) = log10(2) * log2(x) = FYL2X (log10(2), x) = FYL2X(FLDLG2, x)

FYL2XP1 y*log2(x+1), x ST(0), y - ST(1). ST(0), .

x : 0 < x < 1 - 1/sqrt(2)

F2XM1 2x-1, x - ST(0). ST(0), : 0 <= x <= 0,5

FCOS cos(x). x ST(0), .

FSIN FCOS, ST(0).

FSINCOS ST(0). ST(1), - ST(0).

 

FPU

FLD1 - 1,0

FLDZ - +0,0

FLDPI - π

FLDL2E - log2(e)

FLDL2T - log2(10)

FLDLN2 - ln(2)

FLDLG2 - lg(2)

( ST(0)) .

:

.

:

, . , .

, . , .

, , .

.Model Small

.586

.Data

res dq 0

a dq 3.0

b dq 10.0

const25 dw 25

const4 dw 4

const5 dw 5

status dw 0

.Code

;

; -

length_frac Equ [BP+4]

;

ten Equ word ptr [BP-2]

temp Equ word ptr [BP-4]

OutFloat Proc Near

ENTER 4, 0; 4

MOV ten, 10

ftst;

fstsw AX

SAHF

JNC @positiv

MOV AL, '-'; -

INT 29h

fchs;

@positiv:

fld1;

fld st(1);

fprem;

fsub st(2), st; -

fxch st(2);

XOR CX, CX;

;

@1:

fidiv ten;

fxch st(1); st st(1) fprem

fld st(1);

fprem; ( )

fsub st(2), st;

fimul ten; *10

fistp temp;

PUSH temp;

INC CX;

fxch st(1); ( , st(1) - 1)

ftst; 0?

fstsw AX

SAHF

JNZ @1; -

@2:; , .

POP AX

ADD AL, '0'

INT 29h

LOOP @2

; , . ,

fstp st; ,

fxch st(1)

ftst

fstsw AX

SAHF

JZ @quit;

MOV AL, '.'

INT 29h; -

MOV CX, length_frac;

@3:

fimul ten; 10

fxch st(1); fprem - st st(1)

fld st(1);

fprem;

fsub st(2), st;

fxch st(2)

fistp temp; temp

MOV AX, temp; , ,

OR AL, 30h; ascii

INT 29h;

fxch st(1); ( , st(1) - 1)

ftst

fstsw AX

SAHF; 0

LOOPNE @3

@quit:

fstp; .

fstp st

LEAVE;

RET 2

OutFloat EndP

 

func Proc Far

;PUSHA

finit;

fld qword ptr[b]; b

fld qword ptr[a]; a b

fcom st(1); a b

fstsw status;

MOV AH, byte ptr [status+1]

SAHF;

JA a_bigger; a

JB b_bigger; b

;

fild const25; 25 a b

JMP endcalc

a_bigger: ftst; a 0

fstsw status;

MOV AH, byte ptr [status+1]

SAHF;

JE error; a=0

fdivp st(1), st(0); b/a

fild const4; 4 b/a

fsubp st(1), st(0); b/a-4

JMP endcalc

b_bigger: fldz; 0 a b

fcomp st(2); b 0

; a b

fstsw status;

MOV AH, byte ptr [status+1]

SAHF;

JE error; b=0

fld st(0); a a b

fmul st(1), st(0); a a*a b

fmulp st(1), st(0); a*a*a b

fild const5; 5 a*a*a b

fsubp st(1), st(0); a*a*a-5 b

JMP endcalc

error:

fldz;

endcalc:

fstp res;

RET

func EndP

start:

MOV AX, @data

MOV DS, AX

CALL func

XOR AX,AX

XOR BX,BX

XOR CX,CX

XOR DX,DX

finit;

fld res;

PUSH 10;

CALL outfloat

MOV AX,4c00h

INT 21h

End start





:


: 2015-10-01; !; : 801 |


:

:

, - , ; , - .
==> ...

1686 - | 1697 -


© 2015-2024 lektsii.org - -

: 0.051 .