ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/uae_cpu/compiler/codegen_x86.cpp
(Generate patch)

Comparing BasiliskII/src/uae_cpu/compiler/codegen_x86.cpp (file contents):
Revision 1.6 by gbeauche, 2002-10-03T16:13:46Z vs.
Revision 1.31 by gbeauche, 2006-01-15T22:42:51Z

# Line 3 | Line 3
3   *
4   *  Original 68040 JIT compiler for UAE, copyright 2000-2002 Bernd Meyer
5   *
6 < *  Adaptation for Basilisk II and improvements, copyright 2000-2002
6 > *  Adaptation for Basilisk II and improvements, copyright 2000-2005
7   *    Gwenole Beauchesne
8   *
9 < *  Basilisk II (C) 1997-2002 Christian Bauer
9 > *  Basilisk II (C) 1997-2005 Christian Bauer
10 > *
11 > *  Portions related to CPU detection come from linux/arch/i386/kernel/setup.c
12   *  
13   *  This program is free software; you can redistribute it and/or modify
14   *  it under the terms of the GNU General Public License as published by
# Line 40 | Line 42
42   #define EBP_INDEX 5
43   #define ESI_INDEX 6
44   #define EDI_INDEX 7
45 + #if defined(__x86_64__)
46 + #define R8_INDEX  8
47 + #define R9_INDEX  9
48 + #define R10_INDEX 10
49 + #define R11_INDEX 11
50 + #define R12_INDEX 12
51 + #define R13_INDEX 13
52 + #define R14_INDEX 14
53 + #define R15_INDEX 15
54 + #endif
55  
56   /* The register in which subroutines return an integer return value */
57 < #define REG_RESULT 0
57 > #define REG_RESULT EAX_INDEX
58  
59   /* The registers subroutines take their first and second argument in */
60   #if defined( _MSC_VER ) && !defined( USE_NORMAL_CALLING_CONVENTION )
61   /* Handle the _fastcall parameters of ECX and EDX */
62 < #define REG_PAR1 1
63 < #define REG_PAR2 2
62 > #define REG_PAR1 ECX_INDEX
63 > #define REG_PAR2 EDX_INDEX
64 > #elif defined(__x86_64__)
65 > #define REG_PAR1 EDI_INDEX
66 > #define REG_PAR2 ESI_INDEX
67   #else
68 < #define REG_PAR1 0
69 < #define REG_PAR2 2
68 > #define REG_PAR1 EAX_INDEX
69 > #define REG_PAR2 EDX_INDEX
70   #endif
71  
72 < /* Three registers that are not used for any of the above */
58 < #define REG_NOPAR1 6
59 < #define REG_NOPAR2 5
60 < #define REG_NOPAR3 3
61 <
62 < #define REG_PC_PRE 0 /* The register we use for preloading regs.pc_p */
72 > #define REG_PC_PRE EAX_INDEX /* The register we use for preloading regs.pc_p */
73   #if defined( _MSC_VER ) && !defined( USE_NORMAL_CALLING_CONVENTION )
74 < #define REG_PC_TMP 0
74 > #define REG_PC_TMP EAX_INDEX
75   #else
76 < #define REG_PC_TMP 1 /* Another register that is not the above */
76 > #define REG_PC_TMP ECX_INDEX /* Another register that is not the above */
77   #endif
78  
79 < #define SHIFTCOUNT_NREG 1  /* Register that can be used for shiftcount.
79 > #define SHIFTCOUNT_NREG ECX_INDEX  /* Register that can be used for shiftcount.
80                                -1 if any reg will do */
81 < #define MUL_NREG1 0 /* %eax will hold the low 32 bits after a 32x32 mul */
82 < #define MUL_NREG2 2 /* %edx will hold the high 32 bits */
81 > #define MUL_NREG1 EAX_INDEX /* %eax will hold the low 32 bits after a 32x32 mul */
82 > #define MUL_NREG2 EDX_INDEX /* %edx will hold the high 32 bits */
83 >
84 > #define STACK_ALIGN             16
85 > #define STACK_OFFSET    sizeof(void *)
86  
87   uae_s8 always_used[]={4,-1};
88 + #if defined(__x86_64__)
89 + uae_s8 can_byte[]={0,1,2,3,5,6,7,8,9,10,11,12,13,14,15,-1};
90 + uae_s8 can_word[]={0,1,2,3,5,6,7,8,9,10,11,12,13,14,15,-1};
91 + #else
92   uae_s8 can_byte[]={0,1,2,3,-1};
93   uae_s8 can_word[]={0,1,2,3,5,6,7,-1};
94 + #endif
95  
96 + #if USE_OPTIMIZED_CALLS
97 + /* Make sure interpretive core does not use cpuopti */
98 + uae_u8 call_saved[]={0,0,0,1,1,1,1,1};
99 + #error FIXME: code not ready
100 + #else
101   /* cpuopti mutate instruction handlers to assume registers are saved
102     by the caller */
103 < uae_u8 call_saved[]={0,0,0,0,1,0,0,0};
103 > uae_u8 call_saved[]={0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0};
104 > #endif
105  
106   /* This *should* be the same as call_saved. But:
107     - We might not really know which registers are saved, and which aren't,
# Line 86 | Line 110 | uae_u8 call_saved[]={0,0,0,0,1,0,0,0};
110     - Special registers (such like the stack pointer) should not be "preserved"
111       by pushing, even though they are "saved" across function calls
112   */
113 < uae_u8 need_to_preserve[]={1,1,1,1,0,1,1,1};
113 > #if defined(__x86_64__)
114 > /* callee-saved registers as defined by Linux/x86_64 ABI: rbx, rbp, rsp, r12 - r15 */
115 > /* preserve r11 because it's generally used to hold pointers to functions */
116 > static const uae_u8 need_to_preserve[]={0,0,0,1,0,1,0,0,0,0,0,1,1,1,1,1};
117 > #else
118 > static const uae_u8 need_to_preserve[]={1,1,1,1,0,1,1,1};
119 > #endif
120  
121   /* Whether classes of instructions do or don't clobber the native flags */
122   #define CLOBBER_MOV
# Line 111 | Line 141 | uae_u8 need_to_preserve[]={1,1,1,1,0,1,1
141   #define CLOBBER_TEST clobber_flags()
142   #define CLOBBER_CL16
143   #define CLOBBER_CL8  
144 + #define CLOBBER_SE32
145   #define CLOBBER_SE16
146   #define CLOBBER_SE8
147 + #define CLOBBER_ZE32
148   #define CLOBBER_ZE16
149   #define CLOBBER_ZE8
150   #define CLOBBER_SW16 clobber_flags()
# Line 122 | Line 154 | uae_u8 need_to_preserve[]={1,1,1,1,0,1,1
154   #define CLOBBER_BT   clobber_flags()
155   #define CLOBBER_BSF  clobber_flags()
156  
157 + /* FIXME: disabled until that's proofread.  */
158 + #if defined(__x86_64__)
159 + #define USE_NEW_RTASM 1
160 + #endif
161 +
162 + #if USE_NEW_RTASM
163 +
164 + #if defined(__x86_64__)
165 + #define X86_TARGET_64BIT                1
166 + #endif
167 + #define X86_FLAT_REGISTERS              0
168 + #define X86_OPTIMIZE_ALU                1
169 + #define X86_OPTIMIZE_ROTSHI             1
170 + #include "codegen_x86.h"
171 +
172 + #define x86_emit_byte(B)                emit_byte(B)
173 + #define x86_emit_word(W)                emit_word(W)
174 + #define x86_emit_long(L)                emit_long(L)
175 + #define x86_emit_quad(Q)                emit_quad(Q)
176 + #define x86_get_target()                get_target()
177 + #define x86_emit_failure(MSG)   jit_fail(MSG, __FILE__, __LINE__, __FUNCTION__)
178 +
179 + static void jit_fail(const char *msg, const char *file, int line, const char *function)
180 + {
181 +        fprintf(stderr, "JIT failure in function %s from file %s at line %d: %s\n",
182 +                        function, file, line, msg);
183 +        abort();
184 + }
185 +
186 + LOWFUNC(NONE,WRITE,1,raw_push_l_r,(R4 r))
187 + {
188 + #if defined(__x86_64__)
189 +        PUSHQr(r);
190 + #else
191 +        PUSHLr(r);
192 + #endif
193 + }
194 + LENDFUNC(NONE,WRITE,1,raw_push_l_r,(R4 r))
195 +
196 + LOWFUNC(NONE,READ,1,raw_pop_l_r,(R4 r))
197 + {
198 + #if defined(__x86_64__)
199 +        POPQr(r);
200 + #else
201 +        POPLr(r);
202 + #endif
203 + }
204 + LENDFUNC(NONE,READ,1,raw_pop_l_r,(R4 r))
205 +
206 + LOWFUNC(NONE,READ,1,raw_pop_l_m,(MEMW d))
207 + {
208 + #if defined(__x86_64__)
209 +        POPQm(d, X86_NOREG, X86_NOREG, 1);
210 + #else
211 +        POPLm(d, X86_NOREG, X86_NOREG, 1);
212 + #endif
213 + }
214 + LENDFUNC(NONE,READ,1,raw_pop_l_m,(MEMW d))
215 +
216 + LOWFUNC(WRITE,NONE,2,raw_bt_l_ri,(R4 r, IMM i))
217 + {
218 +        BTLir(i, r);
219 + }
220 + LENDFUNC(WRITE,NONE,2,raw_bt_l_ri,(R4 r, IMM i))
221 +
222 + LOWFUNC(WRITE,NONE,2,raw_bt_l_rr,(R4 r, R4 b))
223 + {
224 +        BTLrr(b, r);
225 + }
226 + LENDFUNC(WRITE,NONE,2,raw_bt_l_rr,(R4 r, R4 b))
227 +
228 + LOWFUNC(WRITE,NONE,2,raw_btc_l_ri,(RW4 r, IMM i))
229 + {
230 +        BTCLir(i, r);
231 + }
232 + LENDFUNC(WRITE,NONE,2,raw_btc_l_ri,(RW4 r, IMM i))
233 +
234 + LOWFUNC(WRITE,NONE,2,raw_btc_l_rr,(RW4 r, R4 b))
235 + {
236 +        BTCLrr(b, r);
237 + }
238 + LENDFUNC(WRITE,NONE,2,raw_btc_l_rr,(RW4 r, R4 b))
239 +
240 + LOWFUNC(WRITE,NONE,2,raw_btr_l_ri,(RW4 r, IMM i))
241 + {
242 +        BTRLir(i, r);
243 + }
244 + LENDFUNC(WRITE,NONE,2,raw_btr_l_ri,(RW4 r, IMM i))
245 +
246 + LOWFUNC(WRITE,NONE,2,raw_btr_l_rr,(RW4 r, R4 b))
247 + {
248 +        BTRLrr(b, r);
249 + }
250 + LENDFUNC(WRITE,NONE,2,raw_btr_l_rr,(RW4 r, R4 b))
251 +
252 + LOWFUNC(WRITE,NONE,2,raw_bts_l_ri,(RW4 r, IMM i))
253 + {
254 +        BTSLir(i, r);
255 + }
256 + LENDFUNC(WRITE,NONE,2,raw_bts_l_ri,(RW4 r, IMM i))
257 +
258 + LOWFUNC(WRITE,NONE,2,raw_bts_l_rr,(RW4 r, R4 b))
259 + {
260 +        BTSLrr(b, r);
261 + }
262 + LENDFUNC(WRITE,NONE,2,raw_bts_l_rr,(RW4 r, R4 b))
263 +
264 + LOWFUNC(WRITE,NONE,2,raw_sub_w_ri,(RW2 d, IMM i))
265 + {
266 +        SUBWir(i, d);
267 + }
268 + LENDFUNC(WRITE,NONE,2,raw_sub_w_ri,(RW2 d, IMM i))
269 +
270 + LOWFUNC(NONE,READ,2,raw_mov_l_rm,(W4 d, MEMR s))
271 + {
272 +        MOVLmr(s, X86_NOREG, X86_NOREG, 1, d);
273 + }
274 + LENDFUNC(NONE,READ,2,raw_mov_l_rm,(W4 d, MEMR s))
275 +
276 + LOWFUNC(NONE,WRITE,2,raw_mov_l_mi,(MEMW d, IMM s))
277 + {
278 +        MOVLim(s, d, X86_NOREG, X86_NOREG, 1);
279 + }
280 + LENDFUNC(NONE,WRITE,2,raw_mov_l_mi,(MEMW d, IMM s))
281 +
282 + LOWFUNC(NONE,WRITE,2,raw_mov_w_mi,(MEMW d, IMM s))
283 + {
284 +        MOVWim(s, d, X86_NOREG, X86_NOREG, 1);
285 + }
286 + LENDFUNC(NONE,WRITE,2,raw_mov_w_mi,(MEMW d, IMM s))
287 +
288 + LOWFUNC(NONE,WRITE,2,raw_mov_b_mi,(MEMW d, IMM s))
289 + {
290 +        MOVBim(s, d, X86_NOREG, X86_NOREG, 1);
291 + }
292 + LENDFUNC(NONE,WRITE,2,raw_mov_b_mi,(MEMW d, IMM s))
293 +
294 + LOWFUNC(WRITE,RMW,2,raw_rol_b_mi,(MEMRW d, IMM i))
295 + {
296 +        ROLBim(i, d, X86_NOREG, X86_NOREG, 1);
297 + }
298 + LENDFUNC(WRITE,RMW,2,raw_rol_b_mi,(MEMRW d, IMM i))
299 +
300 + LOWFUNC(WRITE,NONE,2,raw_rol_b_ri,(RW1 r, IMM i))
301 + {
302 +        ROLBir(i, r);
303 + }
304 + LENDFUNC(WRITE,NONE,2,raw_rol_b_ri,(RW1 r, IMM i))
305 +
306 + LOWFUNC(WRITE,NONE,2,raw_rol_w_ri,(RW2 r, IMM i))
307 + {
308 +        ROLWir(i, r);
309 + }
310 + LENDFUNC(WRITE,NONE,2,raw_rol_w_ri,(RW2 r, IMM i))
311 +
312 + LOWFUNC(WRITE,NONE,2,raw_rol_l_ri,(RW4 r, IMM i))
313 + {
314 +        ROLLir(i, r);
315 + }
316 + LENDFUNC(WRITE,NONE,2,raw_rol_l_ri,(RW4 r, IMM i))
317 +
318 + LOWFUNC(WRITE,NONE,2,raw_rol_l_rr,(RW4 d, R1 r))
319 + {
320 +        ROLLrr(r, d);
321 + }
322 + LENDFUNC(WRITE,NONE,2,raw_rol_l_rr,(RW4 d, R1 r))
323 +
324 + LOWFUNC(WRITE,NONE,2,raw_rol_w_rr,(RW2 d, R1 r))
325 + {
326 +        ROLWrr(r, d);
327 + }
328 + LENDFUNC(WRITE,NONE,2,raw_rol_w_rr,(RW2 d, R1 r))
329 +
330 + LOWFUNC(WRITE,NONE,2,raw_rol_b_rr,(RW1 d, R1 r))
331 + {
332 +        ROLBrr(r, d);
333 + }
334 + LENDFUNC(WRITE,NONE,2,raw_rol_b_rr,(RW1 d, R1 r))
335 +
336 + LOWFUNC(WRITE,NONE,2,raw_shll_l_rr,(RW4 d, R1 r))
337 + {
338 +        SHLLrr(r, d);
339 + }
340 + LENDFUNC(WRITE,NONE,2,raw_shll_l_rr,(RW4 d, R1 r))
341 +
342 + LOWFUNC(WRITE,NONE,2,raw_shll_w_rr,(RW2 d, R1 r))
343 + {
344 +        SHLWrr(r, d);
345 + }
346 + LENDFUNC(WRITE,NONE,2,raw_shll_w_rr,(RW2 d, R1 r))
347 +
348 + LOWFUNC(WRITE,NONE,2,raw_shll_b_rr,(RW1 d, R1 r))
349 + {
350 +        SHLBrr(r, d);
351 + }
352 + LENDFUNC(WRITE,NONE,2,raw_shll_b_rr,(RW1 d, R1 r))
353 +
354 + LOWFUNC(WRITE,NONE,2,raw_ror_b_ri,(RW1 r, IMM i))
355 + {
356 +        RORBir(i, r);
357 + }
358 + LENDFUNC(WRITE,NONE,2,raw_ror_b_ri,(RW1 r, IMM i))
359 +
360 + LOWFUNC(WRITE,NONE,2,raw_ror_w_ri,(RW2 r, IMM i))
361 + {
362 +        RORWir(i, r);
363 + }
364 + LENDFUNC(WRITE,NONE,2,raw_ror_w_ri,(RW2 r, IMM i))
365 +
366 + LOWFUNC(WRITE,READ,2,raw_or_l_rm,(RW4 d, MEMR s))
367 + {
368 +        ORLmr(s, X86_NOREG, X86_NOREG, 1, d);
369 + }
370 + LENDFUNC(WRITE,READ,2,raw_or_l_rm,(RW4 d, MEMR s))
371 +
372 + LOWFUNC(WRITE,NONE,2,raw_ror_l_ri,(RW4 r, IMM i))
373 + {
374 +        RORLir(i, r);
375 + }
376 + LENDFUNC(WRITE,NONE,2,raw_ror_l_ri,(RW4 r, IMM i))
377 +
378 + LOWFUNC(WRITE,NONE,2,raw_ror_l_rr,(RW4 d, R1 r))
379 + {
380 +        RORLrr(r, d);
381 + }
382 + LENDFUNC(WRITE,NONE,2,raw_ror_l_rr,(RW4 d, R1 r))
383 +
384 + LOWFUNC(WRITE,NONE,2,raw_ror_w_rr,(RW2 d, R1 r))
385 + {
386 +        RORWrr(r, d);
387 + }
388 + LENDFUNC(WRITE,NONE,2,raw_ror_w_rr,(RW2 d, R1 r))
389 +
390 + LOWFUNC(WRITE,NONE,2,raw_ror_b_rr,(RW1 d, R1 r))
391 + {
392 +        RORBrr(r, d);
393 + }
394 + LENDFUNC(WRITE,NONE,2,raw_ror_b_rr,(RW1 d, R1 r))
395 +
396 + LOWFUNC(WRITE,NONE,2,raw_shrl_l_rr,(RW4 d, R1 r))
397 + {
398 +        SHRLrr(r, d);
399 + }
400 + LENDFUNC(WRITE,NONE,2,raw_shrl_l_rr,(RW4 d, R1 r))
401 +
402 + LOWFUNC(WRITE,NONE,2,raw_shrl_w_rr,(RW2 d, R1 r))
403 + {
404 +        SHRWrr(r, d);
405 + }
406 + LENDFUNC(WRITE,NONE,2,raw_shrl_w_rr,(RW2 d, R1 r))
407 +
408 + LOWFUNC(WRITE,NONE,2,raw_shrl_b_rr,(RW1 d, R1 r))
409 + {
410 +        SHRBrr(r, d);
411 + }
412 + LENDFUNC(WRITE,NONE,2,raw_shrl_b_rr,(RW1 d, R1 r))
413 +
414 + LOWFUNC(WRITE,NONE,2,raw_shra_l_rr,(RW4 d, R1 r))
415 + {
416 +        SARLrr(r, d);
417 + }
418 + LENDFUNC(WRITE,NONE,2,raw_shra_l_rr,(RW4 d, R1 r))
419 +
420 + LOWFUNC(WRITE,NONE,2,raw_shra_w_rr,(RW2 d, R1 r))
421 + {
422 +        SARWrr(r, d);
423 + }
424 + LENDFUNC(WRITE,NONE,2,raw_shra_w_rr,(RW2 d, R1 r))
425 +
426 + LOWFUNC(WRITE,NONE,2,raw_shra_b_rr,(RW1 d, R1 r))
427 + {
428 +        SARBrr(r, d);
429 + }
430 + LENDFUNC(WRITE,NONE,2,raw_shra_b_rr,(RW1 d, R1 r))
431 +
432 + LOWFUNC(WRITE,NONE,2,raw_shll_l_ri,(RW4 r, IMM i))
433 + {
434 +        SHLLir(i, r);
435 + }
436 + LENDFUNC(WRITE,NONE,2,raw_shll_l_ri,(RW4 r, IMM i))
437 +
438 + LOWFUNC(WRITE,NONE,2,raw_shll_w_ri,(RW2 r, IMM i))
439 + {
440 +        SHLWir(i, r);
441 + }
442 + LENDFUNC(WRITE,NONE,2,raw_shll_w_ri,(RW2 r, IMM i))
443 +
444 + LOWFUNC(WRITE,NONE,2,raw_shll_b_ri,(RW1 r, IMM i))
445 + {
446 +        SHLBir(i, r);
447 + }
448 + LENDFUNC(WRITE,NONE,2,raw_shll_b_ri,(RW1 r, IMM i))
449 +
450 + LOWFUNC(WRITE,NONE,2,raw_shrl_l_ri,(RW4 r, IMM i))
451 + {
452 +        SHRLir(i, r);
453 + }
454 + LENDFUNC(WRITE,NONE,2,raw_shrl_l_ri,(RW4 r, IMM i))
455 +
456 + LOWFUNC(WRITE,NONE,2,raw_shrl_w_ri,(RW2 r, IMM i))
457 + {
458 +        SHRWir(i, r);
459 + }
460 + LENDFUNC(WRITE,NONE,2,raw_shrl_w_ri,(RW2 r, IMM i))
461 +
462 + LOWFUNC(WRITE,NONE,2,raw_shrl_b_ri,(RW1 r, IMM i))
463 + {
464 +        SHRBir(i, r);
465 + }
466 + LENDFUNC(WRITE,NONE,2,raw_shrl_b_ri,(RW1 r, IMM i))
467 +
468 + LOWFUNC(WRITE,NONE,2,raw_shra_l_ri,(RW4 r, IMM i))
469 + {
470 +        SARLir(i, r);
471 + }
472 + LENDFUNC(WRITE,NONE,2,raw_shra_l_ri,(RW4 r, IMM i))
473 +
474 + LOWFUNC(WRITE,NONE,2,raw_shra_w_ri,(RW2 r, IMM i))
475 + {
476 +        SARWir(i, r);
477 + }
478 + LENDFUNC(WRITE,NONE,2,raw_shra_w_ri,(RW2 r, IMM i))
479 +
480 + LOWFUNC(WRITE,NONE,2,raw_shra_b_ri,(RW1 r, IMM i))
481 + {
482 +        SARBir(i, r);
483 + }
484 + LENDFUNC(WRITE,NONE,2,raw_shra_b_ri,(RW1 r, IMM i))
485 +
486 + LOWFUNC(WRITE,NONE,1,raw_sahf,(R2 dummy_ah))
487 + {
488 +        SAHF();
489 + }
490 + LENDFUNC(WRITE,NONE,1,raw_sahf,(R2 dummy_ah))
491 +
492 + LOWFUNC(NONE,NONE,1,raw_cpuid,(R4 dummy_eax))
493 + {
494 +        CPUID();
495 + }
496 + LENDFUNC(NONE,NONE,1,raw_cpuid,(R4 dummy_eax))
497 +
498 + LOWFUNC(READ,NONE,1,raw_lahf,(W2 dummy_ah))
499 + {
500 +        LAHF();
501 + }
502 + LENDFUNC(READ,NONE,1,raw_lahf,(W2 dummy_ah))
503 +
504 + LOWFUNC(READ,NONE,2,raw_setcc,(W1 d, IMM cc))
505 + {
506 +        SETCCir(cc, d);
507 + }
508 + LENDFUNC(READ,NONE,2,raw_setcc,(W1 d, IMM cc))
509 +
510 + LOWFUNC(READ,WRITE,2,raw_setcc_m,(MEMW d, IMM cc))
511 + {
512 +        SETCCim(cc, d, X86_NOREG, X86_NOREG, 1);
513 + }
514 + LENDFUNC(READ,WRITE,2,raw_setcc_m,(MEMW d, IMM cc))
515 +
516 + LOWFUNC(READ,NONE,3,raw_cmov_l_rr,(RW4 d, R4 s, IMM cc))
517 + {
518 +        if (have_cmov)
519 +                CMOVLrr(cc, s, d);
520 +        else { /* replacement using branch and mov */
521 + #if defined(__x86_64__)
522 +                write_log("x86-64 implementations are bound to have CMOV!\n");
523 +                abort();
524 + #endif
525 +                JCCSii(cc^1, 2);
526 +                MOVLrr(s, d);
527 +        }
528 + }
529 + LENDFUNC(READ,NONE,3,raw_cmov_l_rr,(RW4 d, R4 s, IMM cc))
530 +
531 + LOWFUNC(WRITE,NONE,2,raw_bsf_l_rr,(W4 d, R4 s))
532 + {
533 +        BSFLrr(s, d);
534 + }
535 + LENDFUNC(WRITE,NONE,2,raw_bsf_l_rr,(W4 d, R4 s))
536 +
537 + LOWFUNC(NONE,NONE,2,raw_sign_extend_32_rr,(W4 d, R4 s))
538 + {
539 +        MOVSLQrr(s, d);
540 + }
541 + LENDFUNC(NONE,NONE,2,raw_sign_extend_32_rr,(W4 d, R4 s))
542 +
543 + LOWFUNC(NONE,NONE,2,raw_sign_extend_16_rr,(W4 d, R2 s))
544 + {
545 +        MOVSWLrr(s, d);
546 + }
547 + LENDFUNC(NONE,NONE,2,raw_sign_extend_16_rr,(W4 d, R2 s))
548 +
549 + LOWFUNC(NONE,NONE,2,raw_sign_extend_8_rr,(W4 d, R1 s))
550 + {
551 +        MOVSBLrr(s, d);
552 + }
553 + LENDFUNC(NONE,NONE,2,raw_sign_extend_8_rr,(W4 d, R1 s))
554 +
555 + LOWFUNC(NONE,NONE,2,raw_zero_extend_16_rr,(W4 d, R2 s))
556 + {
557 +        MOVZWLrr(s, d);
558 + }
559 + LENDFUNC(NONE,NONE,2,raw_zero_extend_16_rr,(W4 d, R2 s))
560 +
561 + LOWFUNC(NONE,NONE,2,raw_zero_extend_8_rr,(W4 d, R1 s))
562 + {
563 +        MOVZBLrr(s, d);
564 + }
565 + LENDFUNC(NONE,NONE,2,raw_zero_extend_8_rr,(W4 d, R1 s))
566 +
567 + LOWFUNC(NONE,NONE,2,raw_imul_32_32,(RW4 d, R4 s))
568 + {
569 +        IMULLrr(s, d);
570 + }
571 + LENDFUNC(NONE,NONE,2,raw_imul_32_32,(RW4 d, R4 s))
572 +
573 + LOWFUNC(NONE,NONE,2,raw_imul_64_32,(RW4 d, RW4 s))
574 + {
575 +        if (d!=MUL_NREG1 || s!=MUL_NREG2) {
576 +        write_log("Bad register in IMUL: d=%d, s=%d\n",d,s);
577 +        abort();
578 +        }
579 +        IMULLr(s);
580 + }
581 + LENDFUNC(NONE,NONE,2,raw_imul_64_32,(RW4 d, RW4 s))
582 +
583 + LOWFUNC(NONE,NONE,2,raw_mul_64_32,(RW4 d, RW4 s))
584 + {
585 +        if (d!=MUL_NREG1 || s!=MUL_NREG2) {
586 +        write_log("Bad register in MUL: d=%d, s=%d\n",d,s);
587 +        abort();
588 +        }
589 +        MULLr(s);
590 + }
591 + LENDFUNC(NONE,NONE,2,raw_mul_64_32,(RW4 d, RW4 s))
592 +
593 + LOWFUNC(NONE,NONE,2,raw_mul_32_32,(RW4 d, R4 s))
594 + {
595 +        abort(); /* %^$&%^$%#^ x86! */
596 + }
597 + LENDFUNC(NONE,NONE,2,raw_mul_32_32,(RW4 d, R4 s))
598 +
599 + LOWFUNC(NONE,NONE,2,raw_mov_b_rr,(W1 d, R1 s))
600 + {
601 +        MOVBrr(s, d);
602 + }
603 + LENDFUNC(NONE,NONE,2,raw_mov_b_rr,(W1 d, R1 s))
604 +
605 + LOWFUNC(NONE,NONE,2,raw_mov_w_rr,(W2 d, R2 s))
606 + {
607 +        MOVWrr(s, d);
608 + }
609 + LENDFUNC(NONE,NONE,2,raw_mov_w_rr,(W2 d, R2 s))
610 +
611 + LOWFUNC(NONE,READ,4,raw_mov_l_rrm_indexed,(W4 d,R4 baser, R4 index, IMM factor))
612 + {
613 +        MOVLmr(0, baser, index, factor, d);
614 + }
615 + LENDFUNC(NONE,READ,4,raw_mov_l_rrm_indexed,(W4 d,R4 baser, R4 index, IMM factor))
616 +
617 + LOWFUNC(NONE,READ,4,raw_mov_w_rrm_indexed,(W2 d, R4 baser, R4 index, IMM factor))
618 + {
619 +        MOVWmr(0, baser, index, factor, d);
620 + }
621 + LENDFUNC(NONE,READ,4,raw_mov_w_rrm_indexed,(W2 d, R4 baser, R4 index, IMM factor))
622 +
623 + LOWFUNC(NONE,READ,4,raw_mov_b_rrm_indexed,(W1 d, R4 baser, R4 index, IMM factor))
624 + {
625 +        MOVBmr(0, baser, index, factor, d);
626 + }
627 + LENDFUNC(NONE,READ,4,raw_mov_b_rrm_indexed,(W1 d, R4 baser, R4 index, IMM factor))
628 +
629 + LOWFUNC(NONE,WRITE,4,raw_mov_l_mrr_indexed,(R4 baser, R4 index, IMM factor, R4 s))
630 + {
631 +        MOVLrm(s, 0, baser, index, factor);
632 + }
633 + LENDFUNC(NONE,WRITE,4,raw_mov_l_mrr_indexed,(R4 baser, R4 index, IMM factor, R4 s))
634 +
635 + LOWFUNC(NONE,WRITE,4,raw_mov_w_mrr_indexed,(R4 baser, R4 index, IMM factor, R2 s))
636 + {
637 +        MOVWrm(s, 0, baser, index, factor);
638 + }
639 + LENDFUNC(NONE,WRITE,4,raw_mov_w_mrr_indexed,(R4 baser, R4 index, IMM factor, R2 s))
640 +
641 + LOWFUNC(NONE,WRITE,4,raw_mov_b_mrr_indexed,(R4 baser, R4 index, IMM factor, R1 s))
642 + {
643 +        MOVBrm(s, 0, baser, index, factor);
644 + }
645 + LENDFUNC(NONE,WRITE,4,raw_mov_b_mrr_indexed,(R4 baser, R4 index, IMM factor, R1 s))
646 +
647 + LOWFUNC(NONE,WRITE,5,raw_mov_l_bmrr_indexed,(IMM base, R4 baser, R4 index, IMM factor, R4 s))
648 + {
649 +        MOVLrm(s, base, baser, index, factor);
650 + }
651 + LENDFUNC(NONE,WRITE,5,raw_mov_l_bmrr_indexed,(IMM base, R4 baser, R4 index, IMM factor, R4 s))
652 +
653 + LOWFUNC(NONE,WRITE,5,raw_mov_w_bmrr_indexed,(IMM base, R4 baser, R4 index, IMM factor, R2 s))
654 + {
655 +        MOVWrm(s, base, baser, index, factor);
656 + }
657 + LENDFUNC(NONE,WRITE,5,raw_mov_w_bmrr_indexed,(IMM base, R4 baser, R4 index, IMM factor, R2 s))
658 +
659 + LOWFUNC(NONE,WRITE,5,raw_mov_b_bmrr_indexed,(IMM base, R4 baser, R4 index, IMM factor, R1 s))
660 + {
661 +        MOVBrm(s, base, baser, index, factor);
662 + }
663 + LENDFUNC(NONE,WRITE,5,raw_mov_b_bmrr_indexed,(IMM base, R4 baser, R4 index, IMM factor, R1 s))
664 +
665 + LOWFUNC(NONE,READ,5,raw_mov_l_brrm_indexed,(W4 d, IMM base, R4 baser, R4 index, IMM factor))
666 + {
667 +        MOVLmr(base, baser, index, factor, d);
668 + }
669 + LENDFUNC(NONE,READ,5,raw_mov_l_brrm_indexed,(W4 d, IMM base, R4 baser, R4 index, IMM factor))
670 +
671 + LOWFUNC(NONE,READ,5,raw_mov_w_brrm_indexed,(W2 d, IMM base, R4 baser, R4 index, IMM factor))
672 + {
673 +        MOVWmr(base, baser, index, factor, d);
674 + }
675 + LENDFUNC(NONE,READ,5,raw_mov_w_brrm_indexed,(W2 d, IMM base, R4 baser, R4 index, IMM factor))
676 +
677 + LOWFUNC(NONE,READ,5,raw_mov_b_brrm_indexed,(W1 d, IMM base, R4 baser, R4 index, IMM factor))
678 + {
679 +        MOVBmr(base, baser, index, factor, d);
680 + }
681 + LENDFUNC(NONE,READ,5,raw_mov_b_brrm_indexed,(W1 d, IMM base, R4 baser, R4 index, IMM factor))
682 +
683 + LOWFUNC(NONE,READ,4,raw_mov_l_rm_indexed,(W4 d, IMM base, R4 index, IMM factor))
684 + {
685 +        MOVLmr(base, X86_NOREG, index, factor, d);
686 + }
687 + LENDFUNC(NONE,READ,4,raw_mov_l_rm_indexed,(W4 d, IMM base, R4 index, IMM factor))
688 +
689 + LOWFUNC(NONE,READ,5,raw_cmov_l_rm_indexed,(W4 d, IMM base, R4 index, IMM factor, IMM cond))
690 + {
691 +        if (have_cmov)
692 +                CMOVLmr(cond, base, X86_NOREG, index, factor, d);
693 +        else { /* replacement using branch and mov */
694 + #if defined(__x86_64__)
695 +                write_log("x86-64 implementations are bound to have CMOV!\n");
696 +                abort();
697 + #endif
698 +                JCCSii(cond^1, 7);
699 +                MOVLmr(base, X86_NOREG, index, factor, d);
700 +        }
701 + }
702 + LENDFUNC(NONE,READ,5,raw_cmov_l_rm_indexed,(W4 d, IMM base, R4 index, IMM factor, IMM cond))
703 +
704 + LOWFUNC(NONE,READ,3,raw_cmov_l_rm,(W4 d, IMM mem, IMM cond))
705 + {
706 +        if (have_cmov)
707 +                CMOVLmr(cond, mem, X86_NOREG, X86_NOREG, 1, d);
708 +        else { /* replacement using branch and mov */
709 + #if defined(__x86_64__)
710 +                write_log("x86-64 implementations are bound to have CMOV!\n");
711 +                abort();
712 + #endif
713 +                JCCSii(cond^1, 6);
714 +                MOVLmr(mem, X86_NOREG, X86_NOREG, 1, d);
715 +        }
716 + }
717 + LENDFUNC(NONE,READ,3,raw_cmov_l_rm,(W4 d, IMM mem, IMM cond))
718 +
719 + LOWFUNC(NONE,READ,3,raw_mov_l_rR,(W4 d, R4 s, IMM offset))
720 + {
721 +        MOVLmr(offset, s, X86_NOREG, 1, d);
722 + }
723 + LENDFUNC(NONE,READ,3,raw_mov_l_rR,(W4 d, R4 s, IMM offset))
724 +
725 + LOWFUNC(NONE,READ,3,raw_mov_w_rR,(W2 d, R4 s, IMM offset))
726 + {
727 +        MOVWmr(offset, s, X86_NOREG, 1, d);
728 + }
729 + LENDFUNC(NONE,READ,3,raw_mov_w_rR,(W2 d, R4 s, IMM offset))
730 +
731 + LOWFUNC(NONE,READ,3,raw_mov_b_rR,(W1 d, R4 s, IMM offset))
732 + {
733 +        MOVBmr(offset, s, X86_NOREG, 1, d);
734 + }
735 + LENDFUNC(NONE,READ,3,raw_mov_b_rR,(W1 d, R4 s, IMM offset))
736 +
737 + LOWFUNC(NONE,READ,3,raw_mov_l_brR,(W4 d, R4 s, IMM offset))
738 + {
739 +        MOVLmr(offset, s, X86_NOREG, 1, d);
740 + }
741 + LENDFUNC(NONE,READ,3,raw_mov_l_brR,(W4 d, R4 s, IMM offset))
742 +
743 + LOWFUNC(NONE,READ,3,raw_mov_w_brR,(W2 d, R4 s, IMM offset))
744 + {
745 +        MOVWmr(offset, s, X86_NOREG, 1, d);
746 + }
747 + LENDFUNC(NONE,READ,3,raw_mov_w_brR,(W2 d, R4 s, IMM offset))
748 +
749 + LOWFUNC(NONE,READ,3,raw_mov_b_brR,(W1 d, R4 s, IMM offset))
750 + {
751 +        MOVBmr(offset, s, X86_NOREG, 1, d);
752 + }
753 + LENDFUNC(NONE,READ,3,raw_mov_b_brR,(W1 d, R4 s, IMM offset))
754 +
755 + LOWFUNC(NONE,WRITE,3,raw_mov_l_Ri,(R4 d, IMM i, IMM offset))
756 + {
757 +        MOVLim(i, offset, d, X86_NOREG, 1);
758 + }
759 + LENDFUNC(NONE,WRITE,3,raw_mov_l_Ri,(R4 d, IMM i, IMM offset))
760 +
761 + LOWFUNC(NONE,WRITE,3,raw_mov_w_Ri,(R4 d, IMM i, IMM offset))
762 + {
763 +        MOVWim(i, offset, d, X86_NOREG, 1);
764 + }
765 + LENDFUNC(NONE,WRITE,3,raw_mov_w_Ri,(R4 d, IMM i, IMM offset))
766 +
767 + LOWFUNC(NONE,WRITE,3,raw_mov_b_Ri,(R4 d, IMM i, IMM offset))
768 + {
769 +        MOVBim(i, offset, d, X86_NOREG, 1);
770 + }
771 + LENDFUNC(NONE,WRITE,3,raw_mov_b_Ri,(R4 d, IMM i, IMM offset))
772 +
773 + LOWFUNC(NONE,WRITE,3,raw_mov_l_Rr,(R4 d, R4 s, IMM offset))
774 + {
775 +        MOVLrm(s, offset, d, X86_NOREG, 1);
776 + }
777 + LENDFUNC(NONE,WRITE,3,raw_mov_l_Rr,(R4 d, R4 s, IMM offset))
778 +
779 + LOWFUNC(NONE,WRITE,3,raw_mov_w_Rr,(R4 d, R2 s, IMM offset))
780 + {
781 +        MOVWrm(s, offset, d, X86_NOREG, 1);
782 + }
783 + LENDFUNC(NONE,WRITE,3,raw_mov_w_Rr,(R4 d, R2 s, IMM offset))
784 +
785 + LOWFUNC(NONE,WRITE,3,raw_mov_b_Rr,(R4 d, R1 s, IMM offset))
786 + {
787 +        MOVBrm(s, offset, d, X86_NOREG, 1);
788 + }
789 + LENDFUNC(NONE,WRITE,3,raw_mov_b_Rr,(R4 d, R1 s, IMM offset))
790 +
791 + LOWFUNC(NONE,NONE,3,raw_lea_l_brr,(W4 d, R4 s, IMM offset))
792 + {
793 +        LEALmr(offset, s, X86_NOREG, 1, d);
794 + }
795 + LENDFUNC(NONE,NONE,3,raw_lea_l_brr,(W4 d, R4 s, IMM offset))
796 +
797 + LOWFUNC(NONE,NONE,5,raw_lea_l_brr_indexed,(W4 d, R4 s, R4 index, IMM factor, IMM offset))
798 + {
799 +        LEALmr(offset, s, index, factor, d);
800 + }
801 + LENDFUNC(NONE,NONE,5,raw_lea_l_brr_indexed,(W4 d, R4 s, R4 index, IMM factor, IMM offset))
802 +
803 + LOWFUNC(NONE,NONE,4,raw_lea_l_rr_indexed,(W4 d, R4 s, R4 index, IMM factor))
804 + {
805 +        LEALmr(0, s, index, factor, d);
806 + }
807 + LENDFUNC(NONE,NONE,4,raw_lea_l_rr_indexed,(W4 d, R4 s, R4 index, IMM factor))
808 +
809 + LOWFUNC(NONE,WRITE,3,raw_mov_l_bRr,(R4 d, R4 s, IMM offset))
810 + {
811 +        MOVLrm(s, offset, d, X86_NOREG, 1);
812 + }
813 + LENDFUNC(NONE,WRITE,3,raw_mov_l_bRr,(R4 d, R4 s, IMM offset))
814 +
815 + LOWFUNC(NONE,WRITE,3,raw_mov_w_bRr,(R4 d, R2 s, IMM offset))
816 + {
817 +        MOVWrm(s, offset, d, X86_NOREG, 1);
818 + }
819 + LENDFUNC(NONE,WRITE,3,raw_mov_w_bRr,(R4 d, R2 s, IMM offset))
820 +
821 + LOWFUNC(NONE,WRITE,3,raw_mov_b_bRr,(R4 d, R1 s, IMM offset))
822 + {
823 +        MOVBrm(s, offset, d, X86_NOREG, 1);
824 + }
825 + LENDFUNC(NONE,WRITE,3,raw_mov_b_bRr,(R4 d, R1 s, IMM offset))
826 +
827 + LOWFUNC(NONE,NONE,1,raw_bswap_32,(RW4 r))
828 + {
829 +        BSWAPLr(r);
830 + }
831 + LENDFUNC(NONE,NONE,1,raw_bswap_32,(RW4 r))
832 +
833 + LOWFUNC(WRITE,NONE,1,raw_bswap_16,(RW2 r))
834 + {
835 +        ROLWir(8, r);
836 + }
837 + LENDFUNC(WRITE,NONE,1,raw_bswap_16,(RW2 r))
838 +
839 + LOWFUNC(NONE,NONE,2,raw_mov_l_rr,(W4 d, R4 s))
840 + {
841 +        MOVLrr(s, d);
842 + }
843 + LENDFUNC(NONE,NONE,2,raw_mov_l_rr,(W4 d, R4 s))
844 +
845 + LOWFUNC(NONE,WRITE,2,raw_mov_l_mr,(IMM d, R4 s))
846 + {
847 +        MOVLrm(s, d, X86_NOREG, X86_NOREG, 1);
848 + }
849 + LENDFUNC(NONE,WRITE,2,raw_mov_l_mr,(IMM d, R4 s))
850 +
851 + LOWFUNC(NONE,WRITE,2,raw_mov_w_mr,(IMM d, R2 s))
852 + {
853 +        MOVWrm(s, d, X86_NOREG, X86_NOREG, 1);
854 + }
855 + LENDFUNC(NONE,WRITE,2,raw_mov_w_mr,(IMM d, R2 s))
856 +
857 + LOWFUNC(NONE,READ,2,raw_mov_w_rm,(W2 d, IMM s))
858 + {
859 +        MOVWmr(s, X86_NOREG, X86_NOREG, 1, d);
860 + }
861 + LENDFUNC(NONE,READ,2,raw_mov_w_rm,(W2 d, IMM s))
862 +
863 + LOWFUNC(NONE,WRITE,2,raw_mov_b_mr,(IMM d, R1 s))
864 + {
865 +        MOVBrm(s, d, X86_NOREG, X86_NOREG, 1);
866 + }
867 + LENDFUNC(NONE,WRITE,2,raw_mov_b_mr,(IMM d, R1 s))
868 +
869 + LOWFUNC(NONE,READ,2,raw_mov_b_rm,(W1 d, IMM s))
870 + {
871 +        MOVBmr(s, X86_NOREG, X86_NOREG, 1, d);
872 + }
873 + LENDFUNC(NONE,READ,2,raw_mov_b_rm,(W1 d, IMM s))
874 +
875 + LOWFUNC(NONE,NONE,2,raw_mov_l_ri,(W4 d, IMM s))
876 + {
877 +        MOVLir(s, d);
878 + }
879 + LENDFUNC(NONE,NONE,2,raw_mov_l_ri,(W4 d, IMM s))
880 +
881 + LOWFUNC(NONE,NONE,2,raw_mov_w_ri,(W2 d, IMM s))
882 + {
883 +        MOVWir(s, d);
884 + }
885 + LENDFUNC(NONE,NONE,2,raw_mov_w_ri,(W2 d, IMM s))
886 +
887 + LOWFUNC(NONE,NONE,2,raw_mov_b_ri,(W1 d, IMM s))
888 + {
889 +        MOVBir(s, d);
890 + }
891 + LENDFUNC(NONE,NONE,2,raw_mov_b_ri,(W1 d, IMM s))
892 +
893 + LOWFUNC(RMW,RMW,2,raw_adc_l_mi,(MEMRW d, IMM s))
894 + {
895 +        ADCLim(s, d, X86_NOREG, X86_NOREG, 1);
896 + }
897 + LENDFUNC(RMW,RMW,2,raw_adc_l_mi,(MEMRW d, IMM s))
898 +
899 + LOWFUNC(WRITE,RMW,2,raw_add_l_mi,(IMM d, IMM s))
900 + {
901 +        ADDLim(s, d, X86_NOREG, X86_NOREG, 1);
902 + }
903 + LENDFUNC(WRITE,RMW,2,raw_add_l_mi,(IMM d, IMM s))
904 +
905 + LOWFUNC(WRITE,RMW,2,raw_add_w_mi,(IMM d, IMM s))
906 + {
907 +        ADDWim(s, d, X86_NOREG, X86_NOREG, 1);
908 + }
909 + LENDFUNC(WRITE,RMW,2,raw_add_w_mi,(IMM d, IMM s))
910 +
911 + LOWFUNC(WRITE,RMW,2,raw_add_b_mi,(IMM d, IMM s))
912 + {
913 +        ADDBim(s, d, X86_NOREG, X86_NOREG, 1);
914 + }
915 + LENDFUNC(WRITE,RMW,2,raw_add_b_mi,(IMM d, IMM s))
916 +
917 + LOWFUNC(WRITE,NONE,2,raw_test_l_ri,(R4 d, IMM i))
918 + {
919 +        TESTLir(i, d);
920 + }
921 + LENDFUNC(WRITE,NONE,2,raw_test_l_ri,(R4 d, IMM i))
922 +
923 + LOWFUNC(WRITE,NONE,2,raw_test_l_rr,(R4 d, R4 s))
924 + {
925 +        TESTLrr(s, d);
926 + }
927 + LENDFUNC(WRITE,NONE,2,raw_test_l_rr,(R4 d, R4 s))
928 +
929 + LOWFUNC(WRITE,NONE,2,raw_test_w_rr,(R2 d, R2 s))
930 + {
931 +        TESTWrr(s, d);
932 + }
933 + LENDFUNC(WRITE,NONE,2,raw_test_w_rr,(R2 d, R2 s))
934 +
935 + LOWFUNC(WRITE,NONE,2,raw_test_b_rr,(R1 d, R1 s))
936 + {
937 +        TESTBrr(s, d);
938 + }
939 + LENDFUNC(WRITE,NONE,2,raw_test_b_rr,(R1 d, R1 s))
940 +
941 + LOWFUNC(WRITE,NONE,2,raw_xor_l_ri,(RW4 d, IMM i))
942 + {
943 +        XORLir(i, d);
944 + }
945 + LENDFUNC(WRITE,NONE,2,raw_xor_l_ri,(RW4 d, IMM i))
946 +
947 + LOWFUNC(WRITE,NONE,2,raw_and_l_ri,(RW4 d, IMM i))
948 + {
949 +        ANDLir(i, d);
950 + }
951 + LENDFUNC(WRITE,NONE,2,raw_and_l_ri,(RW4 d, IMM i))
952 +
953 + LOWFUNC(WRITE,NONE,2,raw_and_w_ri,(RW2 d, IMM i))
954 + {
955 +        ANDWir(i, d);
956 + }
957 + LENDFUNC(WRITE,NONE,2,raw_and_w_ri,(RW2 d, IMM i))
958 +
959 + LOWFUNC(WRITE,NONE,2,raw_and_l,(RW4 d, R4 s))
960 + {
961 +        ANDLrr(s, d);
962 + }
963 + LENDFUNC(WRITE,NONE,2,raw_and_l,(RW4 d, R4 s))
964 +
965 + LOWFUNC(WRITE,NONE,2,raw_and_w,(RW2 d, R2 s))
966 + {
967 +        ANDWrr(s, d);
968 + }
969 + LENDFUNC(WRITE,NONE,2,raw_and_w,(RW2 d, R2 s))
970 +
971 + LOWFUNC(WRITE,NONE,2,raw_and_b,(RW1 d, R1 s))
972 + {
973 +        ANDBrr(s, d);
974 + }
975 + LENDFUNC(WRITE,NONE,2,raw_and_b,(RW1 d, R1 s))
976 +
977 + LOWFUNC(WRITE,NONE,2,raw_or_l_ri,(RW4 d, IMM i))
978 + {
979 +        ORLir(i, d);
980 + }
981 + LENDFUNC(WRITE,NONE,2,raw_or_l_ri,(RW4 d, IMM i))
982 +
983 + LOWFUNC(WRITE,NONE,2,raw_or_l,(RW4 d, R4 s))
984 + {
985 +        ORLrr(s, d);
986 + }
987 + LENDFUNC(WRITE,NONE,2,raw_or_l,(RW4 d, R4 s))
988 +
989 + LOWFUNC(WRITE,NONE,2,raw_or_w,(RW2 d, R2 s))
990 + {
991 +        ORWrr(s, d);
992 + }
993 + LENDFUNC(WRITE,NONE,2,raw_or_w,(RW2 d, R2 s))
994 +
995 + LOWFUNC(WRITE,NONE,2,raw_or_b,(RW1 d, R1 s))
996 + {
997 +        ORBrr(s, d);
998 + }
999 + LENDFUNC(WRITE,NONE,2,raw_or_b,(RW1 d, R1 s))
1000 +
1001 + LOWFUNC(RMW,NONE,2,raw_adc_l,(RW4 d, R4 s))
1002 + {
1003 +        ADCLrr(s, d);
1004 + }
1005 + LENDFUNC(RMW,NONE,2,raw_adc_l,(RW4 d, R4 s))
1006 +
1007 + LOWFUNC(RMW,NONE,2,raw_adc_w,(RW2 d, R2 s))
1008 + {
1009 +        ADCWrr(s, d);
1010 + }
1011 + LENDFUNC(RMW,NONE,2,raw_adc_w,(RW2 d, R2 s))
1012 +
1013 + LOWFUNC(RMW,NONE,2,raw_adc_b,(RW1 d, R1 s))
1014 + {
1015 +        ADCBrr(s, d);
1016 + }
1017 + LENDFUNC(RMW,NONE,2,raw_adc_b,(RW1 d, R1 s))
1018 +
1019 + LOWFUNC(WRITE,NONE,2,raw_add_l,(RW4 d, R4 s))
1020 + {
1021 +        ADDLrr(s, d);
1022 + }
1023 + LENDFUNC(WRITE,NONE,2,raw_add_l,(RW4 d, R4 s))
1024 +
1025 + LOWFUNC(WRITE,NONE,2,raw_add_w,(RW2 d, R2 s))
1026 + {
1027 +        ADDWrr(s, d);
1028 + }
1029 + LENDFUNC(WRITE,NONE,2,raw_add_w,(RW2 d, R2 s))
1030 +
1031 + LOWFUNC(WRITE,NONE,2,raw_add_b,(RW1 d, R1 s))
1032 + {
1033 +        ADDBrr(s, d);
1034 + }
1035 + LENDFUNC(WRITE,NONE,2,raw_add_b,(RW1 d, R1 s))
1036 +
1037 + LOWFUNC(WRITE,NONE,2,raw_sub_l_ri,(RW4 d, IMM i))
1038 + {
1039 +        SUBLir(i, d);
1040 + }
1041 + LENDFUNC(WRITE,NONE,2,raw_sub_l_ri,(RW4 d, IMM i))
1042 +
1043 + LOWFUNC(WRITE,NONE,2,raw_sub_b_ri,(RW1 d, IMM i))
1044 + {
1045 +        SUBBir(i, d);
1046 + }
1047 + LENDFUNC(WRITE,NONE,2,raw_sub_b_ri,(RW1 d, IMM i))
1048 +
1049 + LOWFUNC(WRITE,NONE,2,raw_add_l_ri,(RW4 d, IMM i))
1050 + {
1051 +        ADDLir(i, d);
1052 + }
1053 + LENDFUNC(WRITE,NONE,2,raw_add_l_ri,(RW4 d, IMM i))
1054 +
1055 + LOWFUNC(WRITE,NONE,2,raw_add_w_ri,(RW2 d, IMM i))
1056 + {
1057 +        ADDWir(i, d);
1058 + }
1059 + LENDFUNC(WRITE,NONE,2,raw_add_w_ri,(RW2 d, IMM i))
1060 +
1061 + LOWFUNC(WRITE,NONE,2,raw_add_b_ri,(RW1 d, IMM i))
1062 + {
1063 +        ADDBir(i, d);
1064 + }
1065 + LENDFUNC(WRITE,NONE,2,raw_add_b_ri,(RW1 d, IMM i))
1066 +
1067 + LOWFUNC(RMW,NONE,2,raw_sbb_l,(RW4 d, R4 s))
1068 + {
1069 +        SBBLrr(s, d);
1070 + }
1071 + LENDFUNC(RMW,NONE,2,raw_sbb_l,(RW4 d, R4 s))
1072 +
1073 + LOWFUNC(RMW,NONE,2,raw_sbb_w,(RW2 d, R2 s))
1074 + {
1075 +        SBBWrr(s, d);
1076 + }
1077 + LENDFUNC(RMW,NONE,2,raw_sbb_w,(RW2 d, R2 s))
1078 +
1079 + LOWFUNC(RMW,NONE,2,raw_sbb_b,(RW1 d, R1 s))
1080 + {
1081 +        SBBBrr(s, d);
1082 + }
1083 + LENDFUNC(RMW,NONE,2,raw_sbb_b,(RW1 d, R1 s))
1084 +
1085 + LOWFUNC(WRITE,NONE,2,raw_sub_l,(RW4 d, R4 s))
1086 + {
1087 +        SUBLrr(s, d);
1088 + }
1089 + LENDFUNC(WRITE,NONE,2,raw_sub_l,(RW4 d, R4 s))
1090 +
1091 + LOWFUNC(WRITE,NONE,2,raw_sub_w,(RW2 d, R2 s))
1092 + {
1093 +        SUBWrr(s, d);
1094 + }
1095 + LENDFUNC(WRITE,NONE,2,raw_sub_w,(RW2 d, R2 s))
1096 +
1097 + LOWFUNC(WRITE,NONE,2,raw_sub_b,(RW1 d, R1 s))
1098 + {
1099 +        SUBBrr(s, d);
1100 + }
1101 + LENDFUNC(WRITE,NONE,2,raw_sub_b,(RW1 d, R1 s))
1102 +
1103 + LOWFUNC(WRITE,NONE,2,raw_cmp_l,(R4 d, R4 s))
1104 + {
1105 +        CMPLrr(s, d);
1106 + }
1107 + LENDFUNC(WRITE,NONE,2,raw_cmp_l,(R4 d, R4 s))
1108 +
1109 + LOWFUNC(WRITE,NONE,2,raw_cmp_l_ri,(R4 r, IMM i))
1110 + {
1111 +        CMPLir(i, r);
1112 + }
1113 + LENDFUNC(WRITE,NONE,2,raw_cmp_l_ri,(R4 r, IMM i))
1114 +
1115 + LOWFUNC(WRITE,NONE,2,raw_cmp_w,(R2 d, R2 s))
1116 + {
1117 +        CMPWrr(s, d);
1118 + }
1119 + LENDFUNC(WRITE,NONE,2,raw_cmp_w,(R2 d, R2 s))
1120 +
1121 + LOWFUNC(WRITE,READ,2,raw_cmp_b_mi,(MEMR d, IMM s))
1122 + {
1123 +        CMPBim(s, d, X86_NOREG, X86_NOREG, 1);
1124 + }
1125 + LENDFUNC(WRITE,READ,2,raw_cmp_l_mi,(MEMR d, IMM s))
1126 +
1127 + LOWFUNC(WRITE,NONE,2,raw_cmp_b_ri,(R1 d, IMM i))
1128 + {
1129 +        CMPBir(i, d);
1130 + }
1131 + LENDFUNC(WRITE,NONE,2,raw_cmp_b_ri,(R1 d, IMM i))
1132 +
1133 + LOWFUNC(WRITE,NONE,2,raw_cmp_b,(R1 d, R1 s))
1134 + {
1135 +        CMPBrr(s, d);
1136 + }
1137 + LENDFUNC(WRITE,NONE,2,raw_cmp_b,(R1 d, R1 s))
1138 +
1139 + LOWFUNC(WRITE,READ,4,raw_cmp_l_rm_indexed,(R4 d, IMM offset, R4 index, IMM factor))
1140 + {
1141 +        CMPLmr(offset, X86_NOREG, index, factor, d);
1142 + }
1143 + LENDFUNC(WRITE,READ,4,raw_cmp_l_rm_indexed,(R4 d, IMM offset, R4 index, IMM factor))
1144 +
1145 + LOWFUNC(WRITE,NONE,2,raw_xor_l,(RW4 d, R4 s))
1146 + {
1147 +        XORLrr(s, d);
1148 + }
1149 + LENDFUNC(WRITE,NONE,2,raw_xor_l,(RW4 d, R4 s))
1150 +
1151 + LOWFUNC(WRITE,NONE,2,raw_xor_w,(RW2 d, R2 s))
1152 + {
1153 +        XORWrr(s, d);
1154 + }
1155 + LENDFUNC(WRITE,NONE,2,raw_xor_w,(RW2 d, R2 s))
1156 +
1157 + LOWFUNC(WRITE,NONE,2,raw_xor_b,(RW1 d, R1 s))
1158 + {
1159 +        XORBrr(s, d);
1160 + }
1161 + LENDFUNC(WRITE,NONE,2,raw_xor_b,(RW1 d, R1 s))
1162 +
1163 + LOWFUNC(WRITE,RMW,2,raw_sub_l_mi,(MEMRW d, IMM s))
1164 + {
1165 +        SUBLim(s, d, X86_NOREG, X86_NOREG, 1);
1166 + }
1167 + LENDFUNC(WRITE,RMW,2,raw_sub_l_mi,(MEMRW d, IMM s))
1168 +
1169 + LOWFUNC(WRITE,READ,2,raw_cmp_l_mi,(MEMR d, IMM s))
1170 + {
1171 +        CMPLim(s, d, X86_NOREG, X86_NOREG, 1);
1172 + }
1173 + LENDFUNC(WRITE,READ,2,raw_cmp_l_mi,(MEMR d, IMM s))
1174 +
1175 + LOWFUNC(NONE,NONE,2,raw_xchg_l_rr,(RW4 r1, RW4 r2))
1176 + {
1177 +        XCHGLrr(r2, r1);
1178 + }
1179 + LENDFUNC(NONE,NONE,2,raw_xchg_l_rr,(RW4 r1, RW4 r2))
1180 +
1181 + LOWFUNC(READ,WRITE,0,raw_pushfl,(void))
1182 + {
1183 +        PUSHF();
1184 + }
1185 + LENDFUNC(READ,WRITE,0,raw_pushfl,(void))
1186 +
1187 + LOWFUNC(WRITE,READ,0,raw_popfl,(void))
1188 + {
1189 +        POPF();
1190 + }
1191 + LENDFUNC(WRITE,READ,0,raw_popfl,(void))
1192 +
1193 + #else
1194 +
1195   const bool optimize_accum               = true;
1196   const bool optimize_imm8                = true;
1197   const bool optimize_shift_once  = true;
# Line 157 | Line 1227 | LOWFUNC(NONE,READ,1,raw_pop_l_r,(R4 r))
1227   }
1228   LENDFUNC(NONE,READ,1,raw_pop_l_r,(R4 r))
1229  
1230 + LOWFUNC(NONE,READ,1,raw_pop_l_m,(MEMW d))
1231 + {
1232 +        emit_byte(0x8f);
1233 +        emit_byte(0x05);
1234 +        emit_long(d);
1235 + }
1236 + LENDFUNC(NONE,READ,1,raw_pop_l_m,(MEMW d))
1237 +
1238   LOWFUNC(WRITE,NONE,2,raw_bt_l_ri,(R4 r, IMM i))
1239   {
1240          emit_byte(0x0f);
# Line 1071 | Line 2149 | LENDFUNC(NONE,READ,3,raw_cmov_l_rm,(W4 d
2149  
2150   LOWFUNC(NONE,READ,3,raw_mov_l_rR,(W4 d, R4 s, IMM offset))
2151   {
2152 +        Dif(!isbyte(offset)) abort();
2153      emit_byte(0x8b);
2154      emit_byte(0x40+8*d+s);
2155      emit_byte(offset);
# Line 1079 | Line 2158 | LENDFUNC(NONE,READ,3,raw_mov_l_rR,(W4 d,
2158  
2159   LOWFUNC(NONE,READ,3,raw_mov_w_rR,(W2 d, R4 s, IMM offset))
2160   {
2161 +        Dif(!isbyte(offset)) abort();
2162      emit_byte(0x66);
2163      emit_byte(0x8b);
2164      emit_byte(0x40+8*d+s);
# Line 1088 | Line 2168 | LENDFUNC(NONE,READ,3,raw_mov_w_rR,(W2 d,
2168  
2169   LOWFUNC(NONE,READ,3,raw_mov_b_rR,(W1 d, R4 s, IMM offset))
2170   {
2171 +        Dif(!isbyte(offset)) abort();
2172      emit_byte(0x8a);
2173      emit_byte(0x40+8*d+s);
2174      emit_byte(offset);
# Line 1121 | Line 2202 | LENDFUNC(NONE,READ,3,raw_mov_b_brR,(W1 d
2202  
2203   LOWFUNC(NONE,WRITE,3,raw_mov_l_Ri,(R4 d, IMM i, IMM offset))
2204   {
2205 +        Dif(!isbyte(offset)) abort();
2206      emit_byte(0xc7);
2207      emit_byte(0x40+d);
2208      emit_byte(offset);
# Line 1130 | Line 2212 | LENDFUNC(NONE,WRITE,3,raw_mov_l_Ri,(R4 d
2212  
2213   LOWFUNC(NONE,WRITE,3,raw_mov_w_Ri,(R4 d, IMM i, IMM offset))
2214   {
2215 +        Dif(!isbyte(offset)) abort();
2216      emit_byte(0x66);
2217      emit_byte(0xc7);
2218      emit_byte(0x40+d);
# Line 1140 | Line 2223 | LENDFUNC(NONE,WRITE,3,raw_mov_w_Ri,(R4 d
2223  
2224   LOWFUNC(NONE,WRITE,3,raw_mov_b_Ri,(R4 d, IMM i, IMM offset))
2225   {
2226 +        Dif(!isbyte(offset)) abort();
2227      emit_byte(0xc6);
2228      emit_byte(0x40+d);
2229      emit_byte(offset);
# Line 1149 | Line 2233 | LENDFUNC(NONE,WRITE,3,raw_mov_b_Ri,(R4 d
2233  
2234   LOWFUNC(NONE,WRITE,3,raw_mov_l_Rr,(R4 d, R4 s, IMM offset))
2235   {
2236 +        Dif(!isbyte(offset)) abort();
2237      emit_byte(0x89);
2238      emit_byte(0x40+8*s+d);
2239      emit_byte(offset);
# Line 1157 | Line 2242 | LENDFUNC(NONE,WRITE,3,raw_mov_l_Rr,(R4 d
2242  
2243   LOWFUNC(NONE,WRITE,3,raw_mov_w_Rr,(R4 d, R2 s, IMM offset))
2244   {
2245 +        Dif(!isbyte(offset)) abort();
2246      emit_byte(0x66);
2247      emit_byte(0x89);
2248      emit_byte(0x40+8*s+d);
# Line 1166 | Line 2252 | LENDFUNC(NONE,WRITE,3,raw_mov_w_Rr,(R4 d
2252  
2253   LOWFUNC(NONE,WRITE,3,raw_mov_b_Rr,(R4 d, R1 s, IMM offset))
2254   {
2255 +        Dif(!isbyte(offset)) abort();
2256      emit_byte(0x88);
2257      emit_byte(0x40+8*s+d);
2258      emit_byte(offset);
# Line 1440 | Line 2527 | LOWFUNC(WRITE,NONE,2,raw_test_b_rr,(R1 d
2527   }
2528   LENDFUNC(WRITE,NONE,2,raw_test_b_rr,(R1 d, R1 s))
2529  
2530 + LOWFUNC(WRITE,NONE,2,raw_xor_l_ri,(RW4 d, IMM i))
2531 + {
2532 +    emit_byte(0x81);
2533 +    emit_byte(0xf0+d);
2534 +    emit_long(i);
2535 + }
2536 + LENDFUNC(WRITE,NONE,2,raw_xor_l_ri,(RW4 d, IMM i))
2537 +
2538   LOWFUNC(WRITE,NONE,2,raw_and_l_ri,(RW4 d, IMM i))
2539   {
2540          if (optimize_imm8 && isbyte(i)) {
# Line 1856 | Line 2951 | LOWFUNC(NONE,NONE,2,raw_xchg_l_rr,(RW4 r
2951   LENDFUNC(NONE,NONE,2,raw_xchg_l_rr,(RW4 r1, RW4 r2))
2952  
2953   /*************************************************************************
1859 * FIXME: string-related instructions                                    *
1860 *************************************************************************/
1861
1862 LOWFUNC(WRITE,NONE,0,raw_cld,(void))
1863 {
1864        emit_byte(0xfc);
1865 }
1866 LENDFUNC(WRITE,NONE,0,raw_cld,(void))
1867
1868 LOWFUNC(WRITE,NONE,0,raw_std,(void))
1869 {
1870        emit_byte(0xfd);
1871 }
1872 LENDFUNC(WRITE,NONE,0,raw_std,(void))
1873
1874 LOWFUNC(NONE,RMW,0,raw_movs_b,(void))
1875 {
1876        emit_byte(0xa4);
1877 }
1878 LENDFUNC(NONE,RMW,0,raw_movs_b,(void))
1879
1880 LOWFUNC(NONE,RMW,0,raw_movs_l,(void))
1881 {
1882        emit_byte(0xa5);
1883 }
1884 LENDFUNC(NONE,RMW,0,raw_movs_l,(void))
1885
1886 LOWFUNC(NONE,RMW,0,raw_rep,(void))
1887 {
1888        emit_byte(0xf3);
1889 }
1890 LENDFUNC(NONE,RMW,0,raw_rep,(void))
1891
1892 LOWFUNC(NONE,RMW,0,raw_rep_movsb,(void))
1893 {
1894        raw_rep();
1895        raw_movs_b();
1896 }
1897 LENDFUNC(NONE,RMW,0,raw_rep_movsb,(void))
1898
1899 LOWFUNC(NONE,RMW,0,raw_rep_movsl,(void))
1900 {
1901        raw_rep();
1902        raw_movs_l();
1903 }
1904 LENDFUNC(NONE,RMW,0,raw_rep_movsl,(void))
1905
1906 /*************************************************************************
2954   * FIXME: mem access modes probably wrong                                *
2955   *************************************************************************/
2956  
# Line 1919 | Line 2966 | LOWFUNC(WRITE,READ,0,raw_popfl,(void))
2966   }
2967   LENDFUNC(WRITE,READ,0,raw_popfl,(void))
2968  
2969 + #endif
2970 +
2971   /*************************************************************************
2972   * Unoptimizable stuff --- jump                                          *
2973   *************************************************************************/
2974  
2975   static __inline__ void raw_call_r(R4 r)
2976   {
2977 + #if USE_NEW_RTASM
2978 +    CALLsr(r);
2979 + #else
2980      emit_byte(0xff);
2981      emit_byte(0xd0+r);
2982 + #endif
2983   }
2984  
2985   static __inline__ void raw_call_m_indexed(uae_u32 base, uae_u32 r, uae_u32 m)
2986   {
2987 + #if USE_NEW_RTASM
2988 +    CALLsm(base, X86_NOREG, r, m);
2989 + #else
2990      int mu;
2991      switch(m) {
2992       case 1: mu=0; break;
# Line 1943 | Line 2999 | static __inline__ void raw_call_m_indexe
2999      emit_byte(0x14);
3000      emit_byte(0x05+8*r+0x40*mu);
3001      emit_long(base);
3002 + #endif
3003   }
3004  
3005   static __inline__ void raw_jmp_r(R4 r)
3006   {
3007 + #if USE_NEW_RTASM
3008 +    JMPsr(r);
3009 + #else
3010      emit_byte(0xff);
3011      emit_byte(0xe0+r);
3012 + #endif
3013   }
3014  
3015   static __inline__ void raw_jmp_m_indexed(uae_u32 base, uae_u32 r, uae_u32 m)
3016   {
3017 + #if USE_NEW_RTASM
3018 +    JMPsm(base, X86_NOREG, r, m);
3019 + #else
3020      int mu;
3021      switch(m) {
3022       case 1: mu=0; break;
# Line 1965 | Line 3029 | static __inline__ void raw_jmp_m_indexed
3029      emit_byte(0x24);
3030      emit_byte(0x05+8*r+0x40*mu);
3031      emit_long(base);
3032 + #endif
3033   }
3034  
3035   static __inline__ void raw_jmp_m(uae_u32 base)
# Line 1977 | Line 3042 | static __inline__ void raw_jmp_m(uae_u32
3042  
3043   static __inline__ void raw_call(uae_u32 t)
3044   {
3045 + #if USE_NEW_RTASM
3046 +    CALLm(t);
3047 + #else
3048      emit_byte(0xe8);
3049      emit_long(t-(uae_u32)target-4);
3050 + #endif
3051   }
3052  
3053   static __inline__ void raw_jmp(uae_u32 t)
3054   {
3055 + #if USE_NEW_RTASM
3056 +    JMPm(t);
3057 + #else
3058      emit_byte(0xe9);
3059      emit_long(t-(uae_u32)target-4);
3060 + #endif
3061   }
3062  
3063   static __inline__ void raw_jl(uae_u32 t)
3064   {
3065      emit_byte(0x0f);
3066      emit_byte(0x8c);
3067 <    emit_long(t-(uae_u32)target-4);
3067 >    emit_long(t-(uintptr)target-4);
3068   }
3069  
3070   static __inline__ void raw_jz(uae_u32 t)
3071   {
3072      emit_byte(0x0f);
3073      emit_byte(0x84);
3074 <    emit_long(t-(uae_u32)target-4);
3074 >    emit_long(t-(uintptr)target-4);
3075   }
3076  
3077   static __inline__ void raw_jnz(uae_u32 t)
3078   {
3079      emit_byte(0x0f);
3080      emit_byte(0x85);
3081 <    emit_long(t-(uae_u32)target-4);
3081 >    emit_long(t-(uintptr)target-4);
3082   }
3083  
3084   static __inline__ void raw_jnz_l_oponly(void)
# Line 2055 | Line 3128 | static __inline__ void raw_nop(void)
3128      emit_byte(0x90);
3129   }
3130  
3131 + static __inline__ void raw_emit_nop_filler(int nbytes)
3132 + {
3133 +  /* Source: GNU Binutils 2.12.90.0.15 */
3134 +  /* Various efficient no-op patterns for aligning code labels.
3135 +     Note: Don't try to assemble the instructions in the comments.
3136 +     0L and 0w are not legal.  */
3137 +  static const uae_u8 f32_1[] =
3138 +    {0x90};                                                                     /* nop                                  */
3139 +  static const uae_u8 f32_2[] =
3140 +    {0x89,0xf6};                                                        /* movl %esi,%esi               */
3141 +  static const uae_u8 f32_3[] =
3142 +    {0x8d,0x76,0x00};                                           /* leal 0(%esi),%esi    */
3143 +  static const uae_u8 f32_4[] =
3144 +    {0x8d,0x74,0x26,0x00};                                      /* leal 0(%esi,1),%esi  */
3145 +  static const uae_u8 f32_5[] =
3146 +    {0x90,                                                                      /* nop                                  */
3147 +     0x8d,0x74,0x26,0x00};                                      /* leal 0(%esi,1),%esi  */
3148 +  static const uae_u8 f32_6[] =
3149 +    {0x8d,0xb6,0x00,0x00,0x00,0x00};            /* leal 0L(%esi),%esi   */
3150 +  static const uae_u8 f32_7[] =
3151 +    {0x8d,0xb4,0x26,0x00,0x00,0x00,0x00};       /* leal 0L(%esi,1),%esi */
3152 +  static const uae_u8 f32_8[] =
3153 +    {0x90,                                                                      /* nop                                  */
3154 +     0x8d,0xb4,0x26,0x00,0x00,0x00,0x00};       /* leal 0L(%esi,1),%esi */
3155 +  static const uae_u8 f32_9[] =
3156 +    {0x89,0xf6,                                                         /* movl %esi,%esi               */
3157 +     0x8d,0xbc,0x27,0x00,0x00,0x00,0x00};       /* leal 0L(%edi,1),%edi */
3158 +  static const uae_u8 f32_10[] =
3159 +    {0x8d,0x76,0x00,                                            /* leal 0(%esi),%esi    */
3160 +     0x8d,0xbc,0x27,0x00,0x00,0x00,0x00};       /* leal 0L(%edi,1),%edi */
3161 +  static const uae_u8 f32_11[] =
3162 +    {0x8d,0x74,0x26,0x00,                                       /* leal 0(%esi,1),%esi  */
3163 +     0x8d,0xbc,0x27,0x00,0x00,0x00,0x00};       /* leal 0L(%edi,1),%edi */
3164 +  static const uae_u8 f32_12[] =
3165 +    {0x8d,0xb6,0x00,0x00,0x00,0x00,                     /* leal 0L(%esi),%esi   */
3166 +     0x8d,0xbf,0x00,0x00,0x00,0x00};            /* leal 0L(%edi),%edi   */
3167 +  static const uae_u8 f32_13[] =
3168 +    {0x8d,0xb6,0x00,0x00,0x00,0x00,                     /* leal 0L(%esi),%esi   */
3169 +     0x8d,0xbc,0x27,0x00,0x00,0x00,0x00};       /* leal 0L(%edi,1),%edi */
3170 +  static const uae_u8 f32_14[] =
3171 +    {0x8d,0xb4,0x26,0x00,0x00,0x00,0x00,        /* leal 0L(%esi,1),%esi */
3172 +     0x8d,0xbc,0x27,0x00,0x00,0x00,0x00};       /* leal 0L(%edi,1),%edi */
3173 +  static const uae_u8 f32_15[] =
3174 +    {0xeb,0x0d,0x90,0x90,0x90,0x90,0x90,        /* jmp .+15; lotsa nops */
3175 +     0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90};
3176 +  static const uae_u8 f32_16[] =
3177 +    {0xeb,0x0d,0x90,0x90,0x90,0x90,0x90,        /* jmp .+15; lotsa nops */
3178 +     0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90};
3179 +  static const uae_u8 *const f32_patt[] = {
3180 +    f32_1, f32_2, f32_3, f32_4, f32_5, f32_6, f32_7, f32_8,
3181 +    f32_9, f32_10, f32_11, f32_12, f32_13, f32_14, f32_15
3182 +  };
3183 +  static const uae_u8 prefixes[4] = { 0x66, 0x66, 0x66, 0x66 };
3184 +
3185 + #if defined(__x86_64__)
3186 +  /* The recommended way to pad 64bit code is to use NOPs preceded by
3187 +     maximally four 0x66 prefixes.  Balance the size of nops.  */
3188 +  if (nbytes == 0)
3189 +          return;
3190 +
3191 +  int i;
3192 +  int nnops = (nbytes + 3) / 4;
3193 +  int len = nbytes / nnops;
3194 +  int remains = nbytes - nnops * len;
3195 +
3196 +  for (i = 0; i < remains; i++) {
3197 +          emit_block(prefixes, len);
3198 +          raw_nop();
3199 +  }
3200 +  for (; i < nnops; i++) {
3201 +          emit_block(prefixes, len - 1);
3202 +          raw_nop();
3203 +  }
3204 + #else
3205 +  int nloops = nbytes / 16;
3206 +  while (nloops-- > 0)
3207 +        emit_block(f32_16, sizeof(f32_16));
3208 +
3209 +  nbytes %= 16;
3210 +  if (nbytes)
3211 +        emit_block(f32_patt[nbytes - 1], nbytes);
3212 + #endif
3213 + }
3214 +
3215  
3216   /*************************************************************************
3217   * Flag handling, to and fro UAE flag register                           *
# Line 2068 | Line 3225 | static __inline__ void raw_flags_to_reg(
3225   {
3226    raw_lahf(0);  /* Most flags in AH */
3227    //raw_setcc(r,0); /* V flag in AL */
3228 <  raw_setcc_m((uae_u32)live.state[FLAGTMP].mem,0);
3228 >  raw_setcc_m((uintptr)live.state[FLAGTMP].mem,0);
3229    
3230   #if 1   /* Let's avoid those nasty partial register stalls */
3231 <  //raw_mov_b_mr((uae_u32)live.state[FLAGTMP].mem,r);
3232 <  raw_mov_b_mr(((uae_u32)live.state[FLAGTMP].mem)+1,r+4);
3231 >  //raw_mov_b_mr((uintptr)live.state[FLAGTMP].mem,r);
3232 >  raw_mov_b_mr(((uintptr)live.state[FLAGTMP].mem)+1,r+4);
3233    //live.state[FLAGTMP].status=CLEAN;
3234    live.state[FLAGTMP].status=INMEM;
3235    live.state[FLAGTMP].realreg=-1;
# Line 2092 | Line 3249 | static __inline__ void raw_reg_to_flags(
3249    raw_sahf(0);
3250   }
3251  
3252 + #define FLAG_NREG3 0  /* Set to -1 if any register will do */
3253 + static __inline__ void raw_flags_set_zero(int s, int tmp)
3254 + {
3255 +    raw_mov_l_rr(tmp,s);
3256 +    raw_lahf(s); /* flags into ah */
3257 +    raw_and_l_ri(s,0xffffbfff);
3258 +    raw_and_l_ri(tmp,0x00004000);
3259 +    raw_xor_l_ri(tmp,0x00004000);
3260 +    raw_or_l(s,tmp);
3261 +    raw_sahf(s);
3262 + }
3263 +
3264   #else
3265  
3266   #define FLAG_NREG1 -1  /* Set to -1 if any register will do */
# Line 2099 | Line 3268 | static __inline__ void raw_flags_to_reg(
3268   {
3269          raw_pushfl();
3270          raw_pop_l_r(r);
3271 <        raw_mov_l_mr((uae_u32)live.state[FLAGTMP].mem,r);
3271 >        raw_mov_l_mr((uintptr)live.state[FLAGTMP].mem,r);
3272   //      live.state[FLAGTMP].status=CLEAN;
3273          live.state[FLAGTMP].status=INMEM;
3274          live.state[FLAGTMP].realreg=-1;
# Line 2118 | Line 3287 | static __inline__ void raw_reg_to_flags(
3287          raw_popfl();
3288   }
3289  
3290 + #define FLAG_NREG3 -1  /* Set to -1 if any register will do */
3291 + static __inline__ void raw_flags_set_zero(int s, int tmp)
3292 + {
3293 +    raw_mov_l_rr(tmp,s);
3294 +    raw_pushfl();
3295 +    raw_pop_l_r(s);
3296 +    raw_and_l_ri(s,0xffffffbf);
3297 +    raw_and_l_ri(tmp,0x00000040);
3298 +    raw_xor_l_ri(tmp,0x00000040);
3299 +    raw_or_l(s,tmp);
3300 +    raw_push_l_r(s);
3301 +    raw_popfl();
3302 + }
3303   #endif
3304  
3305   /* Apparently, there are enough instructions between flag store and
# Line 2125 | Line 3307 | static __inline__ void raw_reg_to_flags(
3307   static __inline__ void raw_load_flagreg(uae_u32 target, uae_u32 r)
3308   {
3309   #if 1
3310 <    raw_mov_l_rm(target,(uae_u32)live.state[r].mem);
3310 >    raw_mov_l_rm(target,(uintptr)live.state[r].mem);
3311   #else
3312 <    raw_mov_b_rm(target,(uae_u32)live.state[r].mem);
3313 <    raw_mov_b_rm(target+4,((uae_u32)live.state[r].mem)+1);
3312 >    raw_mov_b_rm(target,(uintptr)live.state[r].mem);
3313 >    raw_mov_b_rm(target+4,((uintptr)live.state[r].mem)+1);
3314   #endif
3315   }
3316  
# Line 2136 | Line 3318 | static __inline__ void raw_load_flagreg(
3318   static __inline__ void raw_load_flagx(uae_u32 target, uae_u32 r)
3319   {
3320      if (live.nat[target].canbyte)
3321 <        raw_mov_b_rm(target,(uae_u32)live.state[r].mem);
3321 >        raw_mov_b_rm(target,(uintptr)live.state[r].mem);
3322      else if (live.nat[target].canword)
3323 <        raw_mov_w_rm(target,(uae_u32)live.state[r].mem);
3323 >        raw_mov_w_rm(target,(uintptr)live.state[r].mem);
3324      else
3325 <        raw_mov_l_rm(target,(uae_u32)live.state[r].mem);
3325 >        raw_mov_l_rm(target,(uintptr)live.state[r].mem);
3326   }
3327  
3328 + static __inline__ void raw_dec_sp(int off)
3329 + {
3330 +    if (off) raw_sub_l_ri(ESP_INDEX,off);
3331 + }
3332  
3333   static __inline__ void raw_inc_sp(int off)
3334   {
3335 <    raw_add_l_ri(ESP_INDEX,off);
3335 >    if (off) raw_add_l_ri(ESP_INDEX,off);
3336   }
3337  
3338   /*************************************************************************
# Line 2305 | Line 3491 | static void vec(int x, struct sigcontext
3491                  for (i=0;i<5;i++)
3492                      vecbuf[i]=target[i];
3493                  emit_byte(0xe9);
3494 <                emit_long((uae_u32)veccode-(uae_u32)target-4);
3494 >                emit_long((uintptr)veccode-(uintptr)target-4);
3495                  write_log("Create jump to %p\n",veccode);
3496              
3497                  write_log("Handled one access!\n");
# Line 2332 | Line 3518 | static void vec(int x, struct sigcontext
3518                  }
3519                  for (i=0;i<5;i++)
3520                      raw_mov_b_mi(sc.eip+i,vecbuf[i]);
3521 <                raw_mov_l_mi((uae_u32)&in_handler,0);
3521 >                raw_mov_l_mi((uintptr)&in_handler,0);
3522                  emit_byte(0xe9);
3523 <                emit_long(sc.eip+len-(uae_u32)target-4);
3523 >                emit_long(sc.eip+len-(uintptr)target-4);
3524                  in_handler=1;
3525                  target=tmp;
3526              }
# Line 2429 | Line 3615 | enum {
3615    X86_PROCESSOR_K6,
3616    X86_PROCESSOR_ATHLON,
3617    X86_PROCESSOR_PENTIUM4,
3618 +  X86_PROCESSOR_X86_64,
3619    X86_PROCESSOR_max
3620   };
3621  
# Line 2439 | Line 3626 | static const char * x86_processor_string
3626    "PentiumPro",
3627    "K6",
3628    "Athlon",
3629 <  "Pentium4"
3629 >  "Pentium4",
3630 >  "x86-64"
3631   };
3632  
3633   static struct ptt {
# Line 2456 | Line 3644 | x86_alignments[X86_PROCESSOR_max] = {
3644    { 16, 15, 16,  7, 16 },
3645    { 32,  7, 32,  7, 32 },
3646    { 16,  7, 16,  7, 16 },
3647 <  {  0,  0,  0,  0,  0 }
3647 >  {  0,  0,  0,  0,  0 },
3648 >  { 16,  7, 16,  7, 16 }
3649   };
3650  
3651   static void
# Line 2490 | Line 3679 | x86_get_cpu_vendor(struct cpuinfo_x86 *c
3679   static void
3680   cpuid(uae_u32 op, uae_u32 *eax, uae_u32 *ebx, uae_u32 *ecx, uae_u32 *edx)
3681   {
3682 <  static uae_u8 cpuid_space[256];  
3682 >  const int CPUID_SPACE = 4096;
3683 >  uae_u8* cpuid_space = (uae_u8 *)vm_acquire(CPUID_SPACE);
3684 >  if (cpuid_space == VM_MAP_FAILED)
3685 >    abort();
3686 >  vm_protect(cpuid_space, CPUID_SPACE, VM_PAGE_READ | VM_PAGE_WRITE | VM_PAGE_EXECUTE);
3687 >
3688 >  static uae_u32 s_op, s_eax, s_ebx, s_ecx, s_edx;
3689    uae_u8* tmp=get_target();
3690  
3691 +  s_op = op;
3692    set_target(cpuid_space);
3693    raw_push_l_r(0); /* eax */
3694    raw_push_l_r(1); /* ecx */
3695    raw_push_l_r(2); /* edx */
3696    raw_push_l_r(3); /* ebx */
3697 <  raw_mov_l_rm(0,(uae_u32)&op);
3697 >  raw_mov_l_rm(0,(uintptr)&s_op);
3698    raw_cpuid(0);
3699 <  if (eax != NULL) raw_mov_l_mr((uae_u32)eax,0);
3700 <  if (ebx != NULL) raw_mov_l_mr((uae_u32)ebx,3);
3701 <  if (ecx != NULL) raw_mov_l_mr((uae_u32)ecx,1);
3702 <  if (edx != NULL) raw_mov_l_mr((uae_u32)edx,2);
3699 >  raw_mov_l_mr((uintptr)&s_eax,0);
3700 >  raw_mov_l_mr((uintptr)&s_ebx,3);
3701 >  raw_mov_l_mr((uintptr)&s_ecx,1);
3702 >  raw_mov_l_mr((uintptr)&s_edx,2);
3703    raw_pop_l_r(3);
3704    raw_pop_l_r(2);
3705    raw_pop_l_r(1);
# Line 2512 | Line 3708 | cpuid(uae_u32 op, uae_u32 *eax, uae_u32
3708    set_target(tmp);
3709  
3710    ((cpuop_func*)cpuid_space)(0);
3711 +  if (eax != NULL) *eax = s_eax;
3712 +  if (ebx != NULL) *ebx = s_ebx;
3713 +  if (ecx != NULL) *ecx = s_ecx;
3714 +  if (edx != NULL) *edx = s_edx;
3715 +
3716 +  vm_release(cpuid_space, CPUID_SPACE);
3717   }
3718  
3719   static void
# Line 2520 | Line 3722 | raw_init_cpu(void)
3722    struct cpuinfo_x86 *c = &cpuinfo;
3723  
3724    /* Defaults */
3725 +  c->x86_processor = X86_PROCESSOR_max;
3726    c->x86_vendor = X86_VENDOR_UNKNOWN;
3727    c->cpuid_level = -1;                          /* CPUID not detected */
3728    c->x86_model = c->x86_mask = 0;       /* So far unknown... */
# Line 2541 | Line 3744 | raw_init_cpu(void)
3744          uae_u32 tfms, brand_id;
3745          cpuid(0x00000001, &tfms, &brand_id, NULL, &c->x86_hwcap);
3746          c->x86 = (tfms >> 8) & 15;
3747 +        if (c->x86 == 0xf)
3748 +                c->x86 += (tfms >> 20) & 0xff; /* extended family */
3749          c->x86_model = (tfms >> 4) & 15;
3750 +        if (c->x86_model == 0xf)
3751 +                c->x86_model |= (tfms >> 12) & 0xf0; /* extended model */
3752          c->x86_brand_id = brand_id & 0xff;
2546        if ( (c->x86_vendor == X86_VENDOR_AMD) &&
2547                 (c->x86 == 0xf)) {
2548          /* AMD Extended Family and Model Values */
2549          c->x86 += (tfms >> 20) & 0xff;
2550          c->x86_model += (tfms >> 12) & 0xf0;
2551        }
3753          c->x86_mask = tfms & 15;
3754    } else {
3755          /* Have CPUID level 0 only - unheard of */
3756          c->x86 = 4;
3757    }
3758  
3759 +  /* AMD-defined flags: level 0x80000001 */
3760 +  uae_u32 xlvl;
3761 +  cpuid(0x80000000, &xlvl, NULL, NULL, NULL);
3762 +  if ( (xlvl & 0xffff0000) == 0x80000000 ) {
3763 +        if ( xlvl >= 0x80000001 ) {
3764 +          uae_u32 features, extra_features;
3765 +          cpuid(0x80000001, NULL, NULL, &extra_features, &features);
3766 +          if (features & (1 << 29)) {
3767 +                /* Assume x86-64 if long mode is supported */
3768 +                c->x86_processor = X86_PROCESSOR_X86_64;
3769 +          }
3770 +          if (extra_features & (1 << 0))
3771 +                  have_lahf_lm = true;
3772 +        }
3773 +  }
3774 +          
3775    /* Canonicalize processor ID */
2559  c->x86_processor = X86_PROCESSOR_max;
3776    switch (c->x86) {
3777    case 3:
3778          c->x86_processor = X86_PROCESSOR_I386;
# Line 2577 | Line 3793 | raw_init_cpu(void)
3793            c->x86_processor = X86_PROCESSOR_PENTIUMPRO;
3794          break;
3795    case 15:
3796 <        if (c->x86_vendor == X86_VENDOR_INTEL) {
3797 <          /*  Assume any BranID >= 8 and family == 15 yields a Pentium 4 */
3798 <          if (c->x86_brand_id >= 8)
3799 <                c->x86_processor = X86_PROCESSOR_PENTIUM4;
3800 <        }
3801 <        break;
3796 >          if (c->x86_processor == X86_PROCESSOR_max) {
3797 >                  switch (c->x86_vendor) {
3798 >                  case X86_VENDOR_INTEL:
3799 >                          c->x86_processor = X86_PROCESSOR_PENTIUM4;
3800 >                          break;
3801 >                  case X86_VENDOR_AMD:
3802 >                          /* Assume a 32-bit Athlon processor if not in long mode */
3803 >                          c->x86_processor = X86_PROCESSOR_ATHLON;
3804 >                          break;
3805 >                  }
3806 >          }
3807 >          break;
3808    }
3809    if (c->x86_processor == X86_PROCESSOR_max) {
3810 <        fprintf(stderr, "Error: unknown processor type\n");
3810 >        c->x86_processor = X86_PROCESSOR_I386;
3811 >        fprintf(stderr, "Error: unknown processor type, assuming i386\n");
3812          fprintf(stderr, "  Family  : %d\n", c->x86);
3813          fprintf(stderr, "  Model   : %d\n", c->x86_model);
3814          fprintf(stderr, "  Mask    : %d\n", c->x86_mask);
3815 +        fprintf(stderr, "  Vendor  : %s [%d]\n", c->x86_vendor_id, c->x86_vendor);
3816          if (c->x86_brand_id)
3817            fprintf(stderr, "  BrandID : %02x\n", c->x86_brand_id);
2594        abort();
3818    }
3819  
3820    /* Have CMOV support? */
3821 <  have_cmov = (c->x86_hwcap & (1 << 15)) && true;
3821 >  have_cmov = c->x86_hwcap & (1 << 15);
3822  
3823    /* Can the host CPU suffer from partial register stalls? */
3824    have_rat_stall = (c->x86_vendor == X86_VENDOR_INTEL);
# Line 2618 | Line 3841 | raw_init_cpu(void)
3841                          x86_processor_string_table[c->x86_processor]);
3842   }
3843  
3844 + static bool target_check_bsf(void)
3845 + {
3846 +        bool mismatch = false;
3847 +        for (int g_ZF = 0; g_ZF <= 1; g_ZF++) {
3848 +        for (int g_CF = 0; g_CF <= 1; g_CF++) {
3849 +        for (int g_OF = 0; g_OF <= 1; g_OF++) {
3850 +        for (int g_SF = 0; g_SF <= 1; g_SF++) {
3851 +                for (int value = -1; value <= 1; value++) {
3852 +                        unsigned long flags = (g_SF << 7) | (g_OF << 11) | (g_ZF << 6) | g_CF;
3853 +                        unsigned long tmp = value;
3854 +                        __asm__ __volatile__ ("push %0; popf; bsf %1,%1; pushf; pop %0"
3855 +                                                                  : "+r" (flags), "+r" (tmp) : : "cc");
3856 +                        int OF = (flags >> 11) & 1;
3857 +                        int SF = (flags >>  7) & 1;
3858 +                        int ZF = (flags >>  6) & 1;
3859 +                        int CF = flags & 1;
3860 +                        tmp = (value == 0);
3861 +                        if (ZF != tmp || SF != g_SF || OF != g_OF || CF != g_CF)
3862 +                                mismatch = true;
3863 +                }
3864 +        }}}}
3865 +        if (mismatch)
3866 +                write_log("Target CPU defines all flags on BSF instruction\n");
3867 +        return !mismatch;
3868 + }
3869 +
3870  
3871   /*************************************************************************
3872   * FPU stuff                                                             *
# Line 2740 | Line 3989 | static __inline__ void tos_make(int r)
3989      emit_byte(0xd8+(live.tos+1)-live.spos[r]);  /* store top of stack in reg,
3990                                           and pop it*/
3991   }
3992 <    
3993 <        
3992 >
3993 > /* FP helper functions */
3994 > #if USE_NEW_RTASM
3995 > #define DEFINE_OP(NAME, GEN)                    \
3996 > static inline void raw_##NAME(uint32 m)         \
3997 > {                                               \
3998 >    GEN(m, X86_NOREG, X86_NOREG, 1);            \
3999 > }
4000 > DEFINE_OP(fstl,  FSTLm);
4001 > DEFINE_OP(fstpl, FSTPLm);
4002 > DEFINE_OP(fldl,  FLDLm);
4003 > DEFINE_OP(fildl, FILDLm);
4004 > DEFINE_OP(fistl, FISTLm);
4005 > DEFINE_OP(flds,  FLDSm);
4006 > DEFINE_OP(fsts,  FSTSm);
4007 > DEFINE_OP(fstpt, FSTPTm);
4008 > DEFINE_OP(fldt,  FLDTm);
4009 > #else
4010 > #define DEFINE_OP(NAME, OP1, OP2)               \
4011 > static inline void raw_##NAME(uint32 m)         \
4012 > {                                               \
4013 >    emit_byte(OP1);                             \
4014 >    emit_byte(OP2);                             \
4015 >    emit_long(m);                               \
4016 > }
4017 > DEFINE_OP(fstl,  0xdd, 0x15);
4018 > DEFINE_OP(fstpl, 0xdd, 0x1d);
4019 > DEFINE_OP(fldl,  0xdd, 0x05);
4020 > DEFINE_OP(fildl, 0xdb, 0x05);
4021 > DEFINE_OP(fistl, 0xdb, 0x15);
4022 > DEFINE_OP(flds,  0xd9, 0x05);
4023 > DEFINE_OP(fsts,  0xd9, 0x15);
4024 > DEFINE_OP(fstpt, 0xdb, 0x3d);
4025 > DEFINE_OP(fldt,  0xdb, 0x2d);
4026 > #endif
4027 > #undef DEFINE_OP
4028 >
4029   LOWFUNC(NONE,WRITE,2,raw_fmov_mr,(MEMW m, FR r))
4030   {
4031      make_tos(r);
4032 <    emit_byte(0xdd);
2749 <    emit_byte(0x15);
2750 <    emit_long(m);
4032 >    raw_fstl(m);
4033   }
4034   LENDFUNC(NONE,WRITE,2,raw_fmov_mr,(MEMW m, FR r))
4035  
4036   LOWFUNC(NONE,WRITE,2,raw_fmov_mr_drop,(MEMW m, FR r))
4037   {
4038      make_tos(r);
4039 <    emit_byte(0xdd);
2758 <    emit_byte(0x1d);
2759 <    emit_long(m);
4039 >    raw_fstpl(m);
4040      live.onstack[live.tos]=-1;
4041      live.tos--;
4042      live.spos[r]=-2;
# Line 2765 | Line 4045 | LENDFUNC(NONE,WRITE,2,raw_fmov_mr,(MEMW
4045  
4046   LOWFUNC(NONE,READ,2,raw_fmov_rm,(FW r, MEMR m))
4047   {
4048 <    emit_byte(0xdd);
2769 <    emit_byte(0x05);
2770 <    emit_long(m);
4048 >    raw_fldl(m);
4049      tos_make(r);
4050   }
4051   LENDFUNC(NONE,READ,2,raw_fmov_rm,(FW r, MEMR m))
4052  
4053   LOWFUNC(NONE,READ,2,raw_fmovi_rm,(FW r, MEMR m))
4054   {
4055 <    emit_byte(0xdb);
2778 <    emit_byte(0x05);
2779 <    emit_long(m);
4055 >    raw_fildl(m);
4056      tos_make(r);
4057   }
4058   LENDFUNC(NONE,READ,2,raw_fmovi_rm,(FW r, MEMR m))
# Line 2784 | Line 4060 | LENDFUNC(NONE,READ,2,raw_fmovi_rm,(FW r,
4060   LOWFUNC(NONE,WRITE,2,raw_fmovi_mr,(MEMW m, FR r))
4061   {
4062      make_tos(r);
4063 <    emit_byte(0xdb);
2788 <    emit_byte(0x15);
2789 <    emit_long(m);
4063 >    raw_fistl(m);
4064   }
4065   LENDFUNC(NONE,WRITE,2,raw_fmovi_mr,(MEMW m, FR r))
4066  
4067   LOWFUNC(NONE,READ,2,raw_fmovs_rm,(FW r, MEMR m))
4068   {
4069 <    emit_byte(0xd9);
2796 <    emit_byte(0x05);
2797 <    emit_long(m);
4069 >    raw_flds(m);
4070      tos_make(r);
4071   }
4072   LENDFUNC(NONE,READ,2,raw_fmovs_rm,(FW r, MEMR m))
# Line 2802 | Line 4074 | LENDFUNC(NONE,READ,2,raw_fmovs_rm,(FW r,
4074   LOWFUNC(NONE,WRITE,2,raw_fmovs_mr,(MEMW m, FR r))
4075   {
4076      make_tos(r);
4077 <    emit_byte(0xd9);
2806 <    emit_byte(0x15);
2807 <    emit_long(m);
4077 >    raw_fsts(m);
4078   }
4079   LENDFUNC(NONE,WRITE,2,raw_fmovs_mr,(MEMW m, FR r))
4080  
# Line 2819 | Line 4089 | LOWFUNC(NONE,WRITE,2,raw_fmov_ext_mr,(ME
4089      emit_byte(0xd9);     /* Get a copy to the top of stack */
4090      emit_byte(0xc0+rs);
4091  
4092 <    emit_byte(0xdb);  /* store and pop it */
2823 <    emit_byte(0x3d);
2824 <    emit_long(m);
4092 >    raw_fstpt(m);       /* store and pop it */
4093   }
4094   LENDFUNC(NONE,WRITE,2,raw_fmov_ext_mr,(MEMW m, FR r))
4095  
# Line 2830 | Line 4098 | LOWFUNC(NONE,WRITE,2,raw_fmov_ext_mr_dro
4098      int rs;
4099  
4100      make_tos(r);
4101 <    emit_byte(0xdb);  /* store and pop it */
2834 <    emit_byte(0x3d);
2835 <    emit_long(m);
4101 >    raw_fstpt(m);       /* store and pop it */
4102      live.onstack[live.tos]=-1;
4103      live.tos--;
4104      live.spos[r]=-2;
# Line 2841 | Line 4107 | LENDFUNC(NONE,WRITE,2,raw_fmov_ext_mr,(M
4107  
4108   LOWFUNC(NONE,READ,2,raw_fmov_ext_rm,(FW r, MEMR m))
4109   {
4110 <    emit_byte(0xdb);
2845 <    emit_byte(0x2d);
2846 <    emit_long(m);
4110 >    raw_fldt(m);
4111      tos_make(r);
4112   }
4113   LENDFUNC(NONE,READ,2,raw_fmov_ext_rm,(FW r, MEMR m))
# Line 3052 | Line 4316 | LOWFUNC(NONE,NONE,2,raw_ftwotox_rr,(FW d
4316      emit_byte(0xf0);  /* f2xm1 */
4317      emit_byte(0xdc);
4318      emit_byte(0x05);
4319 <    emit_long((uae_u32)&one);  /* Add '1' without using extra stack space */
4319 >    emit_long((uintptr)&one);  /* Add '1' without using extra stack space */
4320      emit_byte(0xd9);
4321      emit_byte(0xfd);  /* and scale it */
4322      emit_byte(0xdd);
# Line 3086 | Line 4350 | LOWFUNC(NONE,NONE,2,raw_fetox_rr,(FW d,
4350      emit_byte(0xf0);  /* f2xm1 */
4351      emit_byte(0xdc);
4352      emit_byte(0x05);
4353 <    emit_long((uae_u32)&one);  /* Add '1' without using extra stack space */
4353 >    emit_long((uintptr)&one);  /* Add '1' without using extra stack space */
4354      emit_byte(0xd9);
4355      emit_byte(0xfd);  /* and scale it */
4356      emit_byte(0xdd);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines