Rev 6818 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6818 | Rev 7657 | ||
---|---|---|---|
Line 10... | Line 10... | ||
10 | 10 | ||
11 | ; to be defined: |
11 | ; to be defined: |
12 | ; __DEBUG__ equ 1 |
12 | ; __DEBUG__ equ 1 |
Line -... | Line 13... | ||
- | 13 | ; __DEBUG_LEVEL__ equ 5 |
|
- | 14 | ||
- | 15 | _esp equ esp |
|
- | 16 | ||
- | 17 | macro put_board { |
|
- | 18 | mcall 63 |
|
13 | ; __DEBUG_LEVEL__ equ 5 |
19 | } |
14 | 20 | ||
15 | macro debug_func name { |
21 | macro debug_func name { |
16 | if used name |
22 | if used name |
Line 37... | Line 43... | ||
37 | \} |
43 | \} |
38 | } |
44 | } |
Line 39... | Line 45... | ||
39 | 45 | ||
40 | macro DEBUGS_N _sign,_num,[_str] { |
46 | macro DEBUGS_N _sign,_num,[_str] { |
41 | common |
47 | common |
42 | pushf |
48 | pushf |
43 | pushad |
49 | pushad |
44 | local ..str,..label,is_str |
50 | local ..str,..label,is_str |
45 | is_str = 0 |
51 | is_str = 0 |
46 | forward |
52 | forward |
47 | if _str eqtype '' |
53 | if _str eqtype '' |
48 | is_str = 1 |
54 | is_str = 1 |
49 | end if |
55 | end if |
50 | common |
56 | common |
51 | if is_str = 1 |
57 | if is_str = 1 |
52 | jmp ..label |
58 | jmp ..label |
53 | ..str db _str,0 |
59 | ..str db _str,0 |
54 | ..label: |
- | |
55 | add esp,4*8+4 |
60 | ..label: |
56 | mov edx,..str |
- | |
57 | sub esp,4*8+4 |
61 | mov edx, ..str |
- | 62 | else |
|
58 | else |
63 | esp equ esp+4*8+4 |
- | 64 | mov edx, _str |
|
59 | mov edx,_str |
65 | esp equ _esp |
60 | end if |
66 | end if |
61 | if ~_num eq |
67 | if ~_num eq |
62 | if _num eqtype eax |
68 | if _num eqtype eax |
63 | if _num in |
69 | if _num in |
64 | mov esi,_num |
70 | mov esi, _num |
65 | else if ~_num eq esi |
71 | else if ~_num eq esi |
66 | movzx esi,_num |
72 | movzx esi, _num |
67 | end if |
73 | end if |
68 | else if _num eqtype 0 |
74 | else if _num eqtype 0 |
69 | mov esi,_num |
75 | mov esi, _num |
70 | else |
76 | else |
71 | local tp |
77 | local tp |
72 | tp equ 0 |
78 | tp equ 0 |
73 | match [_arg],_num \{ |
79 | match [_arg],_num \{ |
74 | mov esi,dword[_arg] |
80 | mov esi, dword[_arg] |
75 | tp equ 1 |
81 | tp equ 1 |
76 | \} |
82 | \} |
77 | match =0 =dword[_arg],tp _num \{ |
83 | match =0 =dword[_arg],tp _num \{ |
78 | mov esi,dword[_arg] |
84 | mov esi, dword[_arg] |
79 | tp equ 1 |
85 | tp equ 1 |
80 | \} |
86 | \} |
81 | match =0 =word[_arg],tp _num \{ |
87 | match =0 =word[_arg],tp _num \{ |
82 | movzx esi,word[_arg] |
88 | movzx esi, word[_arg] |
83 | tp equ 1 |
89 | tp equ 1 |
84 | \} |
90 | \} |
85 | match =0 =byte[_arg],tp _num \{ |
91 | match =0 =byte[_arg],tp _num \{ |
86 | movzx esi,byte[_arg] |
92 | movzx esi, byte[_arg] |
87 | tp equ 1 |
93 | tp equ 1 |
88 | \} |
94 | \} |
89 | match =0,tp \{ |
95 | match =0,tp \{ |
90 | 'Error: specified string width is incorrect' |
96 | 'Error: specified string width is incorrect' |
91 | \} |
97 | \} |
92 | end if |
98 | end if |
93 | else |
99 | else |
94 | mov esi,0x7FFFFFFF |
100 | mov esi, 0x7FFFFFFF |
95 | end if |
101 | end if |
96 | call fdo_debug_outstr |
102 | call fdo_debug_outstr |
97 | popad |
103 | popad |
98 | popf |
104 | popf |
Line 99... | Line 105... | ||
99 | } |
105 | } |
100 | 106 | ||
101 | macro DEBUGD _sign,_dec { |
107 | macro DEBUGD _sign,_dec { |
Line 109... | Line 115... | ||
109 | DEBUGD_N _sign,,_arg |
115 | DEBUGD_N _sign,,_arg |
110 | \} |
116 | \} |
111 | } |
117 | } |
Line 112... | Line 118... | ||
112 | 118 | ||
113 | macro DEBUGD_N _sign,_num,_dec { |
119 | macro DEBUGD_N _sign,_num,_dec { |
114 | pushf |
120 | pushf |
115 | pushad |
121 | pushad |
116 | if (~_num eq) |
122 | if (~_num eq) |
117 | if (_dec eqtype eax | _dec eqtype 0) |
123 | if (_dec eqtype eax | _dec eqtype 0) |
118 | 'Error: precision allowed only for in-memory variables' |
124 | 'Error: precision allowed only for in-memory variables' |
119 | end if |
125 | end if |
Line 125... | Line 131... | ||
125 | end if |
131 | end if |
126 | end if |
132 | end if |
127 | end if |
133 | end if |
128 | if _dec eqtype eax |
134 | if _dec eqtype eax |
129 | if _dec in |
135 | if _dec in |
130 | mov eax,_dec |
136 | mov eax, _dec |
131 | else if ~_dec eq eax |
137 | else if ~_dec eq eax |
132 | if _sign = 1 |
138 | if _sign = 1 |
133 | movsx eax,_dec |
139 | movsx eax, _dec |
134 | else |
140 | else |
135 | movzx eax,_dec |
141 | movzx eax, _dec |
136 | end if |
142 | end if |
137 | end if |
143 | end if |
138 | else if _dec eqtype 0 |
144 | else if _dec eqtype 0 |
139 | mov eax,_dec |
145 | mov eax, _dec |
140 | else |
146 | else |
141 | add esp,4*8+4 |
147 | ; add esp,4*8+4 |
- | 148 | esp equ esp+4*8+4 |
|
142 | if _num eq |
149 | if _num eq |
143 | mov eax,dword _dec |
150 | mov eax, dword _dec |
144 | else if _num = 1 |
151 | else if _num = 1 |
145 | if _sign = 1 |
152 | if _sign = 1 |
146 | movsx eax,byte _dec |
153 | movsx eax, byte _dec |
147 | else |
154 | else |
148 | movzx eax,byte _dec |
155 | movzx eax, byte _dec |
149 | end if |
156 | end if |
150 | else if _num = 2 |
157 | else if _num = 2 |
151 | if _sign = 1 |
158 | if _sign = 1 |
152 | movsx eax,word _dec |
159 | movsx eax, word _dec |
153 | else |
160 | else |
154 | movzx eax,word _dec |
161 | movzx eax, word _dec |
155 | end if |
162 | end if |
156 | else |
163 | else |
157 | mov eax,dword _dec |
164 | mov eax, dword _dec |
158 | end if |
165 | end if |
- | 166 | esp equ _esp |
|
159 | sub esp,4*8+4 |
167 | ; sub esp,4*8+4 |
160 | end if |
168 | end if |
161 | mov cl,_sign |
169 | mov cl, _sign |
162 | call fdo_debug_outdec |
170 | call fdo_debug_outdec |
163 | popad |
171 | popad |
164 | popf |
172 | popf |
165 | } |
173 | } |
Line 166... | Line 174... | ||
166 | 174 | ||
167 | macro DEBUGH _sign,_hex { |
175 | macro DEBUGH _sign,_hex { |
168 | local tp |
176 | local tp |
Line 175... | Line 183... | ||
175 | DEBUGH_N _sign,,_arg |
183 | DEBUGH_N _sign,,_arg |
176 | \} |
184 | \} |
177 | } |
185 | } |
Line 178... | Line 186... | ||
178 | 186 | ||
179 | macro DEBUGH_N _sign,_num,_hex { |
187 | macro DEBUGH_N _sign,_num,_hex { |
180 | pushf |
188 | pushf |
181 | pushad |
189 | pushad |
182 | if (~_num eq) & (~_num in <1,2,3,4,5,6,7,8>) |
190 | if (~_num eq) & (~_num in <1,2,3,4,5,6,7,8>) |
183 | 'Error: 1..8 are only allowed for precision in %x' |
191 | 'Error: 1..8 are only allowed for precision in %x' |
184 | end if |
192 | end if |
185 | if _hex eqtype eax |
193 | if _hex eqtype eax |
186 | if _hex in |
194 | if _hex in |
187 | if ~_hex eq eax |
195 | if ~_hex eq eax |
188 | mov eax,_hex |
196 | mov eax, _hex |
- | 197 | end if |
|
189 | end if |
198 | mov edx, 8 |
190 | else if _hex in |
199 | else if _hex in |
191 | if ~_hex eq ax |
200 | if ~_hex eq ax |
192 | movzx eax,_hex |
201 | movzx eax, _hex |
193 | end if |
- | |
194 | shl eax,16 |
202 | end if |
195 | if (_num eq) |
203 | if (_num eq) |
196 | mov edx,4 |
204 | mov edx, 4 |
197 | end if |
205 | end if |
198 | else if _hex in |
206 | else if _hex in |
199 | if ~_hex eq al |
207 | if ~_hex eq al |
200 | movzx eax,_hex |
208 | movzx eax, _hex |
201 | end if |
- | |
202 | shl eax,24 |
209 | end if |
203 | if (_num eq) |
210 | if (_num eq) |
204 | mov edx,2 |
211 | mov edx, 2 |
205 | end if |
212 | end if |
206 | end if |
213 | end if |
207 | else if _hex eqtype 0 |
214 | else if _hex eqtype 0 |
208 | mov eax,_hex |
215 | mov eax, _hex |
209 | else |
216 | else |
- | 217 | ; add esp,4*8+4 |
|
210 | add esp,4*8+4 |
218 | esp equ esp+4*8+4 |
- | 219 | mov eax, dword _hex |
|
211 | mov eax,dword _hex |
220 | esp equ _esp |
212 | sub esp,4*8+4 |
221 | ; sub esp,4*8+4 |
213 | end if |
222 | end if |
214 | if ~_num eq |
223 | if ~_num eq |
215 | mov edx,_num |
224 | mov edx, _num |
- | 225 | else |
|
216 | else |
226 | if ~_hex eqtype eax |
- | 227 | mov edx, 8 |
|
217 | mov edx,8 |
228 | end if |
218 | end if |
229 | end if |
219 | call fdo_debug_outhex |
230 | call fdo_debug_outhex |
220 | popad |
231 | popad |
221 | popf |
232 | popf |
Line 222... | Line 233... | ||
222 | } |
233 | } |
Line 223... | Line 234... | ||
223 | 234 | ||
224 | ;----------------------------------------------------------------------------- |
235 | ;----------------------------------------------------------------------------- |
225 | 236 | ||
226 | debug_func fdo_debug_outchar |
237 | debug_func fdo_debug_outchar |
227 | debug_beginf |
238 | debug_beginf |
228 | pushad |
- | |
229 | mov cl,al |
239 | pushad |
230 | mov ebx,1 |
240 | movzx ecx, al |
231 | mov eax,63 |
241 | mov ebx, 1 |
232 | mcall |
242 | put_board |
Line 233... | Line 243... | ||
233 | popad |
243 | popad |
234 | ret |
244 | ret |
235 | debug_endf |
245 | debug_endf |
236 | 246 | ||
237 | debug_func fdo_debug_outstr |
247 | debug_func fdo_debug_outstr |
238 | debug_beginf |
248 | debug_beginf |
239 | mov eax,63 |
249 | mov ebx, 1 |
240 | mov ebx,1 |
250 | .l1: |
241 | .l1: dec esi |
251 | dec esi |
242 | js .l2 |
252 | js .l2 |
243 | mov cl,[edx] |
253 | movzx ecx, byte[edx] |
244 | or cl,cl |
254 | or cl, cl |
- | 255 | jz .l2 |
|
245 | jz .l2 |
256 | put_board |
246 | mcall |
257 | inc edx |
Line 247... | Line 258... | ||
247 | inc edx |
258 | jmp .l1 |
248 | jmp .l1 |
259 | .l2: |
249 | .l2: ret |
260 | ret |
250 | debug_endf |
261 | debug_endf |
251 | 262 | ||
252 | debug_func fdo_debug_outdec |
263 | debug_func fdo_debug_outdec |
253 | debug_beginf |
264 | debug_beginf |
254 | or cl,cl |
265 | or cl, cl |
255 | jz @f |
266 | jz @f |
256 | or eax,eax |
267 | or eax, eax |
257 | jns @f |
268 | jns @f |
258 | neg eax |
269 | neg eax |
259 | push eax |
270 | push eax |
260 | mov al,'-' |
271 | mov al, '-' |
- | 272 | call fdo_debug_outchar |
|
261 | call fdo_debug_outchar |
273 | pop eax |
262 | pop eax |
274 | @@: |
263 | @@: push 10 |
275 | movi ecx, 10 |
264 | pop ecx |
276 | push -'0' |
265 | push -'0' |
277 | .l1: |
- | 278 | xor edx, edx |
|
266 | .l1: xor edx,edx |
279 | div ecx |
267 | div ecx |
280 | push edx |
268 | push edx |
281 | test eax, eax |
269 | test eax,eax |
282 | jnz .l1 |
270 | jnz .l1 |
283 | .l2: |
- | 284 | pop eax |
|
271 | .l2: pop eax |
285 | add al, '0' |
272 | add al,'0' |
286 | jz .l3 |
Line 273... | Line 287... | ||
273 | jz .l3 |
287 | call fdo_debug_outchar |
274 | call fdo_debug_outchar |
288 | jmp .l2 |
275 | jmp .l2 |
289 | .l3: |
276 | .l3: ret |
290 | ret |
277 | debug_endf |
291 | debug_endf |
278 | 292 | ||
279 | debug_func fdo_debug_outhex |
293 | debug_func fdo_debug_outhex |
280 | __fdo_hexdigits db '0123456789ABCDEF' |
294 | __fdo_hexdigits db '0123456789ABCDEF' |
- | 295 | debug_beginf |
|
281 | debug_beginf |
296 | mov cl, dl |
282 | mov cl,dl |
297 | neg cl |
283 | neg cl |
298 | add cl, 8 |
284 | add cl,8 |
299 | shl cl, 2 |
285 | shl cl,2 |
300 | rol eax, cl |
286 | rol eax,cl |
301 | .l1: |
287 | .l1: rol eax,4 |
302 | rol eax, 4 |
288 | push eax |
303 | push eax |
289 | and eax,0x0000000F |
304 | and eax, 0x0000000F |