-
Notifications
You must be signed in to change notification settings - Fork 919
/
Copy pathworlda.s
144 lines (112 loc) · 2.87 KB
/
worlda.s
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
//
// worlda.s
// x86 assembly-language server testing stuff
//
#define GLQUAKE 1 // don't include unneeded defs
#include "asm_i386.h"
#include "quakeasm.h"
#include "d_ifacea.h"
#if id386
.data
Ltemp: .long 0
.text
//----------------------------------------------------------------------
// hull-point test
//----------------------------------------------------------------------
#define hull 4+8 // because only partially pushed
#define num 8+4 // because only partially pushed
#define p 12+12 // because only partially pushed
.align 4
.globl C(SV_HullPointContents)
C(SV_HullPointContents):
pushl %edi // preserve register variables
movl num(%esp),%eax
testl %eax,%eax
js Lhquickout
// float d;
// dclipnode_t *node;
// mplane_t *plane;
pushl %ebx
movl hull(%esp),%ebx
pushl %ebp
movl p(%esp),%edx
movl hu_clipnodes(%ebx),%edi
movl hu_planes(%ebx),%ebp
subl %ebx,%ebx
pushl %esi
// %ebx: 0
// %eax: num
// %edx: p
// %edi: hull->clipnodes
// %ebp: hull->planes
// while (num >= 0)
// {
Lhloop:
// node = hull->clipnodes + num;
// plane = hull->planes + node->planenum;
// !!! if the size of dclipnode_t changes, the scaling of %eax needs to be
// changed !!!
movl nd_planenum(%edi,%eax,8),%ecx
movl nd_children(%edi,%eax,8),%eax
movl %eax,%esi
rorl $16,%eax
leal (%ecx,%ecx,4),%ecx
// if (plane->type < 3)
// d = p[plane->type] - plane->dist;
movb pl_type(%ebp,%ecx,4),%bl
cmpb $3,%bl
jb Lnodot
// else
// d = DotProduct (plane->normal, p) - plane->dist;
flds pl_normal(%ebp,%ecx,4)
fmuls 0(%edx)
flds pl_normal+4(%ebp,%ecx,4)
fmuls 4(%edx)
flds pl_normal+8(%ebp,%ecx,4)
fmuls 8(%edx)
fxch %st(1)
faddp %st(0),%st(2)
faddp %st(0),%st(1)
fsubs pl_dist(%ebp,%ecx,4)
jmp Lsub
Lnodot:
flds pl_dist(%ebp,%ecx,4)
fsubrs (%edx,%ebx,4)
Lsub:
sarl $16,%eax
sarl $16,%esi
// if (d < 0)
// num = node->children[1];
// else
// num = node->children[0];
fstps Ltemp
movl Ltemp,%ecx
sarl $31,%ecx
andl %ecx,%esi
xorl $0xFFFFFFFF,%ecx
andl %ecx,%eax
orl %esi,%eax
jns Lhloop
// return num;
Lhdone:
popl %esi
popl %ebp
popl %ebx // restore register variables
Lhquickout:
popl %edi
ret
#endif // id386