Скачиваний:
26
Добавлен:
01.05.2014
Размер:
167.42 Кб
Скачать

2.3. Алгоритм на языке Assembler

assume cs:_TEXT

_linfit1 proc near

push bp

mov bp,sp

sub sp,82

push si

push di

mov di,word ptr [bp+10]

mov si,word ptr [bp+14]

fldz

fstp qword ptr [bp-8]

fldz

fstp qword ptr [bp-16]

fldz

fstp qword ptr [bp-24]

fldz

fstp qword ptr [bp-32]

fldz

fstp qword ptr [bp-40]

xor dx,dx

fwait

jmp short @1@114

@1@58:

mov ax,dx

mov cl,3

shl ax,cl

mov bx,word ptr [bp+4]

add bx,ax

fld qword ptr [bx]

fstp qword ptr [bp-48]

mov ax,dx

mov cl,3

shl ax,cl

fwait

mov bx,word ptr [bp+6]

add bx,ax

fld qword ptr [bx]

fstp qword ptr [bp-56]

fld qword ptr [bp-48]

fadd qword ptr [bp-8]

fstp qword ptr [bp-8]

fld qword ptr [bp-56]

fadd qword ptr [bp-16]

fstp qword ptr [bp-16]

fld qword ptr [bp-48]

fmul qword ptr [bp-56]

fadd qword ptr [bp-24]

fstp qword ptr [bp-24]

fld qword ptr [bp-48]

fmul qword ptr [bp-48]

fadd qword ptr [bp-32]

fstp qword ptr [bp-32]

fld qword ptr [bp-56]

fmul qword ptr [bp-56]

fadd qword ptr [bp-40]

fstp qword ptr [bp-40]

fwait

inc dx

@1@114:

cmp dx,si

jl short @1@58

mov word ptr [bp-82],si

fild word ptr [bp-82]

fld qword ptr [bp-8]

fmul qword ptr [bp-8]

fdivr

fsubr qword ptr [bp-32]

fstp qword ptr [bp-72]

fwait

mov word ptr [bp-82],si

fild word ptr [bp-82]

fld qword ptr [bp-8]

fmul qword ptr [bp-16]

fdivr

fsubr qword ptr [bp-24]

fstp qword ptr [bp-64]

fwait

mov word ptr [bp-82],si

fild word ptr [bp-82]

fld qword ptr [bp-16]

fmul qword ptr [bp-16]

fdivr

fsubr qword ptr [bp-40]

fstp qword ptr [bp-80]

fld qword ptr [bp-64]

fdiv qword ptr [bp-72]

mov bx,word ptr [bp+12]

fstp qword ptr [bx]

fwait

mov word ptr [bp-82],si

fild word ptr [bp-82]

fld qword ptr [bp-32]

fmul qword ptr [bp-16]

fld qword ptr [bp-8]

fmul qword ptr [bp-24]

fsub

fdivr

fdiv qword ptr [bp-72]

fstp qword ptr [di]

xor dx,dx

fwait

jmp short @1@226

@1@170:

mov ax,dx

mov cl,3

shl ax,cl

mov bx,word ptr [bp+4]

add bx,ax

fld qword ptr [bx]

mov bx,word ptr [bp+12]

fmul qword ptr [bx]

fadd qword ptr [di]

mov ax,dx

mov cl,3

shl ax,cl

mov bx,word ptr [bp+8]

add bx,ax

fstp qword ptr [bx]

fwait

inc dx

@1@226:

cmp dx,si

jl short @1@170

pop di

pop si

mov sp,bp

pop bp

ret

_linfit1 endp

assume cs:_TEXT

_main proc near

push bp

mov bp,sp

sub sp,498

push si

xor ax,ax

push ax

call near ptr _time

pop cx

push ax

call near ptr _srand

pop cx

mov ax,offset DGROUP:s@

push ax

call near ptr _printf

pop cx

xor si,si

jmp @2@114

@2@58:

mov ax,si

mov dx,10

imul dx

add ax,10

mov word ptr [bp-18],ax

fild word ptr [bp-18]

mov bx,si

mov cl,3

shl bx,cl

lea ax,word ptr [bp-178]

add bx,ax

fstp qword ptr [bx]

xor ax,ax

mov dx,-32768

push ax

push dx

fwait

call near ptr _rand

cwd

push ax

push dx

xor dx,dx

mov ax,20

pop cx

pop bx

call near ptr N_LXMUL@

push dx

push ax

call near ptr N_LDIV@

push ax

mov ax,si

mov dx,10

imul dx

pop dx

add ax,dx

mov word ptr [bp-18],ax

fild word ptr [bp-18]

mov bx,si

mov cl,3

shl bx,cl

lea ax,word ptr [bp-338]

add bx,ax

fstp qword ptr [bx]

mov bx,si

mov cl,3

shl bx,cl

fwait

lea ax,word ptr [bp-338]

add bx,ax

fld qword ptr [bx]

sub sp,8

fstp qword ptr [bp-508]

push si

mov bx,si

mov cl,3

shl bx,cl

fwait

lea ax,word ptr [bp-178]

add bx,ax

fld qword ptr [bx]

sub sp,8

fstp qword ptr [bp-518]

push si

mov ax,offset DGROUP:s@+14

push ax

fwait

call near ptr _printf

add sp,22

inc si

@2@114:

cmp si,20

jge @@0

jmp @2@58

@@0:

mov ax,20

push ax

lea ax,word ptr [bp-16]

push ax

lea ax,word ptr [bp-8]

push ax

lea ax,word ptr [bp-498]

push ax

lea ax,word ptr [bp-338]

push ax

lea ax,word ptr [bp-178]

push ax

call near ptr _linfit1

add sp,12

fld qword ptr [bp-16]

sub sp,8

fstp qword ptr [bp-508]

fld qword ptr [bp-8]

sub sp,8

fstp qword ptr [bp-516]

mov ax,offset DGROUP:s@+43

push ax

fwait

call near ptr _printf

add sp,18

xor si,si

jmp short @2@226

@2@170:

mov bx,si

mov cl,3

shl bx,cl

lea ax,word ptr [bp-498]

add bx,ax

fld qword ptr [bx]

sub sp,8

fstp qword ptr [bp-508]

mov ax,offset DGROUP:s@+63

push ax

fwait

call near ptr _printf

add sp,10

inc si

@2@226:

cmp si,20

jl short @2@170

pop si

mov sp,bp

pop bp

ret

_main endp

_TEXT ends

_DATA segment word public 'DATA'

s@ label byte

db 'Input Data: '

db 10

db 0

db 'x[%d] = %3.1f y[%d] = %3.1f'

db 10

db 0

db 'a: %3.1f, b: %3.1f'

db 10

db 0

db 'y_calc = %3.1f'

db 10

db 0

_DATA ends

_TEXT segment byte public 'CODE'

_TEXT ends

extrn __turboFloat:word

extrn N_LDIV@:far

extrn N_LXMUL@:far

extrn _printf:near

extrn _time:near

public _main

public _linfit1

extrn _srand:near

extrn _rand:near

_s@ equ s@

end

Соседние файлы в папке Лабораторные работы 1-4