1 
2 #if !defined(USE_WIN32_ASSEMBLER)
3 #error "You shouldn't be including this file because you're not using assembler routines"
4 #endif
5 
6 #define mp_addc	P_ADDC
7 #define mp_add	P_ADD
8 #define mp_rotate_left P_ROTATE_LEFT
9 #define mp_subb P_SUBB
10 #define mp_smula P_SMULA
11 
12 #if !defined(_MSC_VER)
13 #error "This code needs a Microsoft compiler"
cost(int * const C,vp8_tree T,const vp8_prob * const P,int i,int c)14 #endif
15 
16 #if defined(_M_IX86)
17 
18 
19 #pragma warning(disable:4035)  // this stops the compiler complaining about no return values from the routines
20 
21 extern unsigned int global_precision;
22 
23 
24 __inline boolean P_ROTATE_LEFT(unitptr r1, boolean carry)
25 {
26 	__asm{
27 		mov edi,DWORD PTR [global_precision]
28 		mov	ecx,DWORD PTR [r1]
29 		xor	esi,esi								// clear esi, which is the offset into the digit arrays
30 		// cetup carry
31 		// note that the instruction above clears the carry
32 		mov	eax,DWORD PTR [carry]
33 		rcr	eax,1
34 loop_t3:
35 		mov	eax,DWORD PTR [ecx + esi * 4]
vp8_cost_tokens(int * c,const vp8_prob * p,vp8_tree t)36 		rcl	eax,1
37 		mov DWORD PTR [ecx + esi * 4],eax
38 		inc	esi
39 		dec	edi
40 		jnz	loop_t3
41 		// compute carry
42 		rcl	eax,1
43 		and	eax,1
44 	}
45 }
46 
47 __inline boolean P_SUBB(unitptr r1, unitptr r2, boolean borrow)
48 {
49 	__asm{
50 		mov edi,DWORD PTR [global_precision]
51 		mov	ecx,DWORD PTR [r1]
52 		mov edx,DWORD PTR [r2]
53 		xor	esi,esi								// clear esi, which is the offset into the digit arrays
54 		// cetup carry
55 		// note that the instruction above clears the carry
56 		mov	eax,DWORD PTR [borrow]
57 		rcr	eax,1
58 loop_t3:
59 		mov	eax,DWORD PTR [ecx + esi * 4]
60 		mov	ebx,DWORD PTR [edx + esi * 4]
61 		sbb	eax,ebx
62 		mov DWORD PTR [ecx + esi * 4],eax
63 		inc	esi
64 		dec	edi
65 		jnz	loop_t3
66 		// compute carry
67 		rcl	eax,1
68 		and	eax,1
69 	}
70 }
71 
72 __inline void P_SMULA(unitptr prod,unitptr multiplicand, unit multiplier)
73 {
74 	__asm{
75 		mov ecx,DWORD PTR [global_precision]
76 		mov	edi,DWORD PTR [prod]
77 		mov esi,DWORD PTR [multiplicand]
78 		push	ebp
79 		mov ebp,DWORD PTR [multiplier]
80 
81 		xor ebx,ebx
82 loop_t3:
83 		mov	eax,DWORD PTR [esi]
84 		mul	ebp
85 		add eax,ebx
86 		adc	edx,0
87 		add eax,DWORD PTR [edi]
88 		adc	edx,0
89 		mov DWORD PTR [edi],eax
90 		mov	ebx,edx
91 		add	esi,4
92 		add	edi,4
93 		dec	ecx
94 		jnz	loop_t3
95 		add	DWORD PTR [edi],ebx
96 		pop	ebp
97 	}
98 }
99 
100 __inline boolean P_ADDC(unitptr r1, unitptr r2, boolean carry)
101 {
102 	__asm{
103 		mov edi,DWORD PTR [global_precision]
104 		mov	ecx,DWORD PTR [r1]
105 		mov edx,DWORD PTR [r2]
106 		xor	esi,esi								// clear esi, which is the offset into the digit arrays
107 		// cetup carry
108 		// note that the instruction above clears the carry
109 		mov	eax,DWORD PTR [carry]
110 		rcr	eax,1
111 loop_t3:
112 		mov	eax,DWORD PTR [ecx + esi * 4]
113 		mov	ebx,DWORD PTR [edx + esi * 4]
114 		adc	eax,ebx
115 		mov DWORD PTR [ecx + esi * 4],eax
116 		inc	esi
117 		dec	edi
118 		jnz	loop_t3
119 		// compute carry
120 		rcl	eax,1
121 		and	eax,1
122 	}
123 }
124 
125 
126 // special version which doesn't read or write a carry.
127 // we actually call this more often than the full version !
128 __inline P_ADD(unitptr r1, unitptr r2)
129 {
130 	__asm{
131 		mov edi,DWORD PTR [global_precision]
132 		mov	ecx,DWORD PTR [r1]
133 		mov edx,DWORD PTR [r2]
134 		xor	esi,esi								// clear esi, which is the offset into the digit arrays
135 loop_t3:
136 		mov	eax,DWORD PTR [ecx + esi * 4]
137 		mov	ebx,DWORD PTR [edx + esi * 4]
138 		adc	eax,ebx
139 		mov DWORD PTR [ecx + esi * 4],eax
140 		inc	esi
141 		dec	edi
142 		jnz	loop_t3
143 	}
144 }
145 
146 #if defined(SMITH)
147 
148 #define  mp_quo_digit  P_QUO_DIGIT
149 
150 extern unit reciph,recipl;
151 extern int  mshift;
152 
153 #endif /*#defined(SMITH) */
154 
155 #endif /* X86 */
156 
157 #if defined(_M_PPC)
158 #error "We've not written the PowerPC Code Yet!"
159 #endif /* _M_PPC */
160 
161 #if defined(_M_ALPHA)
162 #error "We've not written the Alpha Code Yet!"
163 #endif /* _M_ALPHA */
164 
165 #if defined(_M_MRX000)
166 #error "We've not written the MIPS Code Yet!"
167 #endif /* _M_MRX000 */
168 
169 
170 #pragma warning(default:4035)
171