使用MASM lib时在C#中退出错误
我和我的朋友必须用C语言编写程序,计算牛顿的迭代次数,并使用我朋友编写的特殊ASM库。这个库之所以能够工作,是因为我们在visual c主函数中运行了这个asm代码,我们得到了绘制牛顿分形的所有点。但当我想在C#中运行函数时,我在表中得到了结果,当我想用代码-1073740791(0xc0000409)将结果写入文件程序出口时,在文件中我有10000点或20000点(从170476),当我想将数字从170076写入170476时,它可以工作。。我不知道为什么会这样。内存或堆栈有问题吗 Dll导入:使用MASM lib时在C#中退出错误,c#,masm,C#,Masm,我和我的朋友必须用C语言编写程序,计算牛顿的迭代次数,并使用我朋友编写的特殊ASM库。这个库之所以能够工作,是因为我们在visual c主函数中运行了这个asm代码,我们得到了绘制牛顿分形的所有点。但当我想在C#中运行函数时,我在表中得到了结果,当我想用代码-1073740791(0xc0000409)将结果写入文件程序出口时,在文件中我有10000点或20000点(从170476),当我想将数字从170076写入170476时,它可以工作。。我不知道为什么会这样。内存或堆栈有问题吗 Dll导入
[DllImport(@"Dll_ASM.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void countPointsInAsm(double[] PolynomialCoefficient, double[] fromIntervals, double[] toIntervals, double[] TableOfPixels);
在任何呼叫中,约定都是一样的
以下是算法:在C中:
#用436定义像素
#定义像素高391
#定义表格长度170476
类型定义结构
{
双实数;
双重想象;
}复杂的;
复合物添加(复合物a、复合物b)
{
复杂结果;
结果_complex.real=a.real+b.real;
结果_复数虚=a虚+b虚;
返回结果_复杂;
}
复合AddDouble(双a,复合b)
{
复杂结果;
结果_complex.real=a+b.real;
结果_复数虚=b虚;
返回结果_复杂;
}
复杂子系统(复杂a、复杂b)
{
复杂结果;
结果_complex.real=a.real-b.real;
结果_复数虚=a虚-b虚;
返回结果_复杂;
}
复合物Mul(复合物a、复合物b)
{
复杂结果;
结果_complex.real=a.real*b.real-a.virtual*b.virtual;
结果_complex.virginal=a.real*b.virginal+a.virginal*b.real;
返回结果_复杂;
}
综合分区(综合a、综合b)
{
复杂结果;
结果_complex.real=(a.real*b.real+a.virtual*b.virtual)/(b.real*b.real+b.virtual*b.virtual);
结果_complex.virginal=(a.virginal*b.real-a.real*b.virginal)/(b.real*b.real+b.virginal*b.virginal);
返回结果_复杂;
}
双Abs(复合z)
{
双结果=sqrt((z.real*z.real)+(z.virtual*z.virtual));
返回结果;
}
int*CountPointsInC(双多项式系数[10],双区间[2][2])
{
int计数器=0;
int迭代次数=0;
int max_迭代次数=1000;
双导数系数[9];
复z;
复合zp;
复多项式_值;
复导数_值;
int*result_table=(int*)malloc(sizeof(int)*tablength);
对于(int j=0;j=0;i--)
{
多项式_值=AddDouble(多项式系数[i],Mul(多项式_值,z));
}
对于(int i=7;i>=0;i--)
{
导数_值=AddDouble(导数效率[i],Mul(导数_值,z));
}
迭代次数+=1;
zp=z;
z=Sub(z,(Div(多项式_值,导数_值));
}而((Abs(Sub(z,zp))>=0.01)和(&(迭代次数
汇编语言中的类似示例:
.data
aReal REAL8 ?
bReal REAL8 ?
realResult REAL8 ?
aImaginary REAL8 ?
bImaginary REAL8 ?
imaginaryResult REAL8 ?
doubleNumber REAL8 ?
sqrtResult REAL8 ?
zReal REAL8 ?
zImaginary REAL8 ?
zpReal REAL8 ?
zpImaginary REAL8 ?
polynomialValueReal REAL8 ?
polynomialValueImaginary REAL8 ?
derivativeValueReal REAL8 ?
derivativeValueImaginary REAL8 ?
counter REAL4 0.0
iterations REAL4 1.0
maxIterations REAL4 1000.0
k dq 0
j dq 0
whileCondition REAL8 0.01
derivativeCoefficients REAL8 9 dup(?)
.code
addComplex PROC
; adding real part
fld aReal ; load aReal into st0
fadd bReal ; aReal + bReal into st0
fstp realResult ; store into realResult
; adding imaginary part
fld aImaginary ; load aImaginary into st0
fadd bImaginary ; aImaginary + bImaginary into st0
fstp imaginaryResult ; store into imaginaryResult
addComplex ENDP
addDouble PROC
; adding real part
fld aReal ; load aReal into st0
fadd doubleNumber ; aReal + doubleNumber into st0
fstp realResult ; store into realResult
; adding imaginary part
fld aImaginary ; load aImaginary into st0
fstp imaginaryResult ; store into imaginaryResult
ret
addDouble ENDP
subComplex PROC
; subtracting real part
fld aReal ; load aReal into st0
fsub bReal ; aReal - bReal into st0
fstp realResult ; store into realResult
; subtracting imaginary part
fld aImaginary ; load aImaginary into st0
fsub bImaginary ; aImaginary - bImaginary into st0
fstp imaginaryResult ; store into imaginaryResult
ret
subComplex ENDP
mulComplex PROC
; multing real part
fld aReal ; load aReal into st0
fmul bReal ; aReal * bReal into st0
fld aImaginary ; load aImaginary into st0 and aReal * bReal into st1
fmul bImaginary ; aImaginary * bImaginary into st0
fsub st(1), st(0) ; aReal * bReal - aImaginary * bImaginary into st 0
fxch st(1) ; swap st1 with st0
fstp realResult ; store into realResult
; multing imaginary part
fld aReal ; load aReal into st0
fmul bImaginary ; aReal * bImaginary into st0
fld aImaginary ; load aImaginary into st0 and aReal * bImaginary into st1
fmul bReal ; aImaginary * bReal into st0
fadd st(0), st(1) ; aReal * bImaginary + aImaginary * bReal into st 0
fstp imaginaryResult ; store into imaginaryResult
ret
mulComplex ENDP
divComplex PROC
; diving real part
fld aReal ; load aReal into st0
fmul bReal ; aReal * bReal into st0
fld aImaginary ; load aImaginary into st0 and aReal * bReal into st1
fmul bImaginary ; aImaginary * bImaginary into st0
fadd st(0), st(1) ; aReal * bReal + aImaginary * bImaginary into st0
fld bReal ; load bReal into st0
fmul bReal ; bReal * bReal into st0
fld bImaginary ; load bImaginary into st0
fmul bImaginary ; bImaginary * bImaginary into st0
fadd st(0), st(1) ; bReal * bReal + bImaginary * bImaginary into st0
fdiv st(2), st(0) ; aReal * bReal + aImaginary * bImaginary / bReal * bReal + bImaginary * bImaginary into st0
fxch st(2) ; swap st2 with st0
fstp realResult ; store into realResult
; diving imaginary part
fld aImaginary ; load aImaginary into st0
fmul bReal ; aImaginary * bReal into st0
fld aReal ; load aImaginary into st0 and aImaginary * bReal into st1
fmul bImaginary ; aReal * bImaginary into st5
fsub st(1), st(0) ; aImaginary * bReal - aReal * bImaginary into st1
fxch st(1) ; swap st1 with st0
fld bReal ; load bReal into st0
fmul bReal ; bReal * bReal into st0
fld bImaginary ; load bImaginary into st0
fmul bImaginary ; bImaginary * bImaginary into st0
fadd st(0), st(1) ; bReal * bReal + bImaginary * bImaginary into st0
fdiv st(2), st(0) ; aImaginary * bReal - aReal * bImaginary / bReal * bReal + bImaginary * bImaginary into st2
fxch st(2) ; swap st2 with st0
fstp imaginaryResult ; store into imaginaryResult
ret
divComplex ENDP
absComplex PROC
fld aReal ; load aReal into st0
fmul aReal ; aReal * aReal into st0
fld aImaginary ; load aImaginary into st0 and aImaginary * bImaginary in3to st1
fmul aImaginary ; aImaginary * aImaginary into st0
fadd st(0), st(1) ; aReal * aReal + aImaginary * aImaginary into st0
fsqrt ; compute square root and store to st0
fstp sqrtResult ; store into sqrtResult
ret
absComplex ENDP
countPointsInAsm PROC
mov R13, RCX ; save pointer to PolynomialCoefficients table into R13
mov R14, RDX ; save pointer to "fromTable" into R14
mov R15, R8 ; save pointer to "toTable" into R15
mov RBX, R13 ; pointer to PolynomialCoefficients to RBX
mov RCX, 9 ; set loop counter
lea RAX, derivativeCoefficients ; pointer to derivativeCoefficients to RAX
xor RDI, RDI ; zero into RDI
derivativeCoefficientsLoop:
fld REAL8 ptr[RBX+8] ; load PolynomialCoefficients[i + 1]
fmul iterations ; PolynomialCoefficients[i + 1] * (i + 1);
fstp REAL8 ptr[RAX+RDI]
mov R12, [RAX+RDI]
fld iterations ; iterations to st(0)
fld1 ; 1 to st(0) and iterations to st(1)
faddp ; iterations + 1
fstp iterations
add RDI, 8
add RBX, 8
loop derivativeCoefficientsLoop
xor RDI, RDI ; zero into RDI
mov RCX, 391 ; set outer loop counter
mainOuterLoop:
push RCX
mov RCX, 436 ; set inner loop counter
mainInnerLoop:
fld REAL8 ptr[R15] ; load Interval[1][0]
fsub REAL8 ptr[R14] ; Interval[1][0] - Interval[0][0]
fmul k ; k*(Interval[1][0] - Interval[0][0])
push k
mov k, 436
fdiv k ; k*(Interval[1][0] - Interval[0][0])/436
pop k
fadd REAL8 ptr[R14] ; Interval[0][0] + k*(Interval[1][0] - Interval[0][0])/436
fstp zReal
fld REAL8 ptr[R14+8] ; load Interval[1][1]
fsub REAL8 ptr[R15+8] ; Interval[1][1] - Interval[0][1]
fmul j ; j*(Interval[1][1] - Interval[0][1])
push j
mov j, 391
fdiv j ; j*(Interval[1][1] - Interval[0][1])/391
pop j
fadd REAL8 ptr[R15+8] ; Interval[1][1] + j*(Interval[0][1] - Interval[1][1])/391
fstp zImaginary
mov iterations, 0 ; zero into iterations
doWhileLoop:
fld REAL8 ptr[R13+72] ; load PolynomialCoefficients[9]
fstp polynomialValueReal ; store into polynomialValueReal
mov polynomialValueImaginary, 0 ; zero into polynomialValueImaginary
lea RAX, derivativeCoefficients ; pointer to derivativeCoefficients to RAX
fld REAL8 ptr[RAX+64] ; load derivativeCoefficients[8]
fstp derivativeValueReal ; store into derivativeValueReal
mov derivativeValueImaginary, 0 ; zero into derivativeValueImaginary
push RCX
mov RCX, 9 ; set polynomialValueLoop counter
polynomialValueLoop:
fld polynomialValueReal ; load polynomialValueReal
fstp aReal ; store into aReal
fld polynomialValueImaginary ; load polynomialValueImaginary
fstp aImaginary ; store into aImaginary
fld zReal ; load zReal
fstp bReal ; store into bReal
fld zImaginary ; load zImaginary
fstp bImaginary ; store into bImaginary
call mulComplex ; Mul(polynomial_value, z)
fld realResult ; load realResult
fstp aReal ; store into aReal
fld imaginaryResult ; load imaginaryResult
fstp aImaginary ; store into aImaginary
mov RBX, RCX ; loop counter to RBX
dec RBX
imul RBX, 8 ; memory locations of PolynomialCoefficients[i-1]
fld REAL8 ptr[R13+RBX] ; load PolynomialCoefficients[i-1]
fstp doubleNumber ; store into aReal
call addDouble ; AddDouble(PolynomialCoefficients[i-1], Mul(polynomial_value, z))
fld realResult ; load realResult
fstp polynomialValueReal ; store into polynomialValueReal
fld imaginaryResult ; load imaginaryResult
fstp polynomialValueImaginary ; store into polynomialValueImaginary
finit
DEC RCX
CMP RCX, 0
JNE polynomialValueLoop
mov RCX, 8 ; set derivativeValueLoop counter
derivativeValueLoop:
fld derivativeValueReal ; load derivativeValueReal
fstp aReal ; store into aReal
fld derivativeValueImaginary ; load derivativeValueImaginary
fstp aImaginary ; store into aImaginary
fld zReal ; load zReal
fstp bReal ; store into bReal
fld zImaginary ; load zImaginary
fstp bImaginary ; store into bImaginary
call mulComplex ; Mul(derivative_value, z)
fld realResult ; load realResult
fstp aReal ; store into aReal
fld imaginaryResult ; load imaginaryResult
fstp aImaginary ; store into aImaginary
mov RBX, RCX ; loop counter to RBX
dec RBX
imul RBX, 8 ; memory locations of DerivativeCoefficients[i-1]
fld REAL8 ptr[RAX+RBX] ; load DerivativeCoefficients[i-1]
fstp doubleNumber ; store into aReal
call addDouble ; AddDouble(DerivativeCoefficients[i-1], Mul(derivative_value, z))
fld realResult ; load realResult
fstp derivativeValueReal ; store into polynomialValueReal
fld imaginaryResult ; load imaginaryResult
fstp derivativeValueImaginary ; store into polynomialValueImaginary
finit
DEC RCX
CMP RCX, 0
JNE derivativeValueLoop
pop RCX
fld1 ; load 1
fadd iterations ; iterations + 1
fstp iterations ; store into iterations
fld zReal ; load zReal
fstp zpReal ; store into zpReal
fld zImaginary ; load zImaginary
fstp zpImaginary ; store into zpImaginary
fld polynomialValueReal ; load polynomialValueReal
fstp aReal ; store into aReal
fld polynomialValueImaginary ; load polynomialValueImaginary
fstp aImaginary ; store into aImaginary
fld derivativeValueReal ; load derivativeValueReal
fstp bReal ; store into bReal
fld derivativeValueImaginary ; load derivativeValueImaginary
fstp bImaginary ; store into bImaginary
call divComplex ; Div(polynomial_value, derivative_value)
fld realResult ; load realResult
fstp bReal ; store into bReal
fld imaginaryResult ; load imaginaryResult
fstp bImaginary ; store into bImaginary
fld zReal ; load zReal
fstp aReal ; store into aReal
fld zImaginary ; load zImaginary
fstp aImaginary ; store into aImaginary
call subComplex ; Sub(z, (Div(polynomial_value, derivative_value)))
fld realResult ; load realResult
fstp zReal ; store into zReal
fld imaginaryResult ; load imaginaryResult
fstp zImaginary ; store into zImaginary
fld zReal ; load zReal
fstp aReal ; store into aReal
fld zImaginary ; load zImaginary
fstp aImaginary ; store into aImaginary
fld zpReal ; load zpReal
fstp bReal ; store into bReal
fld zpImaginary ; load zpImaginary
fstp bImaginary ; store into bImaginary
call subComplex ; Sub(z, zp)
fld realResult ; load realResult
fstp aReal ; store into aReal
fld imaginaryResult ; load imaginaryResult
fstp aImaginary ; store into aImaginary
call absComplex ; (Abs(Sub(z, zp))
finit
fld sqrtResult ; load sqrtResult
fcomp whileCondition ; compare sqrtResult with 0.01
fstsw AX
sahf
jb toEnd; if sqrtResult < 0.01 end doWhileLoop
fld iterations ; load iterations as int
fcomp maxiterations ; compare iterations with maxiterations
fstsw AX
sahf
jb doWhileLoop ; if iterations >= maxiterations end doWhileLoop
toEnd:
fld iterations ; load iterations
mov RAX, R9 ; pointer to resultTable to RAX
fstp REAL8 ptr[RAX+RDI] ; add iterations to resultTable: result_table[counter] = iterations
add RDI, 8
fld1 ; load 1
fadd counter ; counter + 1
fstp counter ; store into counter
inc k
dec RCX
cmp RCX, 0
JNE mainInnerLoop
inc j
mov k, 0
pop RCX
dec RCX
cmp RCX, 0
JNE mainOuterLoop
ret
countPointsInAsm ENDP
end
.data
真面积8?
布雷尔REAL8?
真实结果真实8?
目标现实8?
双模真8?
想象结果真实8?
双数REAL8?
sqrtResult REAL8?
ZrealReal8?
zImaginary REAL8?
zpReal REAL8?
zpImaginary REAL8?
多项式值实数8?
多项式真值8?
衍生价值现实8?
衍生价值虚拟现实8?
计数器real40.0
迭代REAL4 1.0
MaxReal4 1000.0
kdq0
j dq 0
而条件REAL8 0.01
导数系数REAL8 9 dup(?)
.代码
添加复杂程序
; 添加实部
fld区域性;将区域加载到st0中
法德布雷尔;区域+胸部进入st0
fstp真实结果;存储到realResult中
; 加虚部
外语教学目标;将Aimaginal加载到st0中
fadd双模态;目标+双目标转换为st0
fstp图像结果;存储到想象的结果中
addComplex-ENDP
添加双进程
; 添加实部
fld区域性;将区域加载到st0中
fadd双数;区域+双倍数字转换为st0
fstp真实结果;存储到realResult中
; 加虚部
外语教学目标;将Aimaginal加载到st0中
fstp图像结果;存储到想象的结果中
ret
添加双端
子复杂过程
; 减去实部
fld区域性;将区域加载到st0中
fsub-bReal;区域-胸围至st0
fstp真实结果;存储到realResult中
; 减去虚部
外语教学目标;将Aimaginal加载到st0中
fsub双模态;aimaginal-双maginal转换为st0
fstp图像结果;存储到想象的结果中
ret
亚复数ENDP
复合过程
; 多重实部
fld区域性;将区域加载到st0中
fmul BRAIL;面积*胸围至st0
外语教学目标;将Aimaginal装入st0,将Area*bReal装入st1
fmul双模态;aimaginal*双maginal进入st0
fsub-st(1),st(0);区域*bReal-目标*ST0的双目标
fxch st(1);将st1与st0交换
fstp真实结果;存储到realResu中
.data
aReal REAL8 ?
bReal REAL8 ?
realResult REAL8 ?
aImaginary REAL8 ?
bImaginary REAL8 ?
imaginaryResult REAL8 ?
doubleNumber REAL8 ?
sqrtResult REAL8 ?
zReal REAL8 ?
zImaginary REAL8 ?
zpReal REAL8 ?
zpImaginary REAL8 ?
polynomialValueReal REAL8 ?
polynomialValueImaginary REAL8 ?
derivativeValueReal REAL8 ?
derivativeValueImaginary REAL8 ?
counter REAL4 0.0
iterations REAL4 1.0
maxIterations REAL4 1000.0
k dq 0
j dq 0
whileCondition REAL8 0.01
derivativeCoefficients REAL8 9 dup(?)
.code
addComplex PROC
; adding real part
fld aReal ; load aReal into st0
fadd bReal ; aReal + bReal into st0
fstp realResult ; store into realResult
; adding imaginary part
fld aImaginary ; load aImaginary into st0
fadd bImaginary ; aImaginary + bImaginary into st0
fstp imaginaryResult ; store into imaginaryResult
addComplex ENDP
addDouble PROC
; adding real part
fld aReal ; load aReal into st0
fadd doubleNumber ; aReal + doubleNumber into st0
fstp realResult ; store into realResult
; adding imaginary part
fld aImaginary ; load aImaginary into st0
fstp imaginaryResult ; store into imaginaryResult
ret
addDouble ENDP
subComplex PROC
; subtracting real part
fld aReal ; load aReal into st0
fsub bReal ; aReal - bReal into st0
fstp realResult ; store into realResult
; subtracting imaginary part
fld aImaginary ; load aImaginary into st0
fsub bImaginary ; aImaginary - bImaginary into st0
fstp imaginaryResult ; store into imaginaryResult
ret
subComplex ENDP
mulComplex PROC
; multing real part
fld aReal ; load aReal into st0
fmul bReal ; aReal * bReal into st0
fld aImaginary ; load aImaginary into st0 and aReal * bReal into st1
fmul bImaginary ; aImaginary * bImaginary into st0
fsub st(1), st(0) ; aReal * bReal - aImaginary * bImaginary into st 0
fxch st(1) ; swap st1 with st0
fstp realResult ; store into realResult
; multing imaginary part
fld aReal ; load aReal into st0
fmul bImaginary ; aReal * bImaginary into st0
fld aImaginary ; load aImaginary into st0 and aReal * bImaginary into st1
fmul bReal ; aImaginary * bReal into st0
fadd st(0), st(1) ; aReal * bImaginary + aImaginary * bReal into st 0
fstp imaginaryResult ; store into imaginaryResult
ret
mulComplex ENDP
divComplex PROC
; diving real part
fld aReal ; load aReal into st0
fmul bReal ; aReal * bReal into st0
fld aImaginary ; load aImaginary into st0 and aReal * bReal into st1
fmul bImaginary ; aImaginary * bImaginary into st0
fadd st(0), st(1) ; aReal * bReal + aImaginary * bImaginary into st0
fld bReal ; load bReal into st0
fmul bReal ; bReal * bReal into st0
fld bImaginary ; load bImaginary into st0
fmul bImaginary ; bImaginary * bImaginary into st0
fadd st(0), st(1) ; bReal * bReal + bImaginary * bImaginary into st0
fdiv st(2), st(0) ; aReal * bReal + aImaginary * bImaginary / bReal * bReal + bImaginary * bImaginary into st0
fxch st(2) ; swap st2 with st0
fstp realResult ; store into realResult
; diving imaginary part
fld aImaginary ; load aImaginary into st0
fmul bReal ; aImaginary * bReal into st0
fld aReal ; load aImaginary into st0 and aImaginary * bReal into st1
fmul bImaginary ; aReal * bImaginary into st5
fsub st(1), st(0) ; aImaginary * bReal - aReal * bImaginary into st1
fxch st(1) ; swap st1 with st0
fld bReal ; load bReal into st0
fmul bReal ; bReal * bReal into st0
fld bImaginary ; load bImaginary into st0
fmul bImaginary ; bImaginary * bImaginary into st0
fadd st(0), st(1) ; bReal * bReal + bImaginary * bImaginary into st0
fdiv st(2), st(0) ; aImaginary * bReal - aReal * bImaginary / bReal * bReal + bImaginary * bImaginary into st2
fxch st(2) ; swap st2 with st0
fstp imaginaryResult ; store into imaginaryResult
ret
divComplex ENDP
absComplex PROC
fld aReal ; load aReal into st0
fmul aReal ; aReal * aReal into st0
fld aImaginary ; load aImaginary into st0 and aImaginary * bImaginary in3to st1
fmul aImaginary ; aImaginary * aImaginary into st0
fadd st(0), st(1) ; aReal * aReal + aImaginary * aImaginary into st0
fsqrt ; compute square root and store to st0
fstp sqrtResult ; store into sqrtResult
ret
absComplex ENDP
countPointsInAsm PROC
mov R13, RCX ; save pointer to PolynomialCoefficients table into R13
mov R14, RDX ; save pointer to "fromTable" into R14
mov R15, R8 ; save pointer to "toTable" into R15
mov RBX, R13 ; pointer to PolynomialCoefficients to RBX
mov RCX, 9 ; set loop counter
lea RAX, derivativeCoefficients ; pointer to derivativeCoefficients to RAX
xor RDI, RDI ; zero into RDI
derivativeCoefficientsLoop:
fld REAL8 ptr[RBX+8] ; load PolynomialCoefficients[i + 1]
fmul iterations ; PolynomialCoefficients[i + 1] * (i + 1);
fstp REAL8 ptr[RAX+RDI]
mov R12, [RAX+RDI]
fld iterations ; iterations to st(0)
fld1 ; 1 to st(0) and iterations to st(1)
faddp ; iterations + 1
fstp iterations
add RDI, 8
add RBX, 8
loop derivativeCoefficientsLoop
xor RDI, RDI ; zero into RDI
mov RCX, 391 ; set outer loop counter
mainOuterLoop:
push RCX
mov RCX, 436 ; set inner loop counter
mainInnerLoop:
fld REAL8 ptr[R15] ; load Interval[1][0]
fsub REAL8 ptr[R14] ; Interval[1][0] - Interval[0][0]
fmul k ; k*(Interval[1][0] - Interval[0][0])
push k
mov k, 436
fdiv k ; k*(Interval[1][0] - Interval[0][0])/436
pop k
fadd REAL8 ptr[R14] ; Interval[0][0] + k*(Interval[1][0] - Interval[0][0])/436
fstp zReal
fld REAL8 ptr[R14+8] ; load Interval[1][1]
fsub REAL8 ptr[R15+8] ; Interval[1][1] - Interval[0][1]
fmul j ; j*(Interval[1][1] - Interval[0][1])
push j
mov j, 391
fdiv j ; j*(Interval[1][1] - Interval[0][1])/391
pop j
fadd REAL8 ptr[R15+8] ; Interval[1][1] + j*(Interval[0][1] - Interval[1][1])/391
fstp zImaginary
mov iterations, 0 ; zero into iterations
doWhileLoop:
fld REAL8 ptr[R13+72] ; load PolynomialCoefficients[9]
fstp polynomialValueReal ; store into polynomialValueReal
mov polynomialValueImaginary, 0 ; zero into polynomialValueImaginary
lea RAX, derivativeCoefficients ; pointer to derivativeCoefficients to RAX
fld REAL8 ptr[RAX+64] ; load derivativeCoefficients[8]
fstp derivativeValueReal ; store into derivativeValueReal
mov derivativeValueImaginary, 0 ; zero into derivativeValueImaginary
push RCX
mov RCX, 9 ; set polynomialValueLoop counter
polynomialValueLoop:
fld polynomialValueReal ; load polynomialValueReal
fstp aReal ; store into aReal
fld polynomialValueImaginary ; load polynomialValueImaginary
fstp aImaginary ; store into aImaginary
fld zReal ; load zReal
fstp bReal ; store into bReal
fld zImaginary ; load zImaginary
fstp bImaginary ; store into bImaginary
call mulComplex ; Mul(polynomial_value, z)
fld realResult ; load realResult
fstp aReal ; store into aReal
fld imaginaryResult ; load imaginaryResult
fstp aImaginary ; store into aImaginary
mov RBX, RCX ; loop counter to RBX
dec RBX
imul RBX, 8 ; memory locations of PolynomialCoefficients[i-1]
fld REAL8 ptr[R13+RBX] ; load PolynomialCoefficients[i-1]
fstp doubleNumber ; store into aReal
call addDouble ; AddDouble(PolynomialCoefficients[i-1], Mul(polynomial_value, z))
fld realResult ; load realResult
fstp polynomialValueReal ; store into polynomialValueReal
fld imaginaryResult ; load imaginaryResult
fstp polynomialValueImaginary ; store into polynomialValueImaginary
finit
DEC RCX
CMP RCX, 0
JNE polynomialValueLoop
mov RCX, 8 ; set derivativeValueLoop counter
derivativeValueLoop:
fld derivativeValueReal ; load derivativeValueReal
fstp aReal ; store into aReal
fld derivativeValueImaginary ; load derivativeValueImaginary
fstp aImaginary ; store into aImaginary
fld zReal ; load zReal
fstp bReal ; store into bReal
fld zImaginary ; load zImaginary
fstp bImaginary ; store into bImaginary
call mulComplex ; Mul(derivative_value, z)
fld realResult ; load realResult
fstp aReal ; store into aReal
fld imaginaryResult ; load imaginaryResult
fstp aImaginary ; store into aImaginary
mov RBX, RCX ; loop counter to RBX
dec RBX
imul RBX, 8 ; memory locations of DerivativeCoefficients[i-1]
fld REAL8 ptr[RAX+RBX] ; load DerivativeCoefficients[i-1]
fstp doubleNumber ; store into aReal
call addDouble ; AddDouble(DerivativeCoefficients[i-1], Mul(derivative_value, z))
fld realResult ; load realResult
fstp derivativeValueReal ; store into polynomialValueReal
fld imaginaryResult ; load imaginaryResult
fstp derivativeValueImaginary ; store into polynomialValueImaginary
finit
DEC RCX
CMP RCX, 0
JNE derivativeValueLoop
pop RCX
fld1 ; load 1
fadd iterations ; iterations + 1
fstp iterations ; store into iterations
fld zReal ; load zReal
fstp zpReal ; store into zpReal
fld zImaginary ; load zImaginary
fstp zpImaginary ; store into zpImaginary
fld polynomialValueReal ; load polynomialValueReal
fstp aReal ; store into aReal
fld polynomialValueImaginary ; load polynomialValueImaginary
fstp aImaginary ; store into aImaginary
fld derivativeValueReal ; load derivativeValueReal
fstp bReal ; store into bReal
fld derivativeValueImaginary ; load derivativeValueImaginary
fstp bImaginary ; store into bImaginary
call divComplex ; Div(polynomial_value, derivative_value)
fld realResult ; load realResult
fstp bReal ; store into bReal
fld imaginaryResult ; load imaginaryResult
fstp bImaginary ; store into bImaginary
fld zReal ; load zReal
fstp aReal ; store into aReal
fld zImaginary ; load zImaginary
fstp aImaginary ; store into aImaginary
call subComplex ; Sub(z, (Div(polynomial_value, derivative_value)))
fld realResult ; load realResult
fstp zReal ; store into zReal
fld imaginaryResult ; load imaginaryResult
fstp zImaginary ; store into zImaginary
fld zReal ; load zReal
fstp aReal ; store into aReal
fld zImaginary ; load zImaginary
fstp aImaginary ; store into aImaginary
fld zpReal ; load zpReal
fstp bReal ; store into bReal
fld zpImaginary ; load zpImaginary
fstp bImaginary ; store into bImaginary
call subComplex ; Sub(z, zp)
fld realResult ; load realResult
fstp aReal ; store into aReal
fld imaginaryResult ; load imaginaryResult
fstp aImaginary ; store into aImaginary
call absComplex ; (Abs(Sub(z, zp))
finit
fld sqrtResult ; load sqrtResult
fcomp whileCondition ; compare sqrtResult with 0.01
fstsw AX
sahf
jb toEnd; if sqrtResult < 0.01 end doWhileLoop
fld iterations ; load iterations as int
fcomp maxiterations ; compare iterations with maxiterations
fstsw AX
sahf
jb doWhileLoop ; if iterations >= maxiterations end doWhileLoop
toEnd:
fld iterations ; load iterations
mov RAX, R9 ; pointer to resultTable to RAX
fstp REAL8 ptr[RAX+RDI] ; add iterations to resultTable: result_table[counter] = iterations
add RDI, 8
fld1 ; load 1
fadd counter ; counter + 1
fstp counter ; store into counter
inc k
dec RCX
cmp RCX, 0
JNE mainInnerLoop
inc j
mov k, 0
pop RCX
dec RCX
cmp RCX, 0
JNE mainOuterLoop
ret
countPointsInAsm ENDP
end