1//
2// r_aliasa.s
3// x86 assembly-language Alias model transform and project code.
4//
5
6#include "qasm.h"
7#include "d_ifacea.h"
8
9#if id386
10
11	.data
12Ltemp0:	.long	0
13Ltemp1:	.long	0
14
15	.text
16
17#define pfv0		8+4
18#define pfv1		8+8
19#define out			8+12
20
21.globl C(R_Alias_clip_bottom)
22C(R_Alias_clip_bottom):
23	pushl	%esi
24	pushl	%edi
25
26	movl	pfv0(%esp),%esi
27	movl	pfv1(%esp),%edi
28
29	movl	C(r_refdef)+rd_aliasvrectbottom,%eax
30
31LDoForwardOrBackward:
32
33	movl	fv_v+4(%esi),%edx
34	movl	fv_v+4(%edi),%ecx
35
36	cmpl	%ecx,%edx
37	jl		LDoForward
38
39	movl	fv_v+4(%esi),%ecx
40	movl	fv_v+4(%edi),%edx
41	movl	pfv0(%esp),%edi
42	movl	pfv1(%esp),%esi
43
44LDoForward:
45
46	subl	%edx,%ecx
47	subl	%edx,%eax
48	movl	%ecx,Ltemp1
49	movl	%eax,Ltemp0
50	fildl	Ltemp1
51	fildl	Ltemp0
52	movl	out(%esp),%edx
53	movl	$2,%eax
54
55	fdivp	%st(0),%st(1)					// scale
56
57LDo3Forward:
58	fildl	fv_v+0(%esi)	// fv0v0 | scale
59	fildl	fv_v+0(%edi)	// fv1v0 | fv0v0 | scale
60	fildl	fv_v+4(%esi)	// fv0v1 | fv1v0 | fv0v0 | scale
61	fildl	fv_v+4(%edi)	// fv1v1 | fv0v1 | fv1v0 | fv0v0 | scale
62	fildl	fv_v+8(%esi)	// fv0v2 | fv1v1 | fv0v1 | fv1v0 | fv0v0 | scale
63	fildl	fv_v+8(%edi)	// fv1v2 | fv0v2 | fv1v1 | fv0v1 | fv1v0 | fv0v0 |
64							//  scale
65	fxch	%st(5)			// fv0v0 | fv0v2 | fv1v1 | fv0v1 | fv1v0 | fv1v2 |
66							//  scale
67	fsubr	%st(0),%st(4)	// fv0v0 | fv0v2 | fv1v1 | fv0v1 | fv1v0-fv0v0 |
68							//  fv1v2 | scale
69	fxch	%st(3)			// fv0v1 | fv0v2 | fv1v1 | fv0v0 | fv1v0-fv0v0 |
70							//  fv1v2 | scale
71	fsubr	%st(0),%st(2)	// fv0v1 | fv0v2 | fv1v1-fv0v1 | fv0v0 |
72							//  fv1v0-fv0v0 | fv1v2 | scale
73	fxch	%st(1)			// fv0v2 | fv0v1 | fv1v1-fv0v1 | fv0v0 |
74							//  fv1v0-fv0v0 | fv1v2 | scale
75	fsubr	%st(0),%st(5)	// fv0v2 | fv0v1 | fv1v1-fv0v1 | fv0v0 |
76							//  fv1v0-fv0v0 | fv1v2-fv0v2 | scale
77	fxch	%st(6)			// scale | fv0v1 | fv1v1-fv0v1 | fv0v0 |
78							//  fv1v0-fv0v0 | fv1v2-fv0v2 | fv0v2
79	fmul	%st(0),%st(4)	// scale | fv0v1 | fv1v1-fv0v1 | fv0v0 |
80							//  (fv1v0-fv0v0)*scale | fv1v2-fv0v2 | fv0v2
81	addl	$12,%edi
82	fmul	%st(0),%st(2)	// scale | fv0v1 | (fv1v1-fv0v1)*scale | fv0v0 |
83							//  (fv1v0-fv0v0)*scale | fv1v2-fv0v2 | fv0v2
84	addl	$12,%esi
85	addl	$12,%edx
86	fmul	%st(0),%st(5)	// scale | fv0v1 | (fv1v1-fv0v1)*scale | fv0v0 |
87							//  (fv1v0-fv0v0)*scale | (fv1v2-fv0v2)*scale |
88							//  fv0v2
89	fxch	%st(3)			// fv0v0 | fv0v1 | (fv1v1-fv0v1)*scale | scale |
90							//  (fv1v0-fv0v0)*scale | (fv1v2-fv0v2)*scale |
91							//  fv0v2
92	faddp	%st(0),%st(4)	// fv0v1 | (fv1v1-fv0v1)*scale | scale |
93							//  fv0v0+(fv1v0-fv0v0)*scale |
94							//  (fv1v2-fv0v2)*scale | fv0v2
95	faddp	%st(0),%st(1)	// fv0v1+(fv1v1-fv0v1)*scale | scale |
96							//  fv0v0+(fv1v0-fv0v0)*scale |
97							//  (fv1v2-fv0v2)*scale | fv0v2
98	fxch	%st(4)			// fv0v2 | scale | fv0v0+(fv1v0-fv0v0)*scale |
99							//  (fv1v2-fv0v2)*scale | fv0v1+(fv1v1-fv0v1)*scale
100	faddp	%st(0),%st(3)	// scale | fv0v0+(fv1v0-fv0v0)*scale |
101							//  fv0v2+(fv1v2-fv0v2)*scale |
102							//  fv0v1+(fv1v1-fv0v1)*scale
103	fxch	%st(1)			// fv0v0+(fv1v0-fv0v0)*scale | scale |
104							//  fv0v2+(fv1v2-fv0v2)*scale |
105							//  fv0v1+(fv1v1-fv0v1)*scale
106	fadds	float_point5
107	fxch	%st(3)			// fv0v1+(fv1v1-fv0v1)*scale | scale |
108							//  fv0v2+(fv1v2-fv0v2)*scale |
109							//  fv0v0+(fv1v0-fv0v0)*scale
110	fadds	float_point5
111	fxch	%st(2)			// fv0v2+(fv1v2-fv0v2)*scale | scale |
112							//  fv0v1+(fv1v1-fv0v1)*scale |
113							//  fv0v0+(fv1v0-fv0v0)*scale
114	fadds	float_point5
115	fxch	%st(3)			// fv0v0+(fv1v0-fv0v0)*scale | scale |
116							//  fv0v1+(fv1v1-fv0v1)*scale |
117							//  fv0v2+(fv1v2-fv0v2)*scale
118	fistpl	fv_v+0-12(%edx)	// scale | fv0v1+(fv1v1-fv0v1)*scale |
119							//  fv0v2+(fv1v2-fv0v2)*scale
120	fxch	%st(1)			// fv0v1+(fv1v1-fv0v1)*scale | scale |
121							//  fv0v2+(fv1v2-fv0v2)*scale | scale
122	fistpl	fv_v+4-12(%edx)	// scale | fv0v2+(fv1v2-fv0v2)*scale
123	fxch	%st(1)			// fv0v2+(fv1v2-fv0v2)*sc | scale
124	fistpl	fv_v+8-12(%edx)	// scale
125
126	decl	%eax
127	jnz		LDo3Forward
128
129	fstp	%st(0)
130
131	popl	%edi
132	popl	%esi
133
134	ret
135
136
137.globl C(R_Alias_clip_top)
138C(R_Alias_clip_top):
139	pushl	%esi
140	pushl	%edi
141
142	movl	pfv0(%esp),%esi
143	movl	pfv1(%esp),%edi
144
145	movl	C(r_refdef)+rd_aliasvrect+4,%eax
146	jmp		LDoForwardOrBackward
147
148
149
150.globl C(R_Alias_clip_right)
151C(R_Alias_clip_right):
152	pushl	%esi
153	pushl	%edi
154
155	movl	pfv0(%esp),%esi
156	movl	pfv1(%esp),%edi
157
158	movl	C(r_refdef)+rd_aliasvrectright,%eax
159
160LRightLeftEntry:
161
162
163	movl	fv_v+4(%esi),%edx
164	movl	fv_v+4(%edi),%ecx
165
166	cmpl	%ecx,%edx
167	movl	fv_v+0(%esi),%edx
168
169	movl	fv_v+0(%edi),%ecx
170	jl		LDoForward2
171
172	movl	fv_v+0(%esi),%ecx
173	movl	fv_v+0(%edi),%edx
174	movl	pfv0(%esp),%edi
175	movl	pfv1(%esp),%esi
176
177LDoForward2:
178
179	jmp		LDoForward
180
181
182.globl C(R_Alias_clip_left)
183C(R_Alias_clip_left):
184	pushl	%esi
185	pushl	%edi
186
187	movl	pfv0(%esp),%esi
188	movl	pfv1(%esp),%edi
189
190	movl	C(r_refdef)+rd_aliasvrect+0,%eax
191	jmp		LRightLeftEntry
192
193
194#endif	// id386
195
196