我的任务存在重大问题。我想有以下几点:
•程序必须提示并以弧度输入角度。
•使用子程序使用泰勒级数的前10个项计算角度的正弦值。
我不知道如何有效地计算正弦,正如我以前从未有过的那样。我不确定如何简化这样的问题。我的代码中出现了一大堆错误。我能帮忙吗?
编辑:我修改了我的代码和我正在使用的功能。我现在正在做:l_(i-1) * (-1)x^2/(2i)(2i+1)
。
EDIT2:我修复了无效代码,使其汇编,但我相信我得到了错误的答案。有关如何修复它的任何建议吗?
INCLUDE Irvine32.inc
.data
negone REAL8 -1.0
inputx REAL8 ?
one REAL8 1.0
istu REAL8 1.0
two REAL8 2.0
inputa REAL8 ?
inputb REAL8 ?
inputc REAL8 ?
result REAL8 ?
prompt BYTE "Enter an Integer for X",0dh,0ah,0
resultPrompt BYTE "The result of sine (your angle) is: ",0
.code
main PROC
loop1:
finit ; initializes floating point
mov edx,OFFSET prompt ; offsets the prompt
call WriteString ; writes prompt
call ReadFloat ; read input of the value
fst inputx ; save input of user
fmul inputx ; Multiplies for X Squared
fmul negone ; Multiplies X by negative 1
fst inputa ; Inputs answer into inputa
mov eax, 2 ; move 2 into eax
fmul istu ; Multiplies this by i
fst inputb ; inputs answer into inputb
mov eax, 2 ; moves 2 into eax
fmul istu ; multiplies that by i
fadd one ; adds 1
fst inputc ; places this into inputc
fmul inputb ; multiplies input c with input b
fdiv inputa ; divides whole by input a
fsub inputx ; subtracts x
fst result ; places this into result
mov eax, 0 ; moves i into eax
fadd istu
inc eax ; increments i
fst istu
cmp eax,10 ; compares i with 10
je endloop ; if 10, end the loop
endloop:
mov edx,OFFSET resultPrompt ; offsets result
call WriteString ; write prompt
call WriteFloat
call Crlf
call waitmsg
exit
main ENDP
END main