back to scratko.xyz
aboutsummaryrefslogtreecommitdiff
path: root/compute_functions.asm
diff options
context:
space:
mode:
Diffstat (limited to 'compute_functions.asm')
-rw-r--r--compute_functions.asm44
1 files changed, 44 insertions, 0 deletions
diff --git a/compute_functions.asm b/compute_functions.asm
new file mode 100644
index 0000000..339742a
--- /dev/null
+++ b/compute_functions.asm
@@ -0,0 +1,44 @@
+global compute
+
+section .text
+
+;
+; calculating functions (sine, cosine, tangent, catangent)
+; [ebp+8] is integer angle
+; [ebp+12] is pointer to sine buffer
+; [ebp+16] is pointer to cosine buffer
+; [ebp+20] is pointer to tangent buffer
+; [ebp+24] is pointer to catangent buffer
+;
+compute: push ebp
+ mov ebp, esp
+ sub esp, 4
+ mov dword [ebp-4], 180
+ finit
+ fild dword [ebp+8]
+ fldpi
+ fmulp
+ fild dword [ebp-4]
+ fdivp
+ fld st0 ; copy radian angle
+ fsin
+ mov eax, [ebp+12]
+ fstp dword [eax] ; extract sin
+ fld st0
+ fcos
+ mov eax, [ebp+16]
+ fstp dword [eax] ; extract cos
+ mov eax, [ebp+20] ; check tang
+ cmp dword [eax], 0ffffffffh ; undefined value
+ je .skip
+ fptan
+ fxch
+ fst dword [eax] ; extract tang
+.skip: mov eax, [ebp+24]
+ cmp dword [eax], 0ffffffffh
+ je .quit
+ fdivp ; ctng
+ fstp dword [eax] ; extract ctng
+.quit: mov esp, ebp
+ pop ebp
+ ret