back to scratko.xyz
aboutsummaryrefslogtreecommitdiff
path: root/validations.asm
blob: 12c8e26fe972981de39bc74dfd6cd41faac9f4d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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