back to scratko.xyz
aboutsummaryrefslogtreecommitdiff
path: root/validations.asm
diff options
context:
space:
mode:
authorscratko <m@scratko.xyz>2024-03-27 22:38:51 +0300
committerscratko <m@scratko.xyz>2024-03-27 22:38:51 +0300
commit21f616b5593d87d6381c1f3d67a3df0c442dba44 (patch)
tree28eba727b41d4d6b6b273ba3f7e81a4793d56e84 /validations.asm
downloadtrigonometric-table-21f616b5593d87d6381c1f3d67a3df0c442dba44.tar.gz
trigonometric-table-21f616b5593d87d6381c1f3d67a3df0c442dba44.tar.bz2
trigonometric-table-21f616b5593d87d6381c1f3d67a3df0c442dba44.zip
Initial commit
Diffstat (limited to 'validations.asm')
-rw-r--r--validations.asm74
1 files changed, 74 insertions, 0 deletions
diff --git a/validations.asm b/validations.asm
new file mode 100644
index 0000000..12c8e26
--- /dev/null
+++ b/validations.asm
@@ -0,0 +1,74 @@
+global check_angle
+global check_tangent
+global check_cotanget
+
+section .text
+;
+; angle validation
+; [ebp+8] is end angle
+; [ebp+12] is begin angle
+; returns eax=-1 if begin angle is greater than end angle
+; eax=0 if end angle < 0 or > 360
+; eax=1 if angles are correct
+;
+check_angle: push ebp
+ mov ebp, esp
+ mov eax, [ebp+8] ; end_angle
+ mov edx, [ebp+12] ; begin_angle
+ cmp edx, eax
+ jg .error2
+ cmp eax, 0
+ jl .error1
+ cmp eax, 360
+ jg .error1
+ mov eax, 1
+ jmp .quit
+.error1: xor eax, eax
+ jmp .quit
+.error2: mov eax, -1
+.quit: pop ebp
+ ret
+
+;
+; tangent test
+; [ebp+8] is integer angle
+; [ebp+12] is pointer to tangent buffer
+; buffer=ffffffffh if tangent=90 or 270
+; else buffer=1
+;
+check_tangent: push ebp
+ mov ebp, esp
+ mov eax, [ebp+8] ; value
+ mov ecx, [ebp+12] ; address
+ mov dword [ecx], 1 ; true
+ cmp eax, 90
+ je .undefined
+ cmp eax, 270
+ je .undefined
+ jmp .quit
+.undefined: mov dword [ecx], 0ffffffffh ; false (255)
+.quit: pop ebp
+ ret
+
+;
+; cotangent test
+; [ebp+8] is integer angle
+; [ebp+12] is pointer to cotangent buffer
+; buffer=ffffffffh if cotangent=0, 180 or 360
+; else buffer=1
+;
+check_cotanget: push ebp
+ mov ebp, esp
+ mov eax, [ebp+8] ; value
+ mov ecx, [ebp+12] ; address
+ mov dword [ecx], 1 ; true
+ cmp eax, 0
+ je .undefined
+ cmp eax, 180
+ je .undefined
+ cmp eax, 360
+ je .undefined
+ jmp .quit
+.undefined: mov dword [ecx], 0ffffffffh ; false (255)
+.quit: pop ebp
+ ret