1 /* ======================================================================== */
2 /* ========================= LICENSING & COPYRIGHT ======================== */
3 /* ======================================================================== */
8 * A portable Motorola M680x0 processor emulation engine.
9 * Copyright 1998-2001 Karl Stenerud. All rights reserved.
11 * This code may be freely used for non-commercial purposes as long as this
12 * copyright notice remains unaltered in the source code and any binary files
13 * containing this code in compiled form.
15 * All other lisencing terms must be negotiated with the author
18 * The latest version of this code can be obtained at:
19 * http://kstenerud.cjb.net
24 /* Input file for m68kmake
25 * -----------------------
27 * All sections begin with 80 X's in a row followed by an end-of-line
29 * After this, m68kmake will expect to find one of the following section
31 * M68KMAKE_PROTOTYPE_HEADER - header for opcode handler prototypes
32 * M68KMAKE_PROTOTYPE_FOOTER - footer for opcode handler prototypes
33 * M68KMAKE_TABLE_HEADER - header for opcode handler jumptable
34 * M68KMAKE_TABLE_FOOTER - footer for opcode handler jumptable
35 * M68KMAKE_TABLE_BODY - the table itself
36 * M68KMAKE_OPCODE_HANDLER_HEADER - header for opcode handler implementation
37 * M68KMAKE_OPCODE_HANDLER_FOOTER - footer for opcode handler implementation
38 * M68KMAKE_OPCODE_HANDLER_BODY - body section for opcode handler implementation
40 * NOTE: M68KMAKE_OPCODE_HANDLER_BODY must be last in the file and
41 * M68KMAKE_TABLE_BODY must be second last in the file.
43 * The M68KMAKE_OPHANDLER_BODY section contains the opcode handler
44 * primitives themselves. Each opcode handler begins with:
45 * M68KMAKE_OP(A, B, C, D)
47 * where A is the opcode handler name, B is the size of the operation,
48 * C denotes any special processing mode, and D denotes a specific
50 * For C and D where nothing is specified, use "."
53 * M68KMAKE_OP(abcd, 8, rr, .) abcd, size 8, register to register, default EA
54 * M68KMAKE_OP(abcd, 8, mm, ax7) abcd, size 8, memory to memory, register X is A7
55 * M68KMAKE_OP(tst, 16, ., pcix) tst, size 16, PCIX addressing
57 * All opcode handler primitives end with a closing curly brace "}" at column 1
59 * NOTE: Do not place a M68KMAKE_OP() directive inside the opcode handler,
60 * and do not put a closing curly brace at column 1 unless it is
61 * marking the end of the handler!
63 * Inside the handler, m68kmake will recognize M68KMAKE_GET_OPER_xx_xx,
64 * M68KMAKE_GET_EA_xx_xx, and M68KMAKE_CC directives, and create multiple
65 * opcode handlers to handle variations in the opcode handler.
66 * Note: M68KMAKE_CC will only be interpreted in condition code opcodes.
67 * As well, M68KMAKE_GET_EA_xx_xx and M68KMAKE_GET_OPER_xx_xx will only
68 * be interpreted on instructions where the corresponding table entry
69 * specifies multiple effective addressing modes.
71 * clr 32 . . 0100001010...... A+-DXWL... U U U 12 6 4
73 * This table entry says that the clr.l opcde has 7 variations (A+-DXWL).
74 * It is run in user or supervisor mode for all CPUs, and uses 12 cycles for
75 * 68000, 6 cycles for 68010, and 4 cycles for 68020.
78 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
79 M68KMAKE_PROTOTYPE_HEADER
81 #ifndef M68KOPS__HEADER
82 #define M68KOPS__HEADER
84 /* ======================================================================== */
85 /* ============================ OPCODE HANDLERS =========================== */
86 /* ======================================================================== */
90 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
91 M68KMAKE_PROTOTYPE_FOOTER
94 /* Build the opcode handler table */
95 void m68ki_build_opcode_table(void);
97 extern void (*m68ki_instruction_jump_table[0x10000])(void); /* opcode handler jump table */
98 extern unsigned char m68ki_cycles[][0x10000];
101 /* ======================================================================== */
102 /* ============================== END OF FILE ============================= */
103 /* ======================================================================== */
105 #endif /* M68KOPS__HEADER */
109 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
110 M68KMAKE_TABLE_HEADER
112 /* ======================================================================== */
113 /* ========================= OPCODE TABLE BUILDER ========================= */
114 /* ======================================================================== */
118 #define NUM_CPU_TYPES 3
120 void (*m68ki_instruction_jump_table[0x10000])(void); /* opcode handler jump table */
121 unsigned char m68ki_cycles[NUM_CPU_TYPES][0x10000]; /* Cycles used by CPU type */
123 /* This is used to generate the opcode handler jump table */
126 void (*opcode_handler)(void); /* handler function */
127 unsigned int mask; /* mask on opcode */
128 unsigned int match; /* what to match after masking */
129 unsigned char cycles[NUM_CPU_TYPES]; /* cycles each cpu type takes */
130 } opcode_handler_struct;
133 /* Opcode handler table */
134 static opcode_handler_struct m68k_opcode_handler_table[] =
136 /* function mask match 000 010 020 */
140 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
141 M68KMAKE_TABLE_FOOTER
147 /* Build the opcode handler jump table */
148 void m68ki_build_opcode_table(void)
150 opcode_handler_struct *ostruct;
156 for(i = 0; i < 0x10000; i++)
158 /* default to illegal */
159 m68ki_instruction_jump_table[i] = m68k_op_illegal;
160 for(k=0;k<NUM_CPU_TYPES;k++)
161 m68ki_cycles[k][i] = 0;
164 ostruct = m68k_opcode_handler_table;
165 while(ostruct->mask != 0xff00)
167 for(i = 0;i < 0x10000;i++)
169 if((i & ostruct->mask) == ostruct->match)
171 m68ki_instruction_jump_table[i] = ostruct->opcode_handler;
172 for(k=0;k<NUM_CPU_TYPES;k++)
173 m68ki_cycles[k][i] = ostruct->cycles[k];
178 while(ostruct->mask == 0xff00)
180 for(i = 0;i <= 0xff;i++)
182 m68ki_instruction_jump_table[ostruct->match | i] = ostruct->opcode_handler;
183 for(k=0;k<NUM_CPU_TYPES;k++)
184 m68ki_cycles[k][ostruct->match | i] = ostruct->cycles[k];
188 while(ostruct->mask == 0xf1f8)
194 instr = ostruct->match | (i << 9) | j;
195 m68ki_instruction_jump_table[instr] = ostruct->opcode_handler;
196 for(k=0;k<NUM_CPU_TYPES;k++)
197 m68ki_cycles[k][instr] = ostruct->cycles[k];
198 if((instr & 0xf000) == 0xe000 && (!(instr & 0x20)))
199 m68ki_cycles[0][instr] = m68ki_cycles[1][instr] = ostruct->cycles[k] + ((((j-1)&7)+1)<<1);
204 while(ostruct->mask == 0xfff0)
206 for(i = 0;i <= 0x0f;i++)
208 m68ki_instruction_jump_table[ostruct->match | i] = ostruct->opcode_handler;
209 for(k=0;k<NUM_CPU_TYPES;k++)
210 m68ki_cycles[k][ostruct->match | i] = ostruct->cycles[k];
214 while(ostruct->mask == 0xf1ff)
216 for(i = 0;i <= 0x07;i++)
218 m68ki_instruction_jump_table[ostruct->match | (i << 9)] = ostruct->opcode_handler;
219 for(k=0;k<NUM_CPU_TYPES;k++)
220 m68ki_cycles[k][ostruct->match | (i << 9)] = ostruct->cycles[k];
224 while(ostruct->mask == 0xfff8)
226 for(i = 0;i <= 0x07;i++)
228 m68ki_instruction_jump_table[ostruct->match | i] = ostruct->opcode_handler;
229 for(k=0;k<NUM_CPU_TYPES;k++)
230 m68ki_cycles[k][ostruct->match | i] = ostruct->cycles[k];
234 while(ostruct->mask == 0xffff)
236 m68ki_instruction_jump_table[ostruct->match] = ostruct->opcode_handler;
237 for(k=0;k<NUM_CPU_TYPES;k++)
238 m68ki_cycles[k][ostruct->match] = ostruct->cycles[k];
244 /* ======================================================================== */
245 /* ============================== END OF FILE ============================= */
246 /* ======================================================================== */
250 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
251 M68KMAKE_OPCODE_HANDLER_HEADER
255 /* ======================================================================== */
256 /* ========================= INSTRUCTION HANDLERS ========================= */
257 /* ======================================================================== */
261 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
262 M68KMAKE_OPCODE_HANDLER_FOOTER
264 /* ======================================================================== */
265 /* ============================== END OF FILE ============================= */
266 /* ======================================================================== */
270 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
273 The following table is arranged as follows:
275 name: Opcode mnemonic
279 spec proc: Special processing mode:
283 rr: register to register
285 er: effective address to register
286 re: register to effective address
287 dd: data register to data register
288 da: data register to address register
289 aa: address register to address register
290 cr: control register to register
291 rc: register to control register
292 toc: to condition code register
293 tos: to status register
294 tou: to user stack pointer
295 frc: from condition code register
296 frs: from status register
297 fru: from user stack pointer
298 * for move.x, the special processing mode is a specific
299 destination effective addressing mode.
301 spec ea: Specific effective addressing mode:
306 ai: address register indirect
307 pi: address register indirect with postincrement
308 pd: address register indirect with predecrement
309 di: address register indirect with displacement
310 ix: address register indirect with index
311 aw: absolute word address
312 al: absolute long address
313 pcdi: program counter relative with displacement
314 pcix: program counter relative with index
315 a7: register specified in instruction is A7
316 ax7: register field X of instruction is A7
317 ay7: register field Y of instruction is A7
318 axy7: register fields X and Y of instruction are A7
320 bit pattern: Pattern to recognize this opcode. "." means don't care.
322 allowed ea: List of allowed addressing modes:
324 A: address register indirect
325 +: ARI (address register indirect) with postincrement
326 -: ARI with predecrement
327 D: ARI with displacement
329 W: absolute word address
330 L: absolute long address
331 d: program counter indirect with displacement
332 x: program counter indirect with index
334 mode: CPU operating mode for each cpu type. U = user or supervisor,
335 S = supervisor only, "." = opcode not present.
337 cpu cycles: Base number of cycles required to execute this opcode on the
339 Use "." if CPU does not have this opcode.
343 spec spec allowed ea mode cpu cycles
344 name size proc ea bit pattern A+-DXWLdxI 0 1 2 000 010 020 comments
345 ====== ==== ==== ==== ================ ========== = = = === === === =============
347 1010 0 . . 1010............ .......... U U U 4 4 4
348 1111 0 . . 1111............ .......... U U U 4 4 4
349 abcd 8 rr . 1100...100000... .......... U U U 6 6 4
350 abcd 8 mm ax7 1100111100001... .......... U U U 18 18 16
351 abcd 8 mm ay7 1100...100001111 .......... U U U 18 18 16
352 abcd 8 mm axy7 1100111100001111 .......... U U U 18 18 16
353 abcd 8 mm . 1100...100001... .......... U U U 18 18 16
354 add 8 er d 1101...000000... .......... U U U 4 4 2
355 add 8 er . 1101...000...... A+-DXWLdxI U U U 4 4 2
356 add 16 er d 1101...001000... .......... U U U 4 4 2
357 add 16 er a 1101...001001... .......... U U U 4 4 2
358 add 16 er . 1101...001...... A+-DXWLdxI U U U 4 4 2
359 add 32 er d 1101...010000... .......... U U U 6 6 2
360 add 32 er a 1101...010001... .......... U U U 6 6 2
361 add 32 er . 1101...010...... A+-DXWLdxI U U U 6 6 2
362 add 8 re . 1101...100...... A+-DXWL... U U U 8 8 4
363 add 16 re . 1101...101...... A+-DXWL... U U U 8 8 4
364 add 32 re . 1101...110...... A+-DXWL... U U U 12 12 4
365 adda 16 . d 1101...011000... .......... U U U 8 8 2
366 adda 16 . a 1101...011001... .......... U U U 8 8 2
367 adda 16 . . 1101...011...... A+-DXWLdxI U U U 8 8 2
368 adda 32 . d 1101...111000... .......... U U U 6 6 2
369 adda 32 . a 1101...111001... .......... U U U 6 6 2
370 adda 32 . . 1101...111...... A+-DXWLdxI U U U 6 6 2
371 addi 8 . d 0000011000000... .......... U U U 8 8 2
372 addi 8 . . 0000011000...... A+-DXWL... U U U 12 12 4
373 addi 16 . d 0000011001000... .......... U U U 8 8 2
374 addi 16 . . 0000011001...... A+-DXWL... U U U 12 12 4
375 addi 32 . d 0000011010000... .......... U U U 16 14 2
376 addi 32 . . 0000011010...... A+-DXWL... U U U 20 20 4
377 addq 8 . d 0101...000000... .......... U U U 4 4 2
378 addq 8 . . 0101...000...... A+-DXWL... U U U 8 8 4
379 addq 16 . d 0101...001000... .......... U U U 4 4 2
380 addq 16 . a 0101...001001... .......... U U U 4 4 2
381 addq 16 . . 0101...001...... A+-DXWL... U U U 8 8 4
382 addq 32 . d 0101...010000... .......... U U U 8 8 2
383 addq 32 . a 0101...010001... .......... U U U 8 8 2
384 addq 32 . . 0101...010...... A+-DXWL... U U U 12 12 4
385 addx 8 rr . 1101...100000... .......... U U U 4 4 2
386 addx 16 rr . 1101...101000... .......... U U U 4 4 2
387 addx 32 rr . 1101...110000... .......... U U U 8 6 2
388 addx 8 mm ax7 1101111100001... .......... U U U 18 18 12
389 addx 8 mm ay7 1101...100001111 .......... U U U 18 18 12
390 addx 8 mm axy7 1101111100001111 .......... U U U 18 18 12
391 addx 8 mm . 1101...100001... .......... U U U 18 18 12
392 addx 16 mm . 1101...101001... .......... U U U 18 18 12
393 addx 32 mm . 1101...110001... .......... U U U 30 30 12
394 and 8 er d 1100...000000... .......... U U U 4 4 2
395 and 8 er . 1100...000...... A+-DXWLdxI U U U 4 4 2
396 and 16 er d 1100...001000... .......... U U U 4 4 2
397 and 16 er . 1100...001...... A+-DXWLdxI U U U 4 4 2
398 and 32 er d 1100...010000... .......... U U U 6 6 2
399 and 32 er . 1100...010...... A+-DXWLdxI U U U 6 6 2
400 and 8 re . 1100...100...... A+-DXWL... U U U 8 8 4
401 and 16 re . 1100...101...... A+-DXWL... U U U 8 8 4
402 and 32 re . 1100...110...... A+-DXWL... U U U 12 12 4
403 andi 16 toc . 0000001000111100 .......... U U U 20 16 12
404 andi 16 tos . 0000001001111100 .......... S S S 20 16 12
405 andi 8 . d 0000001000000... .......... U U U 8 8 2
406 andi 8 . . 0000001000...... A+-DXWL... U U U 12 12 4
407 andi 16 . d 0000001001000... .......... U U U 8 8 2
408 andi 16 . . 0000001001...... A+-DXWL... U U U 12 12 4
409 andi 32 . d 0000001010000... .......... U U U 14 14 2
410 andi 32 . . 0000001010...... A+-DXWL... U U U 20 20 4
411 asr 8 s . 1110...000000... .......... U U U 6 6 6
412 asr 16 s . 1110...001000... .......... U U U 6 6 6
413 asr 32 s . 1110...010000... .......... U U U 8 8 6
414 asr 8 r . 1110...000100... .......... U U U 6 6 6
415 asr 16 r . 1110...001100... .......... U U U 6 6 6
416 asr 32 r . 1110...010100... .......... U U U 8 8 6
417 asr 16 . . 1110000011...... A+-DXWL... U U U 8 8 5
418 asl 8 s . 1110...100000... .......... U U U 6 6 8
419 asl 16 s . 1110...101000... .......... U U U 6 6 8
420 asl 32 s . 1110...110000... .......... U U U 8 8 8
421 asl 8 r . 1110...100100... .......... U U U 6 6 8
422 asl 16 r . 1110...101100... .......... U U U 6 6 8
423 asl 32 r . 1110...110100... .......... U U U 8 8 8
424 asl 16 . . 1110000111...... A+-DXWL... U U U 8 8 6
425 bcc 8 . . 0110............ .......... U U U 8 8 6
426 bcc 16 . . 0110....00000000 .......... U U U 10 10 6
427 bcc 32 . . 0110....11111111 .......... . . U . . 6
428 bchg 8 r . 0000...101...... A+-DXWL... U U U 8 8 4
429 bchg 32 r d 0000...101000... .......... U U U 8 8 4
430 bchg 8 s . 0000100001...... A+-DXWL... U U U 12 12 4
431 bchg 32 s d 0000100001000... .......... U U U 12 12 4
432 bclr 8 r . 0000...110...... A+-DXWL... U U U 8 10 4
433 bclr 32 r d 0000...110000... .......... U U U 10 10 4
434 bclr 8 s . 0000100010...... A+-DXWL... U U U 12 12 4
435 bclr 32 s d 0000100010000... .......... U U U 14 14 4
436 bfchg 32 . d 1110101011000... .......... . . U . . 12 timing not quite correct
437 bfchg 32 . . 1110101011...... A..DXWL... . . U . . 20
438 bfclr 32 . d 1110110011000... .......... . . U . . 12
439 bfclr 32 . . 1110110011...... A..DXWL... . . U . . 20
440 bfexts 32 . d 1110101111000... .......... . . U . . 8
441 bfexts 32 . . 1110101111...... A..DXWLdx. . . U . . 15
442 bfextu 32 . d 1110100111000... .......... . . U . . 8
443 bfextu 32 . . 1110100111...... A..DXWLdx. . . U . . 15
444 bfffo 32 . d 1110110111000... .......... . . U . . 18
445 bfffo 32 . . 1110110111...... A..DXWLdx. . . U . . 28
446 bfins 32 . d 1110111111000... .......... . . U . . 10
447 bfins 32 . . 1110111111...... A..DXWL... . . U . . 17
448 bfset 32 . d 1110111011000... .......... . . U . . 12
449 bfset 32 . . 1110111011...... A..DXWL... . . U . . 20
450 bftst 32 . d 1110100011000... .......... . . U . . 6
451 bftst 32 . . 1110100011...... A..DXWLdx. . . U . . 13
452 bkpt 0 . . 0100100001001... .......... . U U . 10 10
453 bra 8 . . 01100000........ .......... U U U 10 10 10
454 bra 16 . . 0110000000000000 .......... U U U 10 10 10
455 bra 32 . . 0110000011111111 .......... U U U . . 10
456 bset 32 r d 0000...111000... .......... U U U 8 8 4
457 bset 8 r . 0000...111...... A+-DXWL... U U U 8 8 4
458 bset 8 s . 0000100011...... A+-DXWL... U U U 12 12 4
459 bset 32 s d 0000100011000... .......... U U U 12 12 4
460 bsr 8 . . 01100001........ .......... U U U 18 18 7
461 bsr 16 . . 0110000100000000 .......... U U U 18 18 7
462 bsr 32 . . 0110000111111111 .......... . . U . . 7
463 btst 8 r . 0000...100...... A+-DXWLdxI U U U 4 4 4
464 btst 32 r d 0000...100000... .......... U U U 6 6 4
465 btst 8 s . 0000100000...... A+-DXWLdx. U U U 8 8 4
466 btst 32 s d 0000100000000... .......... U U U 10 10 4
467 callm 32 . . 0000011011...... A..DXWLdx. . . U . . 60 not properly emulated
468 cas 8 . . 0000101011...... A+-DXWL... . . U . . 12
469 cas 16 . . 0000110011...... A+-DXWL... . . U . . 12
470 cas 32 . . 0000111011...... A+-DXWL... . . U . . 12
471 cas2 16 . . 0000110011111100 .......... . . U . . 12
472 cas2 32 . . 0000111011111100 .......... . . U . . 12
473 chk 16 . d 0100...110000... .......... U U U 10 8 8
474 chk 16 . . 0100...110...... A+-DXWLdxI U U U 10 8 8
475 chk 32 . d 0100...100000... .......... . . U . . 8
476 chk 32 . . 0100...100...... A+-DXWLdxI . . U . . 8
477 chk2cmp2 8 . . 0000000011...... A..DXWLdx. . . U . . 18
478 chk2cmp2 16 . . 0000001011...... A..DXWLdx. . . U . . 18
479 chk2cmp2 32 . . 0000010011...... A..DXWLdx. . . U . . 18
480 clr 8 . d 0100001000000... .......... U U U 4 4 2
481 clr 8 . . 0100001000...... A+-DXWL... U U U 8 4 4
482 clr 16 . d 0100001001000... .......... U U U 4 4 2
483 clr 16 . . 0100001001...... A+-DXWL... U U U 8 4 4
484 clr 32 . d 0100001010000... .......... U U U 6 6 2
485 clr 32 . . 0100001010...... A+-DXWL... U U U 12 6 4
486 cmp 8 . d 1011...000000... .......... U U U 4 4 2
487 cmp 8 . . 1011...000...... A+-DXWLdxI U U U 4 4 2
488 cmp 16 . d 1011...001000... .......... U U U 4 4 2
489 cmp 16 . a 1011...001001... .......... U U U 4 4 2
490 cmp 16 . . 1011...001...... A+-DXWLdxI U U U 4 4 2
491 cmp 32 . d 1011...010000... .......... U U U 6 6 2
492 cmp 32 . a 1011...010001... .......... U U U 6 6 2
493 cmp 32 . . 1011...010...... A+-DXWLdxI U U U 6 6 2
494 cmpa 16 . d 1011...011000... .......... U U U 6 6 4
495 cmpa 16 . a 1011...011001... .......... U U U 6 6 4
496 cmpa 16 . . 1011...011...... A+-DXWLdxI U U U 6 6 4
497 cmpa 32 . d 1011...111000... .......... U U U 6 6 4
498 cmpa 32 . a 1011...111001... .......... U U U 6 6 4
499 cmpa 32 . . 1011...111...... A+-DXWLdxI U U U 6 6 4
500 cmpi 8 . d 0000110000000... .......... U U U 8 8 2
501 cmpi 8 . . 0000110000...... A+-DXWL... U U U 8 8 2
502 cmpi 8 . pcdi 0000110000111010 .......... . . U . . 7
503 cmpi 8 . pcix 0000110000111011 .......... . . U . . 9
504 cmpi 16 . d 0000110001000... .......... U U U 8 8 2
505 cmpi 16 . . 0000110001...... A+-DXWL... U U U 8 8 2
506 cmpi 16 . pcdi 0000110001111010 .......... . . U . . 7
507 cmpi 16 . pcix 0000110001111011 .......... . . U . . 9
508 cmpi 32 . d 0000110010000... .......... U U U 14 12 2
509 cmpi 32 . . 0000110010...... A+-DXWL... U U U 12 12 2
510 cmpi 32 . pcdi 0000110010111010 .......... . . U . . 7
511 cmpi 32 . pcix 0000110010111011 .......... . . U . . 9
512 cmpm 8 . ax7 1011111100001... .......... U U U 12 12 9
513 cmpm 8 . ay7 1011...100001111 .......... U U U 12 12 9
514 cmpm 8 . axy7 1011111100001111 .......... U U U 12 12 9
515 cmpm 8 . . 1011...100001... .......... U U U 12 12 9
516 cmpm 16 . . 1011...101001... .......... U U U 12 12 9
517 cmpm 32 . . 1011...110001... .......... U U U 20 20 9
518 cpbcc 32 . . 1111...01....... .......... . . U . . 4 unemulated
519 cpdbcc 32 . . 1111...001001... .......... . . U . . 4 unemulated
520 cpgen 32 . . 1111...000...... .......... . . U . . 4 unemulated
521 cpscc 32 . . 1111...001...... .......... . . U . . 4 unemulated
522 cptrapcc 32 . . 1111...001111... .......... . . U . . 4 unemulated
523 dbt 16 . . 0101000011001... .......... U U U 12 12 6
524 dbf 16 . . 0101000111001... .......... U U U 14 14 6
525 dbcc 16 . . 0101....11001... .......... U U U 12 12 6
526 divs 16 . d 1000...111000... .......... U U U 158 122 56
527 divs 16 . . 1000...111...... A+-DXWLdxI U U U 158 122 56
528 divu 16 . d 1000...011000... .......... U U U 140 108 44
529 divu 16 . . 1000...011...... A+-DXWLdxI U U U 140 108 44
530 divl 32 . d 0100110001000... .......... . . U . . 84
531 divl 32 . . 0100110001...... A+-DXWLdxI . . U . . 84
532 eor 8 . d 1011...100000... .......... U U U 4 4 2
533 eor 8 . . 1011...100...... A+-DXWL... U U U 8 8 4
534 eor 16 . d 1011...101000... .......... U U U 4 4 2
535 eor 16 . . 1011...101...... A+-DXWL... U U U 8 8 4
536 eor 32 . d 1011...110000... .......... U U U 8 6 2
537 eor 32 . . 1011...110...... A+-DXWL... U U U 12 12 4
538 eori 16 toc . 0000101000111100 .......... U U U 20 16 12
539 eori 16 tos . 0000101001111100 .......... S S S 20 16 12
540 eori 8 . d 0000101000000... .......... U U U 8 8 2
541 eori 8 . . 0000101000...... A+-DXWL... U U U 12 12 4
542 eori 16 . d 0000101001000... .......... U U U 8 8 2
543 eori 16 . . 0000101001...... A+-DXWL... U U U 12 12 4
544 eori 32 . d 0000101010000... .......... U U U 16 14 2
545 eori 32 . . 0000101010...... A+-DXWL... U U U 20 20 4
546 exg 32 dd . 1100...101000... .......... U U U 6 6 2
547 exg 32 aa . 1100...101001... .......... U U U 6 6 2
548 exg 32 da . 1100...110001... .......... U U U 6 6 2
549 ext 16 . . 0100100010000... .......... U U U 4 4 4
550 ext 32 . . 0100100011000... .......... U U U 4 4 4
551 extb 32 . . 0100100111000... .......... . . U . . 4
552 illegal 0 . . 0100101011111100 .......... U U U 4 4 4
553 jmp 32 . . 0100111011...... A..DXWLdx. U U U 4 4 0
554 jsr 32 . . 0100111010...... A..DXWLdx. U U U 12 12 0
555 lea 32 . . 0100...111...... A..DXWLdx. U U U 0 0 2
556 link 16 . a7 0100111001010111 .......... U U U 16 16 5
557 link 16 . . 0100111001010... .......... U U U 16 16 5
558 link 32 . a7 0100100000001111 .......... . . U . . 6
559 link 32 . . 0100100000001... .......... . . U . . 6
560 lsr 8 s . 1110...000001... .......... U U U 6 6 4
561 lsr 16 s . 1110...001001... .......... U U U 6 6 4
562 lsr 32 s . 1110...010001... .......... U U U 8 8 4
563 lsr 8 r . 1110...000101... .......... U U U 6 6 6
564 lsr 16 r . 1110...001101... .......... U U U 6 6 6
565 lsr 32 r . 1110...010101... .......... U U U 8 8 6
566 lsr 16 . . 1110001011...... A+-DXWL... U U U 8 8 5
567 lsl 8 s . 1110...100001... .......... U U U 6 6 4
568 lsl 16 s . 1110...101001... .......... U U U 6 6 4
569 lsl 32 s . 1110...110001... .......... U U U 8 8 4
570 lsl 8 r . 1110...100101... .......... U U U 6 6 6
571 lsl 16 r . 1110...101101... .......... U U U 6 6 6
572 lsl 32 r . 1110...110101... .......... U U U 8 8 6
573 lsl 16 . . 1110001111...... A+-DXWL... U U U 8 8 5
574 move 8 d d 0001...000000... .......... U U U 4 4 2
575 move 8 d . 0001...000...... A+-DXWLdxI U U U 4 4 2
576 move 8 ai d 0001...010000... .......... U U U 8 8 4
577 move 8 ai . 0001...010...... A+-DXWLdxI U U U 8 8 4
578 move 8 pi d 0001...011000... .......... U U U 8 8 4
579 move 8 pi . 0001...011...... A+-DXWLdxI U U U 8 8 4
580 move 8 pi7 d 0001111011000... .......... U U U 8 8 4
581 move 8 pi7 . 0001111011...... A+-DXWLdxI U U U 8 8 4
582 move 8 pd d 0001...100000... .......... U U U 8 8 5
583 move 8 pd . 0001...100...... A+-DXWLdxI U U U 8 8 5
584 move 8 pd7 d 0001111100000... .......... U U U 8 8 5
585 move 8 pd7 . 0001111100...... A+-DXWLdxI U U U 8 8 5
586 move 8 di d 0001...101000... .......... U U U 12 12 5
587 move 8 di . 0001...101...... A+-DXWLdxI U U U 12 12 5
588 move 8 ix d 0001...110000... .......... U U U 14 14 7
589 move 8 ix . 0001...110...... A+-DXWLdxI U U U 14 14 7
590 move 8 aw d 0001000111000... .......... U U U 12 12 4
591 move 8 aw . 0001000111...... A+-DXWLdxI U U U 12 12 4
592 move 8 al d 0001001111000... .......... U U U 16 16 6
593 move 8 al . 0001001111...... A+-DXWLdxI U U U 16 16 6
594 move 16 d d 0011...000000... .......... U U U 4 4 2
595 move 16 d a 0011...000001... .......... U U U 4 4 2
596 move 16 d . 0011...000...... A+-DXWLdxI U U U 4 4 2
597 move 16 ai d 0011...010000... .......... U U U 8 8 4
598 move 16 ai a 0011...010001... .......... U U U 8 8 4
599 move 16 ai . 0011...010...... A+-DXWLdxI U U U 8 8 4
600 move 16 pi d 0011...011000... .......... U U U 8 8 4
601 move 16 pi a 0011...011001... .......... U U U 8 8 4
602 move 16 pi . 0011...011...... A+-DXWLdxI U U U 8 8 4
603 move 16 pd d 0011...100000... .......... U U U 8 8 5
604 move 16 pd a 0011...100001... .......... U U U 8 8 5
605 move 16 pd . 0011...100...... A+-DXWLdxI U U U 8 8 5
606 move 16 di d 0011...101000... .......... U U U 12 12 5
607 move 16 di a 0011...101001... .......... U U U 12 12 5
608 move 16 di . 0011...101...... A+-DXWLdxI U U U 12 12 5
609 move 16 ix d 0011...110000... .......... U U U 14 14 7
610 move 16 ix a 0011...110001... .......... U U U 14 14 7
611 move 16 ix . 0011...110...... A+-DXWLdxI U U U 14 14 7
612 move 16 aw d 0011000111000... .......... U U U 12 12 4
613 move 16 aw a 0011000111001... .......... U U U 12 12 4
614 move 16 aw . 0011000111...... A+-DXWLdxI U U U 12 12 4
615 move 16 al d 0011001111000... .......... U U U 16 16 6
616 move 16 al a 0011001111001... .......... U U U 16 16 6
617 move 16 al . 0011001111...... A+-DXWLdxI U U U 16 16 6
618 move 32 d d 0010...000000... .......... U U U 4 4 2
619 move 32 d a 0010...000001... .......... U U U 4 4 2
620 move 32 d . 0010...000...... A+-DXWLdxI U U U 4 4 2
621 move 32 ai d 0010...010000... .......... U U U 12 12 4
622 move 32 ai a 0010...010001... .......... U U U 12 12 4
623 move 32 ai . 0010...010...... A+-DXWLdxI U U U 12 12 4
624 move 32 pi d 0010...011000... .......... U U U 12 12 4
625 move 32 pi a 0010...011001... .......... U U U 12 12 4
626 move 32 pi . 0010...011...... A+-DXWLdxI U U U 12 12 4
627 move 32 pd d 0010...100000... .......... U U U 12 14 5
628 move 32 pd a 0010...100001... .......... U U U 12 14 5
629 move 32 pd . 0010...100...... A+-DXWLdxI U U U 12 14 5
630 move 32 di d 0010...101000... .......... U U U 16 16 5
631 move 32 di a 0010...101001... .......... U U U 16 16 5
632 move 32 di . 0010...101...... A+-DXWLdxI U U U 16 16 5
633 move 32 ix d 0010...110000... .......... U U U 18 18 7
634 move 32 ix a 0010...110001... .......... U U U 18 18 7
635 move 32 ix . 0010...110...... A+-DXWLdxI U U U 18 18 7
636 move 32 aw d 0010000111000... .......... U U U 16 16 4
637 move 32 aw a 0010000111001... .......... U U U 16 16 4
638 move 32 aw . 0010000111...... A+-DXWLdxI U U U 16 16 4
639 move 32 al d 0010001111000... .......... U U U 20 20 6
640 move 32 al a 0010001111001... .......... U U U 20 20 6
641 move 32 al . 0010001111...... A+-DXWLdxI U U U 20 20 6
642 movea 16 . d 0011...001000... .......... U U U 4 4 2
643 movea 16 . a 0011...001001... .......... U U U 4 4 2
644 movea 16 . . 0011...001...... A+-DXWLdxI U U U 4 4 2
645 movea 32 . d 0010...001000... .......... U U U 4 4 2
646 movea 32 . a 0010...001001... .......... U U U 4 4 2
647 movea 32 . . 0010...001...... A+-DXWLdxI U U U 4 4 2
648 move 16 frc d 0100001011000... .......... . U U . 4 4
649 move 16 frc . 0100001011...... A+-DXWL... . U U . 8 4
650 move 16 toc d 0100010011000... .......... U U U 12 12 4
651 move 16 toc . 0100010011...... A+-DXWLdxI U U U 12 12 4
652 move 16 frs d 0100000011000... .......... U S S 6 4 8 U only for 000
653 move 16 frs . 0100000011...... A+-DXWL... U S S 8 8 8 U only for 000
654 move 16 tos d 0100011011000... .......... S S S 12 12 8
655 move 16 tos . 0100011011...... A+-DXWLdxI S S S 12 12 8
656 move 32 fru . 0100111001101... .......... S S S 4 6 2
657 move 32 tou . 0100111001100... .......... S S S 4 6 2
658 movec 32 cr . 0100111001111010 .......... . S S . 12 6
659 movec 32 rc . 0100111001111011 .......... . S S . 10 12
660 movem 16 re pd 0100100010100... .......... U U U 8 8 4
661 movem 16 re . 0100100010...... A..DXWL... U U U 8 8 4
662 movem 32 re pd 0100100011100... .......... U U U 8 8 4
663 movem 32 re . 0100100011...... A..DXWL... U U U 8 8 4
664 movem 16 er pi 0100110010011... .......... U U U 12 12 8
665 movem 16 er . 0100110010...... A..DXWLdx. U U U 12 12 8
666 movem 32 er pi 0100110011011... .......... U U U 12 12 8
667 movem 32 er . 0100110011...... A..DXWLdx. U U U 12 12 8
668 movep 16 er . 0000...100001... .......... U U U 16 16 12
669 movep 32 er . 0000...101001... .......... U U U 24 24 18
670 movep 16 re . 0000...110001... .......... U U U 16 16 11
671 movep 32 re . 0000...111001... .......... U U U 24 24 17
672 moveq 32 . . 0111...0........ .......... U U U 4 4 2
673 moves 8 . . 0000111000...... A+-DXWL... . S S . 14 5
674 moves 16 . . 0000111001...... A+-DXWL... . S S . 14 5
675 moves 32 . . 0000111010...... A+-DXWL... . S S . 16 5
676 muls 16 . d 1100...111000... .......... U U U 54 32 27
677 muls 16 . . 1100...111...... A+-DXWLdxI U U U 54 32 27
678 mulu 16 . d 1100...011000... .......... U U U 54 30 27
679 mulu 16 . . 1100...011...... A+-DXWLdxI U U U 54 30 27
680 mull 32 . d 0100110000000... .......... . . U . . 43
681 mull 32 . . 0100110000...... A+-DXWLdxI . . U . . 43
682 nbcd 8 . d 0100100000000... .......... U U U 6 6 6
683 nbcd 8 . . 0100100000...... A+-DXWL... U U U 8 8 6
684 neg 8 . d 0100010000000... .......... U U U 4 4 2
685 neg 8 . . 0100010000...... A+-DXWL... U U U 8 8 4
686 neg 16 . d 0100010001000... .......... U U U 4 4 2
687 neg 16 . . 0100010001...... A+-DXWL... U U U 8 8 4
688 neg 32 . d 0100010010000... .......... U U U 6 6 2
689 neg 32 . . 0100010010...... A+-DXWL... U U U 12 12 4
690 negx 8 . d 0100000000000... .......... U U U 4 4 2
691 negx 8 . . 0100000000...... A+-DXWL... U U U 8 8 4
692 negx 16 . d 0100000001000... .......... U U U 4 4 2
693 negx 16 . . 0100000001...... A+-DXWL... U U U 8 8 4
694 negx 32 . d 0100000010000... .......... U U U 6 6 2
695 negx 32 . . 0100000010...... A+-DXWL... U U U 12 12 4
696 nop 0 . . 0100111001110001 .......... U U U 4 4 2
697 not 8 . d 0100011000000... .......... U U U 4 4 2
698 not 8 . . 0100011000...... A+-DXWL... U U U 8 8 4
699 not 16 . d 0100011001000... .......... U U U 4 4 2
700 not 16 . . 0100011001...... A+-DXWL... U U U 8 8 4
701 not 32 . d 0100011010000... .......... U U U 6 6 2
702 not 32 . . 0100011010...... A+-DXWL... U U U 12 12 4
703 or 8 er d 1000...000000... .......... U U U 4 4 2
704 or 8 er . 1000...000...... A+-DXWLdxI U U U 4 4 2
705 or 16 er d 1000...001000... .......... U U U 4 4 2
706 or 16 er . 1000...001...... A+-DXWLdxI U U U 4 4 2
707 or 32 er d 1000...010000... .......... U U U 6 6 2
708 or 32 er . 1000...010...... A+-DXWLdxI U U U 6 6 2
709 or 8 re . 1000...100...... A+-DXWL... U U U 8 8 4
710 or 16 re . 1000...101...... A+-DXWL... U U U 8 8 4
711 or 32 re . 1000...110...... A+-DXWL... U U U 12 12 4
712 ori 16 toc . 0000000000111100 .......... U U U 20 16 12
713 ori 16 tos . 0000000001111100 .......... S S S 20 16 12
714 ori 8 . d 0000000000000... .......... U U U 8 8 2
715 ori 8 . . 0000000000...... A+-DXWL... U U U 12 12 4
716 ori 16 . d 0000000001000... .......... U U U 8 8 2
717 ori 16 . . 0000000001...... A+-DXWL... U U U 12 12 4
718 ori 32 . d 0000000010000... .......... U U U 16 14 2
719 ori 32 . . 0000000010...... A+-DXWL... U U U 20 20 4
720 pack 16 rr . 1000...101000... .......... . . U . . 6
721 pack 16 mm ax7 1000111101001... .......... . . U . . 13
722 pack 16 mm ay7 1000...101001111 .......... . . U . . 13
723 pack 16 mm axy7 1000111101001111 .......... . . U . . 13
724 pack 16 mm . 1000...101001... .......... . . U . . 13
725 pea 32 . . 0100100001...... A..DXWLdx. U U U 6 6 5
726 reset 0 . . 0100111001110000 .......... S S S 0 0 0
727 ror 8 s . 1110...000011... .......... U U U 6 6 8
728 ror 16 s . 1110...001011... .......... U U U 6 6 8
729 ror 32 s . 1110...010011... .......... U U U 8 8 8
730 ror 8 r . 1110...000111... .......... U U U 6 6 8
731 ror 16 r . 1110...001111... .......... U U U 6 6 8
732 ror 32 r . 1110...010111... .......... U U U 8 8 8
733 ror 16 . . 1110011011...... A+-DXWL... U U U 8 8 7
734 rol 8 s . 1110...100011... .......... U U U 6 6 8
735 rol 16 s . 1110...101011... .......... U U U 6 6 8
736 rol 32 s . 1110...110011... .......... U U U 8 8 8
737 rol 8 r . 1110...100111... .......... U U U 6 6 8
738 rol 16 r . 1110...101111... .......... U U U 6 6 8
739 rol 32 r . 1110...110111... .......... U U U 8 8 8
740 rol 16 . . 1110011111...... A+-DXWL... U U U 8 8 7
741 roxr 8 s . 1110...000010... .......... U U U 6 6 12
742 roxr 16 s . 1110...001010... .......... U U U 6 6 12
743 roxr 32 s . 1110...010010... .......... U U U 8 8 12
744 roxr 8 r . 1110...000110... .......... U U U 6 6 12
745 roxr 16 r . 1110...001110... .......... U U U 6 6 12
746 roxr 32 r . 1110...010110... .......... U U U 8 8 12
747 roxr 16 . . 1110010011...... A+-DXWL... U U U 8 8 5
748 roxl 8 s . 1110...100010... .......... U U U 6 6 12
749 roxl 16 s . 1110...101010... .......... U U U 6 6 12
750 roxl 32 s . 1110...110010... .......... U U U 8 8 12
751 roxl 8 r . 1110...100110... .......... U U U 6 6 12
752 roxl 16 r . 1110...101110... .......... U U U 6 6 12
753 roxl 32 r . 1110...110110... .......... U U U 8 8 12
754 roxl 16 . . 1110010111...... A+-DXWL... U U U 8 8 5
755 rtd 32 . . 0100111001110100 .......... . U U . 16 10
756 rte 32 . . 0100111001110011 .......... S S S 20 24 20 bus fault not emulated
757 rtm 32 . . 000001101100.... .......... . . U . . 19 not properly emulated
758 rtr 32 . . 0100111001110111 .......... U U U 20 20 14
759 rts 32 . . 0100111001110101 .......... U U U 16 16 10
760 sbcd 8 rr . 1000...100000... .......... U U U 6 6 4
761 sbcd 8 mm ax7 1000111100001... .......... U U U 18 18 16
762 sbcd 8 mm ay7 1000...100001111 .......... U U U 18 18 16
763 sbcd 8 mm axy7 1000111100001111 .......... U U U 18 18 16
764 sbcd 8 mm . 1000...100001... .......... U U U 18 18 16
765 st 8 . d 0101000011000... .......... U U U 6 4 4
766 st 8 . . 0101000011...... A+-DXWL... U U U 8 8 6
767 sf 8 . d 0101000111000... .......... U U U 4 4 4
768 sf 8 . . 0101000111...... A+-DXWL... U U U 8 8 6
769 scc 8 . d 0101....11000... .......... U U U 4 4 4
770 scc 8 . . 0101....11...... A+-DXWL... U U U 8 8 6
771 stop 0 . . 0100111001110010 .......... S S S 4 4 8
772 sub 8 er d 1001...000000... .......... U U U 4 4 2
773 sub 8 er . 1001...000...... A+-DXWLdxI U U U 4 4 2
774 sub 16 er d 1001...001000... .......... U U U 4 4 2
775 sub 16 er a 1001...001001... .......... U U U 4 4 2
776 sub 16 er . 1001...001...... A+-DXWLdxI U U U 4 4 2
777 sub 32 er d 1001...010000... .......... U U U 6 6 2
778 sub 32 er a 1001...010001... .......... U U U 6 6 2
779 sub 32 er . 1001...010...... A+-DXWLdxI U U U 6 6 2
780 sub 8 re . 1001...100...... A+-DXWL... U U U 8 8 4
781 sub 16 re . 1001...101...... A+-DXWL... U U U 8 8 4
782 sub 32 re . 1001...110...... A+-DXWL... U U U 12 12 4
783 suba 16 . d 1001...011000... .......... U U U 8 8 2
784 suba 16 . a 1001...011001... .......... U U U 8 8 2
785 suba 16 . . 1001...011...... A+-DXWLdxI U U U 8 8 2
786 suba 32 . d 1001...111000... .......... U U U 6 6 2
787 suba 32 . a 1001...111001... .......... U U U 6 6 2
788 suba 32 . . 1001...111...... A+-DXWLdxI U U U 6 6 2
789 subi 8 . d 0000010000000... .......... U U U 8 8 2
790 subi 8 . . 0000010000...... A+-DXWL... U U U 12 12 4
791 subi 16 . d 0000010001000... .......... U U U 8 8 2
792 subi 16 . . 0000010001...... A+-DXWL... U U U 12 12 4
793 subi 32 . d 0000010010000... .......... U U U 16 14 2
794 subi 32 . . 0000010010...... A+-DXWL... U U U 20 20 4
795 subq 8 . d 0101...100000... .......... U U U 4 4 2
796 subq 8 . . 0101...100...... A+-DXWL... U U U 8 8 4
797 subq 16 . d 0101...101000... .......... U U U 4 4 2
798 subq 16 . a 0101...101001... .......... U U U 8 4 2
799 subq 16 . . 0101...101...... A+-DXWL... U U U 8 8 4
800 subq 32 . d 0101...110000... .......... U U U 8 8 2
801 subq 32 . a 0101...110001... .......... U U U 8 8 2
802 subq 32 . . 0101...110...... A+-DXWL... U U U 12 12 4
803 subx 8 rr . 1001...100000... .......... U U U 4 4 2
804 subx 16 rr . 1001...101000... .......... U U U 4 4 2
805 subx 32 rr . 1001...110000... .......... U U U 8 6 2
806 subx 8 mm ax7 1001111100001... .......... U U U 18 18 12
807 subx 8 mm ay7 1001...100001111 .......... U U U 18 18 12
808 subx 8 mm axy7 1001111100001111 .......... U U U 18 18 12
809 subx 8 mm . 1001...100001... .......... U U U 18 18 12
810 subx 16 mm . 1001...101001... .......... U U U 18 18 12
811 subx 32 mm . 1001...110001... .......... U U U 30 30 12
812 swap 32 . . 0100100001000... .......... U U U 4 4 4
813 tas 8 . d 0100101011000... .......... U U U 4 4 4
814 tas 8 . . 0100101011...... A+-DXWL... U U U 14 14 12
815 trap 0 . . 010011100100.... .......... U U U 4 4 4
816 trapt 0 . . 0101000011111100 .......... . . U . . 4
817 trapt 16 . . 0101000011111010 .......... . . U . . 6
818 trapt 32 . . 0101000011111011 .......... . . U . . 8
819 trapf 0 . . 0101000111111100 .......... . . U . . 4
820 trapf 16 . . 0101000111111010 .......... . . U . . 6
821 trapf 32 . . 0101000111111011 .......... . . U . . 8
822 trapcc 0 . . 0101....11111100 .......... . . U . . 4
823 trapcc 16 . . 0101....11111010 .......... . . U . . 6
824 trapcc 32 . . 0101....11111011 .......... . . U . . 8
825 trapv 0 . . 0100111001110110 .......... U U U 4 4 4
826 tst 8 . d 0100101000000... .......... U U U 4 4 2
827 tst 8 . . 0100101000...... A+-DXWL... U U U 4 4 2
828 tst 8 . pcdi 0100101000111010 .......... . . U . . 7
829 tst 8 . pcix 0100101000111011 .......... . . U . . 9
830 tst 8 . i 0100101000111100 .......... . . U . . 6
831 tst 16 . d 0100101001000... .......... U U U 4 4 2
832 tst 16 . a 0100101001001... .......... . . U . . 2
833 tst 16 . . 0100101001...... A+-DXWL... U U U 4 4 2
834 tst 16 . pcdi 0100101001111010 .......... . . U . . 7
835 tst 16 . pcix 0100101001111011 .......... . . U . . 9
836 tst 16 . i 0100101001111100 .......... . . U . . 6
837 tst 32 . d 0100101010000... .......... U U U 4 4 2
838 tst 32 . a 0100101010001... .......... . . U . . 2
839 tst 32 . . 0100101010...... A+-DXWL... U U U 4 4 2
840 tst 32 . pcdi 0100101010111010 .......... . . U . . 7
841 tst 32 . pcix 0100101010111011 .......... . . U . . 9
842 tst 32 . i 0100101010111100 .......... . . U . . 6
843 unlk 32 . a7 0100111001011111 .......... U U U 12 12 6
844 unlk 32 . . 0100111001011... .......... U U U 12 12 6
845 unpk 16 rr . 1000...110000... .......... . . U . . 8
846 unpk 16 mm ax7 1000111110001... .......... . . U . . 13
847 unpk 16 mm ay7 1000...110001111 .......... . . U . . 13
848 unpk 16 mm axy7 1000111110001111 .......... . . U . . 13
849 unpk 16 mm . 1000...110001... .......... . . U . . 13
853 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
854 M68KMAKE_OPCODE_HANDLER_BODY
856 M68KMAKE_OP(1010, 0, ., .)
858 m68ki_exception_1010();
862 M68KMAKE_OP(1111, 0, ., .)
864 m68ki_exception_1111();
868 M68KMAKE_OP(abcd, 8, rr, .)
873 uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1();
877 res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst);
878 FLAG_X = FLAG_C = (res > 0x99) << 8;
882 FLAG_N = NFLAG_8(res); /* officially undefined */
884 res = MASK_OUT_ABOVE_8(res);
887 *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;
891 M68KMAKE_OP(abcd, 8, mm, ax7)
893 uint src = OPER_AY_PD_8();
894 uint ea = EA_A7_PD_8();
895 uint dst = m68ki_read_8(ea);
896 uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1();
900 res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst);
901 FLAG_X = FLAG_C = (res > 0x99) << 8;
905 FLAG_N = NFLAG_8(res); /* officially undefined */
907 res = MASK_OUT_ABOVE_8(res);
910 m68ki_write_8(ea, res);
914 M68KMAKE_OP(abcd, 8, mm, ay7)
916 uint src = OPER_A7_PD_8();
917 uint ea = EA_AX_PD_8();
918 uint dst = m68ki_read_8(ea);
919 uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1();
923 res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst);
924 FLAG_X = FLAG_C = (res > 0x99) << 8;
928 FLAG_N = NFLAG_8(res); /* officially undefined */
930 res = MASK_OUT_ABOVE_8(res);
933 m68ki_write_8(ea, res);
937 M68KMAKE_OP(abcd, 8, mm, axy7)
939 uint src = OPER_A7_PD_8();
940 uint ea = EA_A7_PD_8();
941 uint dst = m68ki_read_8(ea);
942 uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1();
946 res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst);
947 FLAG_X = FLAG_C = (res > 0x99) << 8;
951 FLAG_N = NFLAG_8(res); /* officially undefined */
953 res = MASK_OUT_ABOVE_8(res);
956 m68ki_write_8(ea, res);
960 M68KMAKE_OP(abcd, 8, mm, .)
962 uint src = OPER_AY_PD_8();
963 uint ea = EA_AX_PD_8();
964 uint dst = m68ki_read_8(ea);
965 uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1();
969 res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst);
970 FLAG_X = FLAG_C = (res > 0x99) << 8;
974 FLAG_N = NFLAG_8(res); /* officially undefined */
976 res = MASK_OUT_ABOVE_8(res);
979 m68ki_write_8(ea, res);
983 M68KMAKE_OP(add, 8, er, d)
986 uint src = MASK_OUT_ABOVE_8(DY);
987 uint dst = MASK_OUT_ABOVE_8(*r_dst);
988 uint res = src + dst;
990 FLAG_N = NFLAG_8(res);
991 FLAG_V = VFLAG_ADD_8(src, dst, res);
992 FLAG_X = FLAG_C = CFLAG_8(res);
993 FLAG_Z = MASK_OUT_ABOVE_8(res);
995 *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z;
999 M68KMAKE_OP(add, 8, er, .)
1002 uint src = M68KMAKE_GET_OPER_AY_8;
1003 uint dst = MASK_OUT_ABOVE_8(*r_dst);
1004 uint res = src + dst;
1006 FLAG_N = NFLAG_8(res);
1007 FLAG_V = VFLAG_ADD_8(src, dst, res);
1008 FLAG_X = FLAG_C = CFLAG_8(res);
1009 FLAG_Z = MASK_OUT_ABOVE_8(res);
1011 *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z;
1015 M68KMAKE_OP(add, 16, er, d)
1018 uint src = MASK_OUT_ABOVE_16(DY);
1019 uint dst = MASK_OUT_ABOVE_16(*r_dst);
1020 uint res = src + dst;
1022 FLAG_N = NFLAG_16(res);
1023 FLAG_V = VFLAG_ADD_16(src, dst, res);
1024 FLAG_X = FLAG_C = CFLAG_16(res);
1025 FLAG_Z = MASK_OUT_ABOVE_16(res);
1027 *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z;
1031 M68KMAKE_OP(add, 16, er, a)
1034 uint src = MASK_OUT_ABOVE_16(AY);
1035 uint dst = MASK_OUT_ABOVE_16(*r_dst);
1036 uint res = src + dst;
1038 FLAG_N = NFLAG_16(res);
1039 FLAG_V = VFLAG_ADD_16(src, dst, res);
1040 FLAG_X = FLAG_C = CFLAG_16(res);
1041 FLAG_Z = MASK_OUT_ABOVE_16(res);
1043 *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z;
1047 M68KMAKE_OP(add, 16, er, .)
1050 uint src = M68KMAKE_GET_OPER_AY_16;
1051 uint dst = MASK_OUT_ABOVE_16(*r_dst);
1052 uint res = src + dst;
1054 FLAG_N = NFLAG_16(res);
1055 FLAG_V = VFLAG_ADD_16(src, dst, res);
1056 FLAG_X = FLAG_C = CFLAG_16(res);
1057 FLAG_Z = MASK_OUT_ABOVE_16(res);
1059 *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z;
1063 M68KMAKE_OP(add, 32, er, d)
1068 uint res = src + dst;
1070 FLAG_N = NFLAG_32(res);
1071 FLAG_V = VFLAG_ADD_32(src, dst, res);
1072 FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res);
1073 FLAG_Z = MASK_OUT_ABOVE_32(res);
1079 M68KMAKE_OP(add, 32, er, a)
1084 uint res = src + dst;
1086 FLAG_N = NFLAG_32(res);
1087 FLAG_V = VFLAG_ADD_32(src, dst, res);
1088 FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res);
1089 FLAG_Z = MASK_OUT_ABOVE_32(res);
1095 M68KMAKE_OP(add, 32, er, .)
1098 uint src = M68KMAKE_GET_OPER_AY_32;
1100 uint res = src + dst;
1102 FLAG_N = NFLAG_32(res);
1103 FLAG_V = VFLAG_ADD_32(src, dst, res);
1104 FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res);
1105 FLAG_Z = MASK_OUT_ABOVE_32(res);
1111 M68KMAKE_OP(add, 8, re, .)
1113 uint ea = M68KMAKE_GET_EA_AY_8;
1114 uint src = MASK_OUT_ABOVE_8(DX);
1115 uint dst = m68ki_read_8(ea);
1116 uint res = src + dst;
1118 FLAG_N = NFLAG_8(res);
1119 FLAG_V = VFLAG_ADD_8(src, dst, res);
1120 FLAG_X = FLAG_C = CFLAG_8(res);
1121 FLAG_Z = MASK_OUT_ABOVE_8(res);
1123 m68ki_write_8(ea, FLAG_Z);
1127 M68KMAKE_OP(add, 16, re, .)
1129 uint ea = M68KMAKE_GET_EA_AY_16;
1130 uint src = MASK_OUT_ABOVE_16(DX);
1131 uint dst = m68ki_read_16(ea);
1132 uint res = src + dst;
1134 FLAG_N = NFLAG_16(res);
1135 FLAG_V = VFLAG_ADD_16(src, dst, res);
1136 FLAG_X = FLAG_C = CFLAG_16(res);
1137 FLAG_Z = MASK_OUT_ABOVE_16(res);
1139 m68ki_write_16(ea, FLAG_Z);
1143 M68KMAKE_OP(add, 32, re, .)
1145 uint ea = M68KMAKE_GET_EA_AY_32;
1147 uint dst = m68ki_read_32(ea);
1148 uint res = src + dst;
1150 FLAG_N = NFLAG_32(res);
1151 FLAG_V = VFLAG_ADD_32(src, dst, res);
1152 FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res);
1153 FLAG_Z = MASK_OUT_ABOVE_32(res);
1155 m68ki_write_32(ea, FLAG_Z);
1159 M68KMAKE_OP(adda, 16, ., d)
1163 *r_dst = MASK_OUT_ABOVE_32(*r_dst + MAKE_INT_16(DY));
1167 M68KMAKE_OP(adda, 16, ., a)
1171 *r_dst = MASK_OUT_ABOVE_32(*r_dst + MAKE_INT_16(AY));
1175 M68KMAKE_OP(adda, 16, ., .)
1179 *r_dst = MASK_OUT_ABOVE_32(*r_dst + MAKE_INT_16(M68KMAKE_GET_OPER_AY_16));
1183 M68KMAKE_OP(adda, 32, ., d)
1187 *r_dst = MASK_OUT_ABOVE_32(*r_dst + DY);
1191 M68KMAKE_OP(adda, 32, ., a)
1195 *r_dst = MASK_OUT_ABOVE_32(*r_dst + AY);
1199 M68KMAKE_OP(adda, 32, ., .)
1203 *r_dst = MASK_OUT_ABOVE_32(*r_dst + M68KMAKE_GET_OPER_AY_32);
1207 M68KMAKE_OP(addi, 8, ., d)
1210 uint src = OPER_I_8();
1211 uint dst = MASK_OUT_ABOVE_8(*r_dst);
1212 uint res = src + dst;
1214 FLAG_N = NFLAG_8(res);
1215 FLAG_V = VFLAG_ADD_8(src, dst, res);
1216 FLAG_X = FLAG_C = CFLAG_8(res);
1217 FLAG_Z = MASK_OUT_ABOVE_8(res);
1219 *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z;
1223 M68KMAKE_OP(addi, 8, ., .)
1225 uint src = OPER_I_8();
1226 uint ea = M68KMAKE_GET_EA_AY_8;
1227 uint dst = m68ki_read_8(ea);
1228 uint res = src + dst;
1230 FLAG_N = NFLAG_8(res);
1231 FLAG_V = VFLAG_ADD_8(src, dst, res);
1232 FLAG_X = FLAG_C = CFLAG_8(res);
1233 FLAG_Z = MASK_OUT_ABOVE_8(res);
1235 m68ki_write_8(ea, FLAG_Z);
1239 M68KMAKE_OP(addi, 16, ., d)
1242 uint src = OPER_I_16();
1243 uint dst = MASK_OUT_ABOVE_16(*r_dst);
1244 uint res = src + dst;
1246 FLAG_N = NFLAG_16(res);
1247 FLAG_V = VFLAG_ADD_16(src, dst, res);
1248 FLAG_X = FLAG_C = CFLAG_16(res);
1249 FLAG_Z = MASK_OUT_ABOVE_16(res);
1251 *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z;
1255 M68KMAKE_OP(addi, 16, ., .)
1257 uint src = OPER_I_16();
1258 uint ea = M68KMAKE_GET_EA_AY_16;
1259 uint dst = m68ki_read_16(ea);
1260 uint res = src + dst;
1262 FLAG_N = NFLAG_16(res);
1263 FLAG_V = VFLAG_ADD_16(src, dst, res);
1264 FLAG_X = FLAG_C = CFLAG_16(res);
1265 FLAG_Z = MASK_OUT_ABOVE_16(res);
1267 m68ki_write_16(ea, FLAG_Z);
1271 M68KMAKE_OP(addi, 32, ., d)
1274 uint src = OPER_I_32();
1276 uint res = src + dst;
1278 FLAG_N = NFLAG_32(res);
1279 FLAG_V = VFLAG_ADD_32(src, dst, res);
1280 FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res);
1281 FLAG_Z = MASK_OUT_ABOVE_32(res);
1287 M68KMAKE_OP(addi, 32, ., .)
1289 uint src = OPER_I_32();
1290 uint ea = M68KMAKE_GET_EA_AY_32;
1291 uint dst = m68ki_read_32(ea);
1292 uint res = src + dst;
1294 FLAG_N = NFLAG_32(res);
1295 FLAG_V = VFLAG_ADD_32(src, dst, res);
1296 FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res);
1297 FLAG_Z = MASK_OUT_ABOVE_32(res);
1299 m68ki_write_32(ea, FLAG_Z);
1303 M68KMAKE_OP(addq, 8, ., d)
1306 uint src = (((REG_IR >> 9) - 1) & 7) + 1;
1307 uint dst = MASK_OUT_ABOVE_8(*r_dst);
1308 uint res = src + dst;
1310 FLAG_N = NFLAG_8(res);
1311 FLAG_V = VFLAG_ADD_8(src, dst, res);
1312 FLAG_X = FLAG_C = CFLAG_8(res);
1313 FLAG_Z = MASK_OUT_ABOVE_8(res);
1315 *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z;
1319 M68KMAKE_OP(addq, 8, ., .)
1321 uint src = (((REG_IR >> 9) - 1) & 7) + 1;
1322 uint ea = M68KMAKE_GET_EA_AY_8;
1323 uint dst = m68ki_read_8(ea);
1324 uint res = src + dst;
1326 FLAG_N = NFLAG_8(res);
1327 FLAG_V = VFLAG_ADD_8(src, dst, res);
1328 FLAG_X = FLAG_C = CFLAG_8(res);
1329 FLAG_Z = MASK_OUT_ABOVE_8(res);
1331 m68ki_write_8(ea, FLAG_Z);
1335 M68KMAKE_OP(addq, 16, ., d)
1338 uint src = (((REG_IR >> 9) - 1) & 7) + 1;
1339 uint dst = MASK_OUT_ABOVE_16(*r_dst);
1340 uint res = src + dst;
1342 FLAG_N = NFLAG_16(res);
1343 FLAG_V = VFLAG_ADD_16(src, dst, res);
1344 FLAG_X = FLAG_C = CFLAG_16(res);
1345 FLAG_Z = MASK_OUT_ABOVE_16(res);
1347 *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z;
1351 M68KMAKE_OP(addq, 16, ., a)
1355 *r_dst = MASK_OUT_ABOVE_32(*r_dst + (((REG_IR >> 9) - 1) & 7) + 1);
1359 M68KMAKE_OP(addq, 16, ., .)
1361 uint src = (((REG_IR >> 9) - 1) & 7) + 1;
1362 uint ea = M68KMAKE_GET_EA_AY_16;
1363 uint dst = m68ki_read_16(ea);
1364 uint res = src + dst;
1366 FLAG_N = NFLAG_16(res);
1367 FLAG_V = VFLAG_ADD_16(src, dst, res);
1368 FLAG_X = FLAG_C = CFLAG_16(res);
1369 FLAG_Z = MASK_OUT_ABOVE_16(res);
1371 m68ki_write_16(ea, FLAG_Z);
1375 M68KMAKE_OP(addq, 32, ., d)
1378 uint src = (((REG_IR >> 9) - 1) & 7) + 1;
1380 uint res = src + dst;
1382 FLAG_N = NFLAG_32(res);
1383 FLAG_V = VFLAG_ADD_32(src, dst, res);
1384 FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res);
1385 FLAG_Z = MASK_OUT_ABOVE_32(res);
1391 M68KMAKE_OP(addq, 32, ., a)
1395 *r_dst = MASK_OUT_ABOVE_32(*r_dst + (((REG_IR >> 9) - 1) & 7) + 1);
1399 M68KMAKE_OP(addq, 32, ., .)
1401 uint src = (((REG_IR >> 9) - 1) & 7) + 1;
1402 uint ea = M68KMAKE_GET_EA_AY_32;
1403 uint dst = m68ki_read_32(ea);
1404 uint res = src + dst;
1407 FLAG_N = NFLAG_32(res);
1408 FLAG_V = VFLAG_ADD_32(src, dst, res);
1409 FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res);
1410 FLAG_Z = MASK_OUT_ABOVE_32(res);
1412 m68ki_write_32(ea, FLAG_Z);
1416 M68KMAKE_OP(addx, 8, rr, .)
1419 uint src = MASK_OUT_ABOVE_8(DY);
1420 uint dst = MASK_OUT_ABOVE_8(*r_dst);
1421 uint res = src + dst + XFLAG_AS_1();
1423 FLAG_N = NFLAG_8(res);
1424 FLAG_V = VFLAG_ADD_8(src, dst, res);
1425 FLAG_X = FLAG_C = CFLAG_8(res);
1427 res = MASK_OUT_ABOVE_8(res);
1430 *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;
1434 M68KMAKE_OP(addx, 16, rr, .)
1437 uint src = MASK_OUT_ABOVE_16(DY);
1438 uint dst = MASK_OUT_ABOVE_16(*r_dst);
1439 uint res = src + dst + XFLAG_AS_1();
1441 FLAG_N = NFLAG_16(res);
1442 FLAG_V = VFLAG_ADD_16(src, dst, res);
1443 FLAG_X = FLAG_C = CFLAG_16(res);
1445 res = MASK_OUT_ABOVE_16(res);
1448 *r_dst = MASK_OUT_BELOW_16(*r_dst) | res;
1452 M68KMAKE_OP(addx, 32, rr, .)
1457 uint res = src + dst + XFLAG_AS_1();
1459 FLAG_N = NFLAG_32(res);
1460 FLAG_V = VFLAG_ADD_32(src, dst, res);
1461 FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res);
1463 res = MASK_OUT_ABOVE_32(res);
1470 M68KMAKE_OP(addx, 8, mm, ax7)
1472 uint src = OPER_AY_PD_8();
1473 uint ea = EA_A7_PD_8();
1474 uint dst = m68ki_read_8(ea);
1475 uint res = src + dst + XFLAG_AS_1();
1477 FLAG_N = NFLAG_8(res);
1478 FLAG_V = VFLAG_ADD_8(src, dst, res);
1479 FLAG_X = FLAG_C = CFLAG_8(res);
1481 res = MASK_OUT_ABOVE_8(res);
1484 m68ki_write_8(ea, res);
1488 M68KMAKE_OP(addx, 8, mm, ay7)
1490 uint src = OPER_A7_PD_8();
1491 uint ea = EA_AX_PD_8();
1492 uint dst = m68ki_read_8(ea);
1493 uint res = src + dst + XFLAG_AS_1();
1495 FLAG_N = NFLAG_8(res);
1496 FLAG_V = VFLAG_ADD_8(src, dst, res);
1497 FLAG_X = FLAG_C = CFLAG_8(res);
1499 res = MASK_OUT_ABOVE_8(res);
1502 m68ki_write_8(ea, res);
1506 M68KMAKE_OP(addx, 8, mm, axy7)
1508 uint src = OPER_A7_PD_8();
1509 uint ea = EA_A7_PD_8();
1510 uint dst = m68ki_read_8(ea);
1511 uint res = src + dst + XFLAG_AS_1();
1513 FLAG_N = NFLAG_8(res);
1514 FLAG_V = VFLAG_ADD_8(src, dst, res);
1515 FLAG_X = FLAG_C = CFLAG_8(res);
1517 res = MASK_OUT_ABOVE_8(res);
1520 m68ki_write_8(ea, res);
1524 M68KMAKE_OP(addx, 8, mm, .)
1526 uint src = OPER_AY_PD_8();
1527 uint ea = EA_AX_PD_8();
1528 uint dst = m68ki_read_8(ea);
1529 uint res = src + dst + XFLAG_AS_1();
1531 FLAG_N = NFLAG_8(res);
1532 FLAG_V = VFLAG_ADD_8(src, dst, res);
1533 FLAG_X = FLAG_C = CFLAG_8(res);
1535 res = MASK_OUT_ABOVE_8(res);
1538 m68ki_write_8(ea, res);
1542 M68KMAKE_OP(addx, 16, mm, .)
1544 uint src = OPER_AY_PD_16();
1545 uint ea = EA_AX_PD_16();
1546 uint dst = m68ki_read_16(ea);
1547 uint res = src + dst + XFLAG_AS_1();
1549 FLAG_N = NFLAG_16(res);
1550 FLAG_V = VFLAG_ADD_16(src, dst, res);
1551 FLAG_X = FLAG_C = CFLAG_16(res);
1553 res = MASK_OUT_ABOVE_16(res);
1556 m68ki_write_16(ea, res);
1560 M68KMAKE_OP(addx, 32, mm, .)
1562 uint src = OPER_AY_PD_32();
1563 uint ea = EA_AX_PD_32();
1564 uint dst = m68ki_read_32(ea);
1565 uint res = src + dst + XFLAG_AS_1();
1567 FLAG_N = NFLAG_32(res);
1568 FLAG_V = VFLAG_ADD_32(src, dst, res);
1569 FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res);
1571 res = MASK_OUT_ABOVE_32(res);
1574 m68ki_write_32(ea, res);
1578 M68KMAKE_OP(and, 8, er, d)
1580 FLAG_Z = MASK_OUT_ABOVE_8(DX &= (DY | 0xffffff00));
1582 FLAG_N = NFLAG_8(FLAG_Z);
1583 FLAG_C = CFLAG_CLEAR;
1584 FLAG_V = VFLAG_CLEAR;
1588 M68KMAKE_OP(and, 8, er, .)
1590 FLAG_Z = MASK_OUT_ABOVE_8(DX &= (M68KMAKE_GET_OPER_AY_8 | 0xffffff00));
1592 FLAG_N = NFLAG_8(FLAG_Z);
1593 FLAG_C = CFLAG_CLEAR;
1594 FLAG_V = VFLAG_CLEAR;
1598 M68KMAKE_OP(and, 16, er, d)
1600 FLAG_Z = MASK_OUT_ABOVE_16(DX &= (DY | 0xffff0000));
1602 FLAG_N = NFLAG_16(FLAG_Z);
1603 FLAG_C = CFLAG_CLEAR;
1604 FLAG_V = VFLAG_CLEAR;
1608 M68KMAKE_OP(and, 16, er, .)
1610 FLAG_Z = MASK_OUT_ABOVE_16(DX &= (M68KMAKE_GET_OPER_AY_16 | 0xffff0000));
1612 FLAG_N = NFLAG_16(FLAG_Z);
1613 FLAG_C = CFLAG_CLEAR;
1614 FLAG_V = VFLAG_CLEAR;
1618 M68KMAKE_OP(and, 32, er, d)
1622 FLAG_N = NFLAG_32(FLAG_Z);
1623 FLAG_C = CFLAG_CLEAR;
1624 FLAG_V = VFLAG_CLEAR;
1628 M68KMAKE_OP(and, 32, er, .)
1630 FLAG_Z = DX &= M68KMAKE_GET_OPER_AY_32;
1632 FLAG_N = NFLAG_32(FLAG_Z);
1633 FLAG_C = CFLAG_CLEAR;
1634 FLAG_V = VFLAG_CLEAR;
1638 M68KMAKE_OP(and, 8, re, .)
1640 uint ea = M68KMAKE_GET_EA_AY_8;
1641 uint res = DX & m68ki_read_8(ea);
1643 FLAG_N = NFLAG_8(res);
1644 FLAG_C = CFLAG_CLEAR;
1645 FLAG_V = VFLAG_CLEAR;
1646 FLAG_Z = MASK_OUT_ABOVE_8(res);
1648 m68ki_write_8(ea, FLAG_Z);
1652 M68KMAKE_OP(and, 16, re, .)
1654 uint ea = M68KMAKE_GET_EA_AY_16;
1655 uint res = DX & m68ki_read_16(ea);
1657 FLAG_N = NFLAG_16(res);
1658 FLAG_C = CFLAG_CLEAR;
1659 FLAG_V = VFLAG_CLEAR;
1660 FLAG_Z = MASK_OUT_ABOVE_16(res);
1662 m68ki_write_16(ea, FLAG_Z);
1666 M68KMAKE_OP(and, 32, re, .)
1668 uint ea = M68KMAKE_GET_EA_AY_32;
1669 uint res = DX & m68ki_read_32(ea);
1671 FLAG_N = NFLAG_32(res);
1673 FLAG_C = CFLAG_CLEAR;
1674 FLAG_V = VFLAG_CLEAR;
1676 m68ki_write_32(ea, res);
1680 M68KMAKE_OP(andi, 8, ., d)
1682 FLAG_Z = MASK_OUT_ABOVE_8(DY &= (OPER_I_8() | 0xffffff00));
1684 FLAG_N = NFLAG_8(FLAG_Z);
1685 FLAG_C = CFLAG_CLEAR;
1686 FLAG_V = VFLAG_CLEAR;
1690 M68KMAKE_OP(andi, 8, ., .)
1692 uint src = OPER_I_8();
1693 uint ea = M68KMAKE_GET_EA_AY_8;
1694 uint res = src & m68ki_read_8(ea);
1696 FLAG_N = NFLAG_8(res);
1698 FLAG_C = CFLAG_CLEAR;
1699 FLAG_V = VFLAG_CLEAR;
1701 m68ki_write_8(ea, res);
1705 M68KMAKE_OP(andi, 16, ., d)
1707 FLAG_Z = MASK_OUT_ABOVE_16(DY &= (OPER_I_16() | 0xffff0000));
1709 FLAG_N = NFLAG_16(FLAG_Z);
1710 FLAG_C = CFLAG_CLEAR;
1711 FLAG_V = VFLAG_CLEAR;
1715 M68KMAKE_OP(andi, 16, ., .)
1717 uint src = OPER_I_16();
1718 uint ea = M68KMAKE_GET_EA_AY_16;
1719 uint res = src & m68ki_read_16(ea);
1721 FLAG_N = NFLAG_16(res);
1723 FLAG_C = CFLAG_CLEAR;
1724 FLAG_V = VFLAG_CLEAR;
1726 m68ki_write_16(ea, res);
1730 M68KMAKE_OP(andi, 32, ., d)
1732 FLAG_Z = DY &= (OPER_I_32());
1734 FLAG_N = NFLAG_32(FLAG_Z);
1735 FLAG_C = CFLAG_CLEAR;
1736 FLAG_V = VFLAG_CLEAR;
1740 M68KMAKE_OP(andi, 32, ., .)
1742 uint src = OPER_I_32();
1743 uint ea = M68KMAKE_GET_EA_AY_32;
1744 uint res = src & m68ki_read_32(ea);
1746 FLAG_N = NFLAG_32(res);
1748 FLAG_C = CFLAG_CLEAR;
1749 FLAG_V = VFLAG_CLEAR;
1751 m68ki_write_32(ea, res);
1755 M68KMAKE_OP(andi, 16, toc, .)
1757 m68ki_set_ccr(m68ki_get_ccr() & OPER_I_16());
1761 M68KMAKE_OP(andi, 16, tos, .)
1765 uint src = OPER_I_16();
1766 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
1767 m68ki_set_sr(m68ki_get_sr() & src);
1770 m68ki_exception_privilege_violation();
1774 M68KMAKE_OP(asr, 8, s, .)
1777 uint shift = (((REG_IR >> 9) - 1) & 7) + 1;
1778 uint src = MASK_OUT_ABOVE_8(*r_dst);
1779 uint res = src >> shift;
1782 res |= m68ki_shift_8_table[shift];
1784 *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;
1786 FLAG_N = NFLAG_8(res);
1788 FLAG_V = VFLAG_CLEAR;
1789 FLAG_X = FLAG_C = src << (9-shift);
1793 M68KMAKE_OP(asr, 16, s, .)
1796 uint shift = (((REG_IR >> 9) - 1) & 7) + 1;
1797 uint src = MASK_OUT_ABOVE_16(*r_dst);
1798 uint res = src >> shift;
1801 res |= m68ki_shift_16_table[shift];
1803 *r_dst = MASK_OUT_BELOW_16(*r_dst) | res;
1805 FLAG_N = NFLAG_16(res);
1807 FLAG_V = VFLAG_CLEAR;
1808 FLAG_X = FLAG_C = src << (9-shift);
1812 M68KMAKE_OP(asr, 32, s, .)
1815 uint shift = (((REG_IR >> 9) - 1) & 7) + 1;
1817 uint res = src >> shift;
1820 res |= m68ki_shift_32_table[shift];
1824 FLAG_N = NFLAG_32(res);
1826 FLAG_V = VFLAG_CLEAR;
1827 FLAG_X = FLAG_C = src << (9-shift);
1831 M68KMAKE_OP(asr, 8, r, .)
1834 uint shift = DX & 0x3f;
1835 uint src = MASK_OUT_ABOVE_8(*r_dst);
1836 uint res = src >> shift;
1840 USE_CYCLES(shift<<CYC_SHIFT);
1845 res |= m68ki_shift_8_table[shift];
1847 *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;
1849 FLAG_X = FLAG_C = src << (9-shift);
1850 FLAG_N = NFLAG_8(res);
1852 FLAG_V = VFLAG_CLEAR;
1862 FLAG_Z = ZFLAG_CLEAR;
1863 FLAG_V = VFLAG_CLEAR;
1867 *r_dst &= 0xffffff00;
1868 FLAG_C = CFLAG_CLEAR;
1869 FLAG_X = XFLAG_CLEAR;
1870 FLAG_N = NFLAG_CLEAR;
1872 FLAG_V = VFLAG_CLEAR;
1876 FLAG_C = CFLAG_CLEAR;
1877 FLAG_N = NFLAG_8(src);
1879 FLAG_V = VFLAG_CLEAR;
1883 M68KMAKE_OP(asr, 16, r, .)
1886 uint shift = DX & 0x3f;
1887 uint src = MASK_OUT_ABOVE_16(*r_dst);
1888 uint res = src >> shift;
1892 USE_CYCLES(shift<<CYC_SHIFT);
1897 res |= m68ki_shift_16_table[shift];
1899 *r_dst = MASK_OUT_BELOW_16(*r_dst) | res;
1901 FLAG_C = FLAG_X = (src >> (shift - 1))<<8;
1902 FLAG_N = NFLAG_16(res);
1904 FLAG_V = VFLAG_CLEAR;
1914 FLAG_Z = ZFLAG_CLEAR;
1915 FLAG_V = VFLAG_CLEAR;
1919 *r_dst &= 0xffff0000;
1920 FLAG_C = CFLAG_CLEAR;
1921 FLAG_X = XFLAG_CLEAR;
1922 FLAG_N = NFLAG_CLEAR;
1924 FLAG_V = VFLAG_CLEAR;
1928 FLAG_C = CFLAG_CLEAR;
1929 FLAG_N = NFLAG_16(src);
1931 FLAG_V = VFLAG_CLEAR;
1935 M68KMAKE_OP(asr, 32, r, .)
1938 uint shift = DX & 0x3f;
1940 uint res = src >> shift;
1944 USE_CYCLES(shift<<CYC_SHIFT);
1949 res |= m68ki_shift_32_table[shift];
1953 FLAG_C = FLAG_X = (src >> (shift - 1))<<8;
1954 FLAG_N = NFLAG_32(res);
1956 FLAG_V = VFLAG_CLEAR;
1962 *r_dst = 0xffffffff;
1966 FLAG_Z = ZFLAG_CLEAR;
1967 FLAG_V = VFLAG_CLEAR;
1972 FLAG_C = CFLAG_CLEAR;
1973 FLAG_X = XFLAG_CLEAR;
1974 FLAG_N = NFLAG_CLEAR;
1976 FLAG_V = VFLAG_CLEAR;
1980 FLAG_C = CFLAG_CLEAR;
1981 FLAG_N = NFLAG_32(src);
1983 FLAG_V = VFLAG_CLEAR;
1987 M68KMAKE_OP(asr, 16, ., .)
1989 uint ea = M68KMAKE_GET_EA_AY_16;
1990 uint src = m68ki_read_16(ea);
1991 uint res = src >> 1;
1996 m68ki_write_16(ea, res);
1998 FLAG_N = NFLAG_16(res);
2000 FLAG_V = VFLAG_CLEAR;
2001 FLAG_C = FLAG_X = src << 8;
2005 M68KMAKE_OP(asl, 8, s, .)
2008 uint shift = (((REG_IR >> 9) - 1) & 7) + 1;
2009 uint src = MASK_OUT_ABOVE_8(*r_dst);
2010 uint res = MASK_OUT_ABOVE_8(src << shift);
2012 *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;
2014 FLAG_X = FLAG_C = src << shift;
2015 FLAG_N = NFLAG_8(res);
2017 src &= m68ki_shift_8_table[shift + 1];
2018 FLAG_V = (!(src == 0 || (src == m68ki_shift_8_table[shift + 1] && shift < 8)))<<7;
2022 M68KMAKE_OP(asl, 16, s, .)
2025 uint shift = (((REG_IR >> 9) - 1) & 7) + 1;
2026 uint src = MASK_OUT_ABOVE_16(*r_dst);
2027 uint res = MASK_OUT_ABOVE_16(src << shift);
2029 *r_dst = MASK_OUT_BELOW_16(*r_dst) | res;
2031 FLAG_N = NFLAG_16(res);
2033 FLAG_X = FLAG_C = src >> (8-shift);
2034 src &= m68ki_shift_16_table[shift + 1];
2035 FLAG_V = (!(src == 0 || src == m68ki_shift_16_table[shift + 1]))<<7;
2039 M68KMAKE_OP(asl, 32, s, .)
2042 uint shift = (((REG_IR >> 9) - 1) & 7) + 1;
2044 uint res = MASK_OUT_ABOVE_32(src << shift);
2048 FLAG_N = NFLAG_32(res);
2050 FLAG_X = FLAG_C = src >> (24-shift);
2051 src &= m68ki_shift_32_table[shift + 1];
2052 FLAG_V = (!(src == 0 || src == m68ki_shift_32_table[shift + 1]))<<7;
2056 M68KMAKE_OP(asl, 8, r, .)
2059 uint shift = DX & 0x3f;
2060 uint src = MASK_OUT_ABOVE_8(*r_dst);
2061 uint res = MASK_OUT_ABOVE_8(src << shift);
2065 USE_CYCLES(shift<<CYC_SHIFT);
2069 *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;
2070 FLAG_X = FLAG_C = src << shift;
2071 FLAG_N = NFLAG_8(res);
2073 src &= m68ki_shift_8_table[shift + 1];
2074 FLAG_V = (!(src == 0 || src == m68ki_shift_8_table[shift + 1]))<<7;
2078 *r_dst &= 0xffffff00;
2079 FLAG_X = FLAG_C = ((shift == 8 ? src & 1 : 0))<<8;
2080 FLAG_N = NFLAG_CLEAR;
2082 FLAG_V = (!(src == 0))<<7;
2086 FLAG_C = CFLAG_CLEAR;
2087 FLAG_N = NFLAG_8(src);
2089 FLAG_V = VFLAG_CLEAR;
2093 M68KMAKE_OP(asl, 16, r, .)
2096 uint shift = DX & 0x3f;
2097 uint src = MASK_OUT_ABOVE_16(*r_dst);
2098 uint res = MASK_OUT_ABOVE_16(src << shift);
2102 USE_CYCLES(shift<<CYC_SHIFT);
2106 *r_dst = MASK_OUT_BELOW_16(*r_dst) | res;
2107 FLAG_X = FLAG_C = (src << shift) >> 8;
2108 FLAG_N = NFLAG_16(res);
2110 src &= m68ki_shift_16_table[shift + 1];
2111 FLAG_V = (!(src == 0 || src == m68ki_shift_16_table[shift + 1]))<<7;
2115 *r_dst &= 0xffff0000;
2116 FLAG_X = FLAG_C = ((shift == 16 ? src & 1 : 0))<<8;
2117 FLAG_N = NFLAG_CLEAR;
2119 FLAG_V = (!(src == 0))<<7;
2123 FLAG_C = CFLAG_CLEAR;
2124 FLAG_N = NFLAG_16(src);
2126 FLAG_V = VFLAG_CLEAR;
2130 M68KMAKE_OP(asl, 32, r, .)
2133 uint shift = DX & 0x3f;
2135 uint res = MASK_OUT_ABOVE_32(src << shift);
2139 USE_CYCLES(shift<<CYC_SHIFT);
2144 FLAG_X = FLAG_C = (src >> (32 - shift)) << 8;
2145 FLAG_N = NFLAG_32(res);
2147 src &= m68ki_shift_32_table[shift + 1];
2148 FLAG_V = (!(src == 0 || src == m68ki_shift_32_table[shift + 1]))<<7;
2153 FLAG_X = FLAG_C = ((shift == 32 ? src & 1 : 0))<<8;
2154 FLAG_N = NFLAG_CLEAR;
2156 FLAG_V = (!(src == 0))<<7;
2160 FLAG_C = CFLAG_CLEAR;
2161 FLAG_N = NFLAG_32(src);
2163 FLAG_V = VFLAG_CLEAR;
2167 M68KMAKE_OP(asl, 16, ., .)
2169 uint ea = M68KMAKE_GET_EA_AY_16;
2170 uint src = m68ki_read_16(ea);
2171 uint res = MASK_OUT_ABOVE_16(src << 1);
2173 m68ki_write_16(ea, res);
2175 FLAG_N = NFLAG_16(res);
2177 FLAG_X = FLAG_C = src >> 7;
2179 FLAG_V = (!(src == 0 || src == 0xc000))<<7;
2183 M68KMAKE_OP(bcc, 8, ., .)
2187 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
2188 m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR));
2191 USE_CYCLES(CYC_BCC_NOTAKE_B);
2195 M68KMAKE_OP(bcc, 16, ., .)
2199 uint offset = OPER_I_16();
2201 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
2202 m68ki_branch_16(offset);
2206 USE_CYCLES(CYC_BCC_NOTAKE_W);
2210 M68KMAKE_OP(bcc, 32, ., .)
2212 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
2216 uint offset = OPER_I_32();
2218 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
2219 m68ki_branch_32(offset);
2225 m68ki_exception_illegal();
2229 M68KMAKE_OP(bchg, 32, r, d)
2232 uint mask = 1 << (DX & 0x1f);
2234 FLAG_Z = *r_dst & mask;
2239 M68KMAKE_OP(bchg, 8, r, .)
2241 uint ea = M68KMAKE_GET_EA_AY_8;
2242 uint src = m68ki_read_8(ea);
2243 uint mask = 1 << (DX & 7);
2245 FLAG_Z = src & mask;
2246 m68ki_write_8(ea, src ^ mask);
2250 M68KMAKE_OP(bchg, 32, s, d)
2253 uint mask = 1 << (OPER_I_8() & 0x1f);
2255 FLAG_Z = *r_dst & mask;
2260 M68KMAKE_OP(bchg, 8, s, .)
2262 uint mask = 1 << (OPER_I_8() & 7);
2263 uint ea = M68KMAKE_GET_EA_AY_8;
2264 uint src = m68ki_read_8(ea);
2266 FLAG_Z = src & mask;
2267 m68ki_write_8(ea, src ^ mask);
2271 M68KMAKE_OP(bclr, 32, r, d)
2274 uint mask = 1 << (DX & 0x1f);
2276 FLAG_Z = *r_dst & mask;
2281 M68KMAKE_OP(bclr, 8, r, .)
2283 uint ea = M68KMAKE_GET_EA_AY_8;
2284 uint src = m68ki_read_8(ea);
2285 uint mask = 1 << (DX & 7);
2287 FLAG_Z = src & mask;
2288 m68ki_write_8(ea, src & ~mask);
2292 M68KMAKE_OP(bclr, 32, s, d)
2295 uint mask = 1 << (OPER_I_8() & 0x1f);
2297 FLAG_Z = *r_dst & mask;
2302 M68KMAKE_OP(bclr, 8, s, .)
2304 uint mask = 1 << (OPER_I_8() & 7);
2305 uint ea = M68KMAKE_GET_EA_AY_8;
2306 uint src = m68ki_read_8(ea);
2308 FLAG_Z = src & mask;
2309 m68ki_write_8(ea, src & ~mask);
2313 M68KMAKE_OP(bfchg, 32, ., d)
2315 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
2317 uint word2 = OPER_I_16();
2318 uint offset = (word2>>6)&31;
2325 offset = REG_D[offset&7];
2327 width = REG_D[width&7];
2330 width = ((width-1) & 31) + 1;
2332 mask = MASK_OUT_ABOVE_32(0xffffffff << (32 - width));
2333 mask = ROR_32(mask, offset);
2335 FLAG_N = NFLAG_32(*data<<offset);
2336 FLAG_Z = *data & mask;
2337 FLAG_V = VFLAG_CLEAR;
2338 FLAG_C = CFLAG_CLEAR;
2344 m68ki_exception_illegal();
2348 M68KMAKE_OP(bfchg, 32, ., .)
2350 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
2352 uint word2 = OPER_I_16();
2353 sint offset = (word2>>6)&31;
2360 uint ea = M68KMAKE_GET_EA_AY_8;
2364 offset = MAKE_INT_32(REG_D[offset&7]);
2366 width = REG_D[width&7];
2368 /* Offset is signed so we have to use ugly math =( */
2376 width = ((width-1) & 31) + 1;
2378 mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width));
2379 mask_long = mask_base >> offset;
2381 data_long = m68ki_read_32(ea);
2382 FLAG_N = NFLAG_32(data_long << offset);
2383 FLAG_Z = data_long & mask_long;
2384 FLAG_V = VFLAG_CLEAR;
2385 FLAG_C = CFLAG_CLEAR;
2387 m68ki_write_32(ea, data_long ^ mask_long);
2389 if((width + offset) > 32)
2391 mask_byte = MASK_OUT_ABOVE_8(mask_base);
2392 data_byte = m68ki_read_8(ea+4);
2393 FLAG_Z |= (data_byte & mask_byte);
2394 m68ki_write_8(ea+4, data_byte ^ mask_byte);
2398 m68ki_exception_illegal();
2402 M68KMAKE_OP(bfclr, 32, ., d)
2404 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
2406 uint word2 = OPER_I_16();
2407 uint offset = (word2>>6)&31;
2414 offset = REG_D[offset&7];
2416 width = REG_D[width&7];
2420 width = ((width-1) & 31) + 1;
2423 mask = MASK_OUT_ABOVE_32(0xffffffff << (32 - width));
2424 mask = ROR_32(mask, offset);
2426 FLAG_N = NFLAG_32(*data<<offset);
2427 FLAG_Z = *data & mask;
2428 FLAG_V = VFLAG_CLEAR;
2429 FLAG_C = CFLAG_CLEAR;
2435 m68ki_exception_illegal();
2439 M68KMAKE_OP(bfclr, 32, ., .)
2441 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
2443 uint word2 = OPER_I_16();
2444 sint offset = (word2>>6)&31;
2451 uint ea = M68KMAKE_GET_EA_AY_8;
2455 offset = MAKE_INT_32(REG_D[offset&7]);
2457 width = REG_D[width&7];
2459 /* Offset is signed so we have to use ugly math =( */
2467 width = ((width-1) & 31) + 1;
2469 mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width));
2470 mask_long = mask_base >> offset;
2472 data_long = m68ki_read_32(ea);
2473 FLAG_N = NFLAG_32(data_long << offset);
2474 FLAG_Z = data_long & mask_long;
2475 FLAG_V = VFLAG_CLEAR;
2476 FLAG_C = CFLAG_CLEAR;
2478 m68ki_write_32(ea, data_long & ~mask_long);
2480 if((width + offset) > 32)
2482 mask_byte = MASK_OUT_ABOVE_8(mask_base);
2483 data_byte = m68ki_read_8(ea+4);
2484 FLAG_Z |= (data_byte & mask_byte);
2485 m68ki_write_8(ea+4, data_byte & ~mask_byte);
2489 m68ki_exception_illegal();
2493 M68KMAKE_OP(bfexts, 32, ., d)
2495 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
2497 uint word2 = OPER_I_16();
2498 uint offset = (word2>>6)&31;
2504 offset = REG_D[offset&7];
2506 width = REG_D[width&7];
2509 width = ((width-1) & 31) + 1;
2511 data = ROL_32(data, offset);
2512 FLAG_N = NFLAG_32(data);
2513 data = MAKE_INT_32(data) >> (32 - width);
2516 FLAG_V = VFLAG_CLEAR;
2517 FLAG_C = CFLAG_CLEAR;
2519 REG_D[(word2>>12)&7] = data;
2523 m68ki_exception_illegal();
2527 M68KMAKE_OP(bfexts, 32, ., .)
2529 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
2531 uint word2 = OPER_I_16();
2532 sint offset = (word2>>6)&31;
2535 uint ea = M68KMAKE_GET_EA_AY_8;
2539 offset = MAKE_INT_32(REG_D[offset&7]);
2541 width = REG_D[width&7];
2543 /* Offset is signed so we have to use ugly math =( */
2551 width = ((width-1) & 31) + 1;
2553 data = m68ki_read_32(ea);
2555 data = MASK_OUT_ABOVE_32(data<<offset);
2557 if((offset+width) > 32)
2558 data |= (m68ki_read_8(ea+4) << offset) >> 8;
2560 FLAG_N = NFLAG_32(data);
2561 data = MAKE_INT_32(data) >> (32 - width);
2564 FLAG_V = VFLAG_CLEAR;
2565 FLAG_C = CFLAG_CLEAR;
2567 REG_D[(word2 >> 12) & 7] = data;
2571 m68ki_exception_illegal();
2575 M68KMAKE_OP(bfextu, 32, ., d)
2577 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
2579 uint word2 = OPER_I_16();
2580 uint offset = (word2>>6)&31;
2586 offset = REG_D[offset&7];
2588 width = REG_D[width&7];
2591 width = ((width-1) & 31) + 1;
2593 data = ROL_32(data, offset);
2594 FLAG_N = NFLAG_32(data);
2595 data >>= 32 - width;
2598 FLAG_V = VFLAG_CLEAR;
2599 FLAG_C = CFLAG_CLEAR;
2601 REG_D[(word2>>12)&7] = data;
2605 m68ki_exception_illegal();
2609 M68KMAKE_OP(bfextu, 32, ., .)
2611 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
2613 uint word2 = OPER_I_16();
2614 sint offset = (word2>>6)&31;
2617 uint ea = M68KMAKE_GET_EA_AY_8;
2621 offset = MAKE_INT_32(REG_D[offset&7]);
2623 width = REG_D[width&7];
2625 /* Offset is signed so we have to use ugly math =( */
2633 width = ((width-1) & 31) + 1;
2635 data = m68ki_read_32(ea);
2636 data = MASK_OUT_ABOVE_32(data<<offset);
2638 if((offset+width) > 32)
2639 data |= (m68ki_read_8(ea+4) << offset) >> 8;
2641 FLAG_N = NFLAG_32(data);
2642 data >>= (32 - width);
2645 FLAG_V = VFLAG_CLEAR;
2646 FLAG_C = CFLAG_CLEAR;
2648 REG_D[(word2 >> 12) & 7] = data;
2652 m68ki_exception_illegal();
2656 M68KMAKE_OP(bfffo, 32, ., d)
2658 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
2660 uint word2 = OPER_I_16();
2661 uint offset = (word2>>6)&31;
2668 offset = REG_D[offset&7];
2670 width = REG_D[width&7];
2673 width = ((width-1) & 31) + 1;
2675 data = ROL_32(data, offset);
2676 FLAG_N = NFLAG_32(data);
2677 data >>= 32 - width;
2680 FLAG_V = VFLAG_CLEAR;
2681 FLAG_C = CFLAG_CLEAR;
2683 for(bit = 1<<(width-1);bit && !(data & bit);bit>>= 1)
2686 REG_D[(word2>>12)&7] = offset;
2690 m68ki_exception_illegal();
2694 M68KMAKE_OP(bfffo, 32, ., .)
2696 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
2698 uint word2 = OPER_I_16();
2699 sint offset = (word2>>6)&31;
2704 uint ea = M68KMAKE_GET_EA_AY_8;
2708 offset = MAKE_INT_32(REG_D[offset&7]);
2710 width = REG_D[width&7];
2712 /* Offset is signed so we have to use ugly math =( */
2714 local_offset = offset % 8;
2715 if(local_offset < 0)
2720 width = ((width-1) & 31) + 1;
2722 data = m68ki_read_32(ea);
2723 data = MASK_OUT_ABOVE_32(data<<local_offset);
2725 if((local_offset+width) > 32)
2726 data |= (m68ki_read_8(ea+4) << local_offset) >> 8;
2728 FLAG_N = NFLAG_32(data);
2729 data >>= (32 - width);
2732 FLAG_V = VFLAG_CLEAR;
2733 FLAG_C = CFLAG_CLEAR;
2735 for(bit = 1<<(width-1);bit && !(data & bit);bit>>= 1)
2738 REG_D[(word2>>12)&7] = offset;
2742 m68ki_exception_illegal();
2746 M68KMAKE_OP(bfins, 32, ., d)
2748 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
2750 uint word2 = OPER_I_16();
2751 uint offset = (word2>>6)&31;
2755 uint64 insert = REG_D[(word2>>12)&7];
2759 offset = REG_D[offset&7];
2761 width = REG_D[width&7];
2765 width = ((width-1) & 31) + 1;
2768 mask = MASK_OUT_ABOVE_32(0xffffffff << (32 - width));
2769 mask = ROR_32(mask, offset);
2771 insert = MASK_OUT_ABOVE_32(insert << (32 - width));
2772 FLAG_N = NFLAG_32(insert);
2774 insert = ROR_32(insert, offset);
2776 FLAG_V = VFLAG_CLEAR;
2777 FLAG_C = CFLAG_CLEAR;
2784 m68ki_exception_illegal();
2788 M68KMAKE_OP(bfins, 32, ., .)
2790 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
2792 uint word2 = OPER_I_16();
2793 sint offset = (word2>>6)&31;
2795 uint insert_base = REG_D[(word2>>12)&7];
2803 uint ea = M68KMAKE_GET_EA_AY_8;
2807 offset = MAKE_INT_32(REG_D[offset&7]);
2809 width = REG_D[width&7];
2811 /* Offset is signed so we have to use ugly math =( */
2819 width = ((width-1) & 31) + 1;
2821 mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width));
2822 mask_long = mask_base >> offset;
2824 insert_base = MASK_OUT_ABOVE_32(insert_base << (32 - width));
2825 FLAG_N = NFLAG_32(insert_base);
2826 FLAG_Z = insert_base;
2827 insert_long = insert_base >> offset;
2829 data_long = m68ki_read_32(ea);
2830 FLAG_V = VFLAG_CLEAR;
2831 FLAG_C = CFLAG_CLEAR;
2833 m68ki_write_32(ea, (data_long & ~mask_long) | insert_long);
2835 if((width + offset) > 32)
2837 mask_byte = MASK_OUT_ABOVE_8(mask_base);
2838 insert_byte = MASK_OUT_ABOVE_8(insert_base);
2839 data_byte = m68ki_read_8(ea+4);
2840 FLAG_Z |= (data_byte & mask_byte);
2841 m68ki_write_8(ea+4, (data_byte & ~mask_byte) | insert_byte);
2845 m68ki_exception_illegal();
2849 M68KMAKE_OP(bfset, 32, ., d)
2851 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
2853 uint word2 = OPER_I_16();
2854 uint offset = (word2>>6)&31;
2861 offset = REG_D[offset&7];
2863 width = REG_D[width&7];
2867 width = ((width-1) & 31) + 1;
2870 mask = MASK_OUT_ABOVE_32(0xffffffff << (32 - width));
2871 mask = ROR_32(mask, offset);
2873 FLAG_N = NFLAG_32(*data<<offset);
2874 FLAG_Z = *data & mask;
2875 FLAG_V = VFLAG_CLEAR;
2876 FLAG_C = CFLAG_CLEAR;
2882 m68ki_exception_illegal();
2886 M68KMAKE_OP(bfset, 32, ., .)
2888 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
2890 uint word2 = OPER_I_16();
2891 sint offset = (word2>>6)&31;
2898 uint ea = M68KMAKE_GET_EA_AY_8;
2902 offset = MAKE_INT_32(REG_D[offset&7]);
2904 width = REG_D[width&7];
2906 /* Offset is signed so we have to use ugly math =( */
2914 width = ((width-1) & 31) + 1;
2917 mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width));
2918 mask_long = mask_base >> offset;
2920 data_long = m68ki_read_32(ea);
2921 FLAG_N = NFLAG_32(data_long << offset);
2922 FLAG_Z = data_long & mask_long;
2923 FLAG_V = VFLAG_CLEAR;
2924 FLAG_C = CFLAG_CLEAR;
2926 m68ki_write_32(ea, data_long | mask_long);
2928 if((width + offset) > 32)
2930 mask_byte = MASK_OUT_ABOVE_8(mask_base);
2931 data_byte = m68ki_read_8(ea+4);
2932 FLAG_Z |= (data_byte & mask_byte);
2933 m68ki_write_8(ea+4, data_byte | mask_byte);
2937 m68ki_exception_illegal();
2941 M68KMAKE_OP(bftst, 32, ., d)
2943 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
2945 uint word2 = OPER_I_16();
2946 uint offset = (word2>>6)&31;
2953 offset = REG_D[offset&7];
2955 width = REG_D[width&7];
2959 width = ((width-1) & 31) + 1;
2962 mask = MASK_OUT_ABOVE_32(0xffffffff << (32 - width));
2963 mask = ROR_32(mask, offset);
2965 FLAG_N = NFLAG_32(*data<<offset);
2966 FLAG_Z = *data & mask;
2967 FLAG_V = VFLAG_CLEAR;
2968 FLAG_C = CFLAG_CLEAR;
2972 m68ki_exception_illegal();
2976 M68KMAKE_OP(bftst, 32, ., .)
2978 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
2980 uint word2 = OPER_I_16();
2981 sint offset = (word2>>6)&31;
2988 uint ea = M68KMAKE_GET_EA_AY_8;
2991 offset = MAKE_INT_32(REG_D[offset&7]);
2993 width = REG_D[width&7];
2995 /* Offset is signed so we have to use ugly math =( */
3003 width = ((width-1) & 31) + 1;
3006 mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width));
3007 mask_long = mask_base >> offset;
3009 data_long = m68ki_read_32(ea);
3010 FLAG_N = ((data_long & (0x80000000 >> offset))<<offset)>>24;
3011 FLAG_Z = data_long & mask_long;
3012 FLAG_V = VFLAG_CLEAR;
3013 FLAG_C = CFLAG_CLEAR;
3015 if((width + offset) > 32)
3017 mask_byte = MASK_OUT_ABOVE_8(mask_base);
3018 data_byte = m68ki_read_8(ea+4);
3019 FLAG_Z |= (data_byte & mask_byte);
3023 m68ki_exception_illegal();
3027 M68KMAKE_OP(bkpt, 0, ., .)
3029 if(CPU_TYPE_IS_010_PLUS(CPU_TYPE))
3031 m68ki_bkpt_ack(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE) ? REG_IR & 7 : 0); /* auto-disable (see m68kcpu.h) */
3033 m68ki_exception_illegal();
3037 M68KMAKE_OP(bra, 8, ., .)
3039 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
3040 m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR));
3041 if(REG_PC == REG_PPC)
3046 M68KMAKE_OP(bra, 16, ., .)
3048 uint offset = OPER_I_16();
3050 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
3051 m68ki_branch_16(offset);
3052 if(REG_PC == REG_PPC)
3057 M68KMAKE_OP(bra, 32, ., .)
3059 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
3061 uint offset = OPER_I_32();
3063 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
3064 m68ki_branch_32(offset);
3065 if(REG_PC == REG_PPC)
3069 m68ki_exception_illegal();
3073 M68KMAKE_OP(bset, 32, r, d)
3076 uint mask = 1 << (DX & 0x1f);
3078 FLAG_Z = *r_dst & mask;
3083 M68KMAKE_OP(bset, 8, r, .)
3085 uint ea = M68KMAKE_GET_EA_AY_8;
3086 uint src = m68ki_read_8(ea);
3087 uint mask = 1 << (DX & 7);
3089 FLAG_Z = src & mask;
3090 m68ki_write_8(ea, src | mask);
3094 M68KMAKE_OP(bset, 32, s, d)
3097 uint mask = 1 << (OPER_I_8() & 0x1f);
3099 FLAG_Z = *r_dst & mask;
3104 M68KMAKE_OP(bset, 8, s, .)
3106 uint mask = 1 << (OPER_I_8() & 7);
3107 uint ea = M68KMAKE_GET_EA_AY_8;
3108 uint src = m68ki_read_8(ea);
3110 FLAG_Z = src & mask;
3111 m68ki_write_8(ea, src | mask);
3115 M68KMAKE_OP(bsr, 8, ., .)
3117 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
3118 m68ki_push_32(REG_PC);
3119 m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR));
3123 M68KMAKE_OP(bsr, 16, ., .)
3125 uint offset = OPER_I_16();
3126 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
3127 m68ki_push_32(REG_PC);
3129 m68ki_branch_16(offset);
3133 M68KMAKE_OP(bsr, 32, ., .)
3135 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
3137 uint offset = OPER_I_32();
3138 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
3139 m68ki_push_32(REG_PC);
3141 m68ki_branch_32(offset);
3144 m68ki_exception_illegal();
3148 M68KMAKE_OP(btst, 32, r, d)
3150 FLAG_Z = DY & (1 << (DX & 0x1f));
3154 M68KMAKE_OP(btst, 8, r, .)
3156 FLAG_Z = M68KMAKE_GET_OPER_AY_8 & (1 << (DX & 7));
3160 M68KMAKE_OP(btst, 32, s, d)
3162 FLAG_Z = DY & (1 << (OPER_I_8() & 0x1f));
3166 M68KMAKE_OP(btst, 8, s, .)
3168 uint bit = OPER_I_8() & 7;
3170 FLAG_Z = M68KMAKE_GET_OPER_AY_8 & (1 << bit);
3174 M68KMAKE_OP(callm, 32, ., .)
3176 if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE))
3178 uint ea = M68KMAKE_GET_EA_AY_32;
3180 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
3182 (void)ea; /* just to avoid an 'unused variable' warning */
3183 M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n",
3184 m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR,
3185 m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2))));
3188 m68ki_exception_illegal();
3192 M68KMAKE_OP(cas, 8, ., .)
3194 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
3196 uint word2 = OPER_I_16();
3197 uint ea = M68KMAKE_GET_EA_AY_8;
3198 uint dest = m68ki_read_8(ea);
3199 uint* compare = ®_D[word2 & 7];
3200 uint res = dest - MASK_OUT_ABOVE_8(*compare);
3202 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
3203 FLAG_N = NFLAG_8(res);
3204 FLAG_Z = MASK_OUT_ABOVE_8(res);
3205 FLAG_V = VFLAG_SUB_8(*compare, dest, res);
3206 FLAG_C = CFLAG_8(res);
3209 *compare = MASK_OUT_BELOW_8(*compare) | dest;
3213 m68ki_write_8(ea, MASK_OUT_ABOVE_8(REG_D[(word2 >> 6) & 7]));
3217 m68ki_exception_illegal();
3221 M68KMAKE_OP(cas, 16, ., .)
3223 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
3225 uint word2 = OPER_I_16();
3226 uint ea = M68KMAKE_GET_EA_AY_16;
3227 uint dest = m68ki_read_16(ea);
3228 uint* compare = ®_D[word2 & 7];
3229 uint res = dest - MASK_OUT_ABOVE_16(*compare);
3231 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
3232 FLAG_N = NFLAG_16(res);
3233 FLAG_Z = MASK_OUT_ABOVE_16(res);
3234 FLAG_V = VFLAG_SUB_16(*compare, dest, res);
3235 FLAG_C = CFLAG_16(res);
3238 *compare = MASK_OUT_BELOW_16(*compare) | dest;
3242 m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_D[(word2 >> 6) & 7]));
3246 m68ki_exception_illegal();
3250 M68KMAKE_OP(cas, 32, ., .)
3252 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
3254 uint word2 = OPER_I_16();
3255 uint ea = M68KMAKE_GET_EA_AY_32;
3256 uint dest = m68ki_read_32(ea);
3257 uint* compare = ®_D[word2 & 7];
3258 uint res = dest - *compare;
3260 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
3261 FLAG_N = NFLAG_32(res);
3262 FLAG_Z = MASK_OUT_ABOVE_32(res);
3263 FLAG_V = VFLAG_SUB_32(*compare, dest, res);
3264 FLAG_C = CFLAG_SUB_32(*compare, dest, res);
3271 m68ki_write_32(ea, REG_D[(word2 >> 6) & 7]);
3275 m68ki_exception_illegal();
3279 M68KMAKE_OP(cas2, 16, ., .)
3281 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
3283 uint word2 = OPER_I_32();
3284 uint* compare1 = ®_D[(word2 >> 16) & 7];
3285 uint ea1 = REG_DA[(word2 >> 28) & 15];
3286 uint dest1 = m68ki_read_16(ea1);
3287 uint res1 = dest1 - MASK_OUT_ABOVE_16(*compare1);
3288 uint* compare2 = ®_D[word2 & 7];
3289 uint ea2 = REG_DA[(word2 >> 12) & 15];
3290 uint dest2 = m68ki_read_16(ea2);
3293 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
3294 FLAG_N = NFLAG_16(res1);
3295 FLAG_Z = MASK_OUT_ABOVE_16(res1);
3296 FLAG_V = VFLAG_SUB_16(*compare1, dest1, res1);
3297 FLAG_C = CFLAG_16(res1);
3301 res2 = dest2 - MASK_OUT_ABOVE_16(*compare2);
3303 FLAG_N = NFLAG_16(res2);
3304 FLAG_Z = MASK_OUT_ABOVE_16(res2);
3305 FLAG_V = VFLAG_SUB_16(*compare2, dest2, res2);
3306 FLAG_C = CFLAG_16(res2);
3311 m68ki_write_16(ea1, REG_D[(word2 >> 22) & 7]);
3312 m68ki_write_16(ea2, REG_D[(word2 >> 6) & 7]);
3316 *compare1 = BIT_1F(word2) ? MAKE_INT_16(dest1) : MASK_OUT_BELOW_16(*compare1) | dest1;
3317 *compare2 = BIT_F(word2) ? MAKE_INT_16(dest2) : MASK_OUT_BELOW_16(*compare2) | dest2;
3320 m68ki_exception_illegal();
3324 M68KMAKE_OP(cas2, 32, ., .)
3326 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
3328 uint word2 = OPER_I_32();
3329 uint* compare1 = ®_D[(word2 >> 16) & 7];
3330 uint ea1 = REG_DA[(word2 >> 28) & 15];
3331 uint dest1 = m68ki_read_32(ea1);
3332 uint res1 = dest1 - *compare1;
3333 uint* compare2 = ®_D[word2 & 7];
3334 uint ea2 = REG_DA[(word2 >> 12) & 15];
3335 uint dest2 = m68ki_read_32(ea2);
3338 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
3339 FLAG_N = NFLAG_32(res1);
3340 FLAG_Z = MASK_OUT_ABOVE_32(res1);
3341 FLAG_V = VFLAG_SUB_32(*compare1, dest1, res1);
3342 FLAG_C = CFLAG_SUB_32(*compare1, dest1, res1);
3346 res2 = dest2 - *compare2;
3348 FLAG_N = NFLAG_32(res2);
3349 FLAG_Z = MASK_OUT_ABOVE_32(res2);
3350 FLAG_V = VFLAG_SUB_32(*compare2, dest2, res2);
3351 FLAG_C = CFLAG_SUB_32(*compare2, dest2, res2);
3356 m68ki_write_32(ea1, REG_D[(word2 >> 22) & 7]);
3357 m68ki_write_32(ea2, REG_D[(word2 >> 6) & 7]);
3365 m68ki_exception_illegal();
3369 M68KMAKE_OP(chk, 16, ., d)
3371 sint src = MAKE_INT_16(DX);
3372 sint bound = MAKE_INT_16(DY);
3374 if(src >= 0 && src <= bound)
3378 FLAG_N = (src < 0)<<7;
3379 m68ki_exception_trap(EXCEPTION_CHK);
3383 M68KMAKE_OP(chk, 16, ., .)
3385 sint src = MAKE_INT_16(DX);
3386 sint bound = MAKE_INT_16(M68KMAKE_GET_OPER_AY_16);
3388 if(src >= 0 && src <= bound)
3392 FLAG_N = (src < 0)<<7;
3393 m68ki_exception_trap(EXCEPTION_CHK);
3397 M68KMAKE_OP(chk, 32, ., d)
3399 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
3401 sint src = MAKE_INT_32(DX);
3402 sint bound = MAKE_INT_32(DY);
3404 if(src >= 0 && src <= bound)
3408 FLAG_N = (src < 0)<<7;
3409 m68ki_exception_trap(EXCEPTION_CHK);
3412 m68ki_exception_illegal();
3416 M68KMAKE_OP(chk, 32, ., .)
3418 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
3420 sint src = MAKE_INT_32(DX);
3421 sint bound = MAKE_INT_32(M68KMAKE_GET_OPER_AY_32);
3423 if(src >= 0 && src <= bound)
3427 FLAG_N = (src < 0)<<7;
3428 m68ki_exception_trap(EXCEPTION_CHK);
3431 m68ki_exception_illegal();
3435 M68KMAKE_OP(chk2cmp2, 8, ., .)
3437 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
3439 uint word2 = OPER_I_16();
3440 uint compare = REG_DA[(word2 >> 12) & 15];
3441 uint ea = M68KMAKE_GET_EA_AY_8;
3442 uint lower_bound = m68ki_read_8(ea);
3443 uint upper_bound = m68ki_read_8(ea + 1);
3446 compare = MAKE_INT_8(compare);
3448 FLAG_C = compare - lower_bound;
3449 FLAG_Z = MASK_OUT_ABOVE_8(FLAG_C);
3453 m68ki_exception_trap(EXCEPTION_CHK);
3457 FLAG_C = upper_bound - compare;
3458 FLAG_Z = MASK_OUT_ABOVE_8(FLAG_C);
3459 if(COND_CS() && BIT_B(word2))
3460 m68ki_exception_trap(EXCEPTION_CHK);
3464 m68ki_exception_illegal();
3468 M68KMAKE_OP(chk2cmp2, 16, ., .)
3470 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
3472 uint word2 = OPER_I_16();
3473 uint compare = REG_DA[(word2 >> 12) & 15];
3474 uint ea = M68KMAKE_GET_EA_AY_16;
3475 uint lower_bound = m68ki_read_16(ea);
3476 uint upper_bound = m68ki_read_16(ea + 1);
3479 compare = MAKE_INT_16(compare);
3481 FLAG_C = compare - lower_bound;
3482 FLAG_Z = MASK_OUT_ABOVE_16(FLAG_C);
3483 FLAG_C = CFLAG_16(FLAG_C);
3487 m68ki_exception_trap(EXCEPTION_CHK);
3491 FLAG_C = upper_bound - compare;
3492 FLAG_Z = MASK_OUT_ABOVE_16(FLAG_C);
3493 FLAG_C = CFLAG_16(FLAG_C);
3494 if(COND_CS() && BIT_B(word2))
3495 m68ki_exception_trap(EXCEPTION_CHK);
3499 m68ki_exception_illegal();
3503 M68KMAKE_OP(chk2cmp2, 32, ., .)
3505 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
3507 uint word2 = OPER_I_16();
3508 uint compare = REG_DA[(word2 >> 12) & 15];
3509 uint ea = M68KMAKE_GET_EA_AY_32;
3510 uint lower_bound = m68ki_read_32(ea);
3511 uint upper_bound = m68ki_read_32(ea + 1);
3513 FLAG_C = compare - lower_bound;
3514 FLAG_Z = MASK_OUT_ABOVE_32(FLAG_C);
3515 FLAG_C = CFLAG_SUB_32(lower_bound, compare, FLAG_C);
3519 m68ki_exception_trap(EXCEPTION_CHK);
3523 FLAG_C = upper_bound - compare;
3524 FLAG_Z = MASK_OUT_ABOVE_32(FLAG_C);
3525 FLAG_C = CFLAG_SUB_32(compare, upper_bound, FLAG_C);
3526 if(COND_CS() && BIT_B(word2))
3527 m68ki_exception_trap(EXCEPTION_CHK);
3531 m68ki_exception_illegal();
3535 M68KMAKE_OP(clr, 8, ., d)
3539 FLAG_N = NFLAG_CLEAR;
3540 FLAG_V = VFLAG_CLEAR;
3541 FLAG_C = CFLAG_CLEAR;
3546 M68KMAKE_OP(clr, 8, ., .)
3548 m68ki_write_8(M68KMAKE_GET_EA_AY_8, 0);
3550 FLAG_N = NFLAG_CLEAR;
3551 FLAG_V = VFLAG_CLEAR;
3552 FLAG_C = CFLAG_CLEAR;
3557 M68KMAKE_OP(clr, 16, ., d)
3561 FLAG_N = NFLAG_CLEAR;
3562 FLAG_V = VFLAG_CLEAR;
3563 FLAG_C = CFLAG_CLEAR;
3568 M68KMAKE_OP(clr, 16, ., .)
3570 m68ki_write_16(M68KMAKE_GET_EA_AY_16, 0);
3572 FLAG_N = NFLAG_CLEAR;
3573 FLAG_V = VFLAG_CLEAR;
3574 FLAG_C = CFLAG_CLEAR;
3579 M68KMAKE_OP(clr, 32, ., d)
3583 FLAG_N = NFLAG_CLEAR;
3584 FLAG_V = VFLAG_CLEAR;
3585 FLAG_C = CFLAG_CLEAR;
3590 M68KMAKE_OP(clr, 32, ., .)
3592 m68ki_write_32(M68KMAKE_GET_EA_AY_32, 0);
3594 FLAG_N = NFLAG_CLEAR;
3595 FLAG_V = VFLAG_CLEAR;
3596 FLAG_C = CFLAG_CLEAR;
3601 M68KMAKE_OP(cmp, 8, ., d)
3603 uint src = MASK_OUT_ABOVE_8(DY);
3604 uint dst = MASK_OUT_ABOVE_8(DX);
3605 uint res = dst - src;
3607 FLAG_N = NFLAG_8(res);
3608 FLAG_Z = MASK_OUT_ABOVE_8(res);
3609 FLAG_V = VFLAG_SUB_8(src, dst, res);
3610 FLAG_C = CFLAG_8(res);
3614 M68KMAKE_OP(cmp, 8, ., .)
3616 uint src = M68KMAKE_GET_OPER_AY_8;
3617 uint dst = MASK_OUT_ABOVE_8(DX);
3618 uint res = dst - src;
3620 FLAG_N = NFLAG_8(res);
3621 FLAG_Z = MASK_OUT_ABOVE_8(res);
3622 FLAG_V = VFLAG_SUB_8(src, dst, res);
3623 FLAG_C = CFLAG_8(res);
3627 M68KMAKE_OP(cmp, 16, ., d)
3629 uint src = MASK_OUT_ABOVE_16(DY);
3630 uint dst = MASK_OUT_ABOVE_16(DX);
3631 uint res = dst - src;
3633 FLAG_N = NFLAG_16(res);
3634 FLAG_Z = MASK_OUT_ABOVE_16(res);
3635 FLAG_V = VFLAG_SUB_16(src, dst, res);
3636 FLAG_C = CFLAG_16(res);
3640 M68KMAKE_OP(cmp, 16, ., a)
3642 uint src = MASK_OUT_ABOVE_16(AY);
3643 uint dst = MASK_OUT_ABOVE_16(DX);
3644 uint res = dst - src;
3646 FLAG_N = NFLAG_16(res);
3647 FLAG_Z = MASK_OUT_ABOVE_16(res);
3648 FLAG_V = VFLAG_SUB_16(src, dst, res);
3649 FLAG_C = CFLAG_16(res);
3653 M68KMAKE_OP(cmp, 16, ., .)
3655 uint src = M68KMAKE_GET_OPER_AY_16;
3656 uint dst = MASK_OUT_ABOVE_16(DX);
3657 uint res = dst - src;
3659 FLAG_N = NFLAG_16(res);
3660 FLAG_Z = MASK_OUT_ABOVE_16(res);
3661 FLAG_V = VFLAG_SUB_16(src, dst, res);
3662 FLAG_C = CFLAG_16(res);
3666 M68KMAKE_OP(cmp, 32, ., d)
3670 uint res = dst - src;
3672 FLAG_N = NFLAG_32(res);
3673 FLAG_Z = MASK_OUT_ABOVE_32(res);
3674 FLAG_V = VFLAG_SUB_32(src, dst, res);
3675 FLAG_C = CFLAG_SUB_32(src, dst, res);
3679 M68KMAKE_OP(cmp, 32, ., a)
3683 uint res = dst - src;
3685 FLAG_N = NFLAG_32(res);
3686 FLAG_Z = MASK_OUT_ABOVE_32(res);
3687 FLAG_V = VFLAG_SUB_32(src, dst, res);
3688 FLAG_C = CFLAG_SUB_32(src, dst, res);
3692 M68KMAKE_OP(cmp, 32, ., .)
3694 uint src = M68KMAKE_GET_OPER_AY_32;
3696 uint res = dst - src;
3698 FLAG_N = NFLAG_32(res);
3699 FLAG_Z = MASK_OUT_ABOVE_32(res);
3700 FLAG_V = VFLAG_SUB_32(src, dst, res);
3701 FLAG_C = CFLAG_SUB_32(src, dst, res);
3705 M68KMAKE_OP(cmpa, 16, ., d)
3707 uint src = MAKE_INT_16(DY);
3709 uint res = dst - src;
3711 FLAG_N = NFLAG_32(res);
3712 FLAG_Z = MASK_OUT_ABOVE_32(res);
3713 FLAG_V = VFLAG_SUB_32(src, dst, res);
3714 FLAG_C = CFLAG_SUB_32(src, dst, res);
3718 M68KMAKE_OP(cmpa, 16, ., a)
3720 uint src = MAKE_INT_16(AY);
3722 uint res = dst - src;
3724 FLAG_N = NFLAG_32(res);
3725 FLAG_Z = MASK_OUT_ABOVE_32(res);
3726 FLAG_V = VFLAG_SUB_32(src, dst, res);
3727 FLAG_C = CFLAG_SUB_32(src, dst, res);
3731 M68KMAKE_OP(cmpa, 16, ., .)
3733 uint src = MAKE_INT_16(M68KMAKE_GET_OPER_AY_16);
3735 uint res = dst - src;
3737 FLAG_N = NFLAG_32(res);
3738 FLAG_Z = MASK_OUT_ABOVE_32(res);
3739 FLAG_V = VFLAG_SUB_32(src, dst, res);
3740 FLAG_C = CFLAG_SUB_32(src, dst, res);
3744 M68KMAKE_OP(cmpa, 32, ., d)
3748 uint res = dst - src;
3750 FLAG_N = NFLAG_32(res);
3751 FLAG_Z = MASK_OUT_ABOVE_32(res);
3752 FLAG_V = VFLAG_SUB_32(src, dst, res);
3753 FLAG_C = CFLAG_SUB_32(src, dst, res);
3757 M68KMAKE_OP(cmpa, 32, ., a)
3761 uint res = dst - src;
3763 FLAG_N = NFLAG_32(res);
3764 FLAG_Z = MASK_OUT_ABOVE_32(res);
3765 FLAG_V = VFLAG_SUB_32(src, dst, res);
3766 FLAG_C = CFLAG_SUB_32(src, dst, res);
3770 M68KMAKE_OP(cmpa, 32, ., .)
3772 uint src = M68KMAKE_GET_OPER_AY_32;
3774 uint res = dst - src;
3776 FLAG_N = NFLAG_32(res);
3777 FLAG_Z = MASK_OUT_ABOVE_32(res);
3778 FLAG_V = VFLAG_SUB_32(src, dst, res);
3779 FLAG_C = CFLAG_SUB_32(src, dst, res);
3783 M68KMAKE_OP(cmpi, 8, ., d)
3785 uint src = OPER_I_8();
3786 uint dst = MASK_OUT_ABOVE_8(DY);
3787 uint res = dst - src;
3789 FLAG_N = NFLAG_8(res);
3790 FLAG_Z = MASK_OUT_ABOVE_8(res);
3791 FLAG_V = VFLAG_SUB_8(src, dst, res);
3792 FLAG_C = CFLAG_8(res);
3796 M68KMAKE_OP(cmpi, 8, ., .)
3798 uint src = OPER_I_8();
3799 uint dst = M68KMAKE_GET_OPER_AY_8;
3800 uint res = dst - src;
3802 FLAG_N = NFLAG_8(res);
3803 FLAG_Z = MASK_OUT_ABOVE_8(res);
3804 FLAG_V = VFLAG_SUB_8(src, dst, res);
3805 FLAG_C = CFLAG_8(res);
3809 M68KMAKE_OP(cmpi, 8, ., pcdi)
3811 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
3813 uint src = OPER_I_8();
3814 uint dst = OPER_PCDI_8();
3815 uint res = dst - src;
3817 FLAG_N = NFLAG_8(res);
3818 FLAG_Z = MASK_OUT_ABOVE_8(res);
3819 FLAG_V = VFLAG_SUB_8(src, dst, res);
3820 FLAG_C = CFLAG_8(res);
3823 m68ki_exception_illegal();
3827 M68KMAKE_OP(cmpi, 8, ., pcix)
3829 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
3831 uint src = OPER_I_8();
3832 uint dst = OPER_PCIX_8();
3833 uint res = dst - src;
3835 FLAG_N = NFLAG_8(res);
3836 FLAG_Z = MASK_OUT_ABOVE_8(res);
3837 FLAG_V = VFLAG_SUB_8(src, dst, res);
3838 FLAG_C = CFLAG_8(res);
3841 m68ki_exception_illegal();
3845 M68KMAKE_OP(cmpi, 16, ., d)
3847 uint src = OPER_I_16();
3848 uint dst = MASK_OUT_ABOVE_16(DY);
3849 uint res = dst - src;
3851 FLAG_N = NFLAG_16(res);
3852 FLAG_Z = MASK_OUT_ABOVE_16(res);
3853 FLAG_V = VFLAG_SUB_16(src, dst, res);
3854 FLAG_C = CFLAG_16(res);
3858 M68KMAKE_OP(cmpi, 16, ., .)
3860 uint src = OPER_I_16();
3861 uint dst = M68KMAKE_GET_OPER_AY_16;
3862 uint res = dst - src;
3864 FLAG_N = NFLAG_16(res);
3865 FLAG_Z = MASK_OUT_ABOVE_16(res);
3866 FLAG_V = VFLAG_SUB_16(src, dst, res);
3867 FLAG_C = CFLAG_16(res);
3871 M68KMAKE_OP(cmpi, 16, ., pcdi)
3873 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
3875 uint src = OPER_I_16();
3876 uint dst = OPER_PCDI_16();
3877 uint res = dst - src;
3879 FLAG_N = NFLAG_16(res);
3880 FLAG_Z = MASK_OUT_ABOVE_16(res);
3881 FLAG_V = VFLAG_SUB_16(src, dst, res);
3882 FLAG_C = CFLAG_16(res);
3885 m68ki_exception_illegal();
3889 M68KMAKE_OP(cmpi, 16, ., pcix)
3891 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
3893 uint src = OPER_I_16();
3894 uint dst = OPER_PCIX_16();
3895 uint res = dst - src;
3897 FLAG_N = NFLAG_16(res);
3898 FLAG_Z = MASK_OUT_ABOVE_16(res);
3899 FLAG_V = VFLAG_SUB_16(src, dst, res);
3900 FLAG_C = CFLAG_16(res);
3903 m68ki_exception_illegal();
3907 M68KMAKE_OP(cmpi, 32, ., d)
3909 uint src = OPER_I_32();
3911 uint res = dst - src;
3913 FLAG_N = NFLAG_32(res);
3914 FLAG_Z = MASK_OUT_ABOVE_32(res);
3915 FLAG_V = VFLAG_SUB_32(src, dst, res);
3916 FLAG_C = CFLAG_SUB_32(src, dst, res);
3920 M68KMAKE_OP(cmpi, 32, ., .)
3922 uint src = OPER_I_32();
3923 uint dst = M68KMAKE_GET_OPER_AY_32;
3924 uint res = dst - src;
3926 FLAG_N = NFLAG_32(res);
3927 FLAG_Z = MASK_OUT_ABOVE_32(res);
3928 FLAG_V = VFLAG_SUB_32(src, dst, res);
3929 FLAG_C = CFLAG_SUB_32(src, dst, res);
3933 M68KMAKE_OP(cmpi, 32, ., pcdi)
3935 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
3937 uint src = OPER_I_32();
3938 uint dst = OPER_PCDI_32();
3939 uint res = dst - src;
3941 FLAG_N = NFLAG_32(res);
3942 FLAG_Z = MASK_OUT_ABOVE_32(res);
3943 FLAG_V = VFLAG_SUB_32(src, dst, res);
3944 FLAG_C = CFLAG_SUB_32(src, dst, res);
3947 m68ki_exception_illegal();
3951 M68KMAKE_OP(cmpi, 32, ., pcix)
3953 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
3955 uint src = OPER_I_32();
3956 uint dst = OPER_PCIX_32();
3957 uint res = dst - src;
3959 FLAG_N = NFLAG_32(res);
3960 FLAG_Z = MASK_OUT_ABOVE_32(res);
3961 FLAG_V = VFLAG_SUB_32(src, dst, res);
3962 FLAG_C = CFLAG_SUB_32(src, dst, res);
3965 m68ki_exception_illegal();
3969 M68KMAKE_OP(cmpm, 8, ., ax7)
3971 uint src = OPER_AY_PI_8();
3972 uint dst = OPER_A7_PI_8();
3973 uint res = dst - src;
3975 FLAG_N = NFLAG_8(res);
3976 FLAG_Z = MASK_OUT_ABOVE_8(res);
3977 FLAG_V = VFLAG_SUB_8(src, dst, res);
3978 FLAG_C = CFLAG_8(res);
3982 M68KMAKE_OP(cmpm, 8, ., ay7)
3984 uint src = OPER_A7_PI_8();
3985 uint dst = OPER_AX_PI_8();
3986 uint res = dst - src;
3988 FLAG_N = NFLAG_8(res);
3989 FLAG_Z = MASK_OUT_ABOVE_8(res);
3990 FLAG_V = VFLAG_SUB_8(src, dst, res);
3991 FLAG_C = CFLAG_8(res);
3995 M68KMAKE_OP(cmpm, 8, ., axy7)
3997 uint src = OPER_A7_PI_8();
3998 uint dst = OPER_A7_PI_8();
3999 uint res = dst - src;
4001 FLAG_N = NFLAG_8(res);
4002 FLAG_Z = MASK_OUT_ABOVE_8(res);
4003 FLAG_V = VFLAG_SUB_8(src, dst, res);
4004 FLAG_C = CFLAG_8(res);
4008 M68KMAKE_OP(cmpm, 8, ., .)
4010 uint src = OPER_AY_PI_8();
4011 uint dst = OPER_AX_PI_8();
4012 uint res = dst - src;
4014 FLAG_N = NFLAG_8(res);
4015 FLAG_Z = MASK_OUT_ABOVE_8(res);
4016 FLAG_V = VFLAG_SUB_8(src, dst, res);
4017 FLAG_C = CFLAG_8(res);
4021 M68KMAKE_OP(cmpm, 16, ., .)
4023 uint src = OPER_AY_PI_16();
4024 uint dst = OPER_AX_PI_16();
4025 uint res = dst - src;
4027 FLAG_N = NFLAG_16(res);
4028 FLAG_Z = MASK_OUT_ABOVE_16(res);
4029 FLAG_V = VFLAG_SUB_16(src, dst, res);
4030 FLAG_C = CFLAG_16(res);
4034 M68KMAKE_OP(cmpm, 32, ., .)
4036 uint src = OPER_AY_PI_32();
4037 uint dst = OPER_AX_PI_32();
4038 uint res = dst - src;
4040 FLAG_N = NFLAG_32(res);
4041 FLAG_Z = MASK_OUT_ABOVE_32(res);
4042 FLAG_V = VFLAG_SUB_32(src, dst, res);
4043 FLAG_C = CFLAG_SUB_32(src, dst, res);
4047 M68KMAKE_OP(cpbcc, 32, ., .)
4049 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
4051 M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n",
4052 m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR,
4053 m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2))));
4056 m68ki_exception_1111();
4060 M68KMAKE_OP(cpdbcc, 32, ., .)
4062 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
4064 M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n",
4065 m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR,
4066 m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2))));
4069 m68ki_exception_1111();
4073 M68KMAKE_OP(cpgen, 32, ., .)
4075 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
4077 M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n",
4078 m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR,
4079 m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2))));
4082 m68ki_exception_1111();
4086 M68KMAKE_OP(cpscc, 32, ., .)
4088 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
4090 M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n",
4091 m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR,
4092 m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2))));
4095 m68ki_exception_1111();
4099 M68KMAKE_OP(cptrapcc, 32, ., .)
4101 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
4103 M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n",
4104 m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR,
4105 m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2))));
4108 m68ki_exception_1111();
4112 M68KMAKE_OP(dbt, 16, ., .)
4118 M68KMAKE_OP(dbf, 16, ., .)
4121 uint res = MASK_OUT_ABOVE_16(*r_dst - 1);
4123 *r_dst = MASK_OUT_BELOW_16(*r_dst) | res;
4126 uint offset = OPER_I_16();
4128 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
4129 m68ki_branch_16(offset);
4136 M68KMAKE_OP(dbcc, 16, ., .)
4141 uint res = MASK_OUT_ABOVE_16(*r_dst - 1);
4143 *r_dst = MASK_OUT_BELOW_16(*r_dst) | res;
4146 uint offset = OPER_I_16();
4148 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
4149 m68ki_branch_16(offset);
4150 USE_CYCLES(CYC_DBCC_F_NOEXP);
4154 USE_CYCLES(CYC_DBCC_F_EXP);
4161 M68KMAKE_OP(divs, 16, ., d)
4164 sint src = MAKE_INT_16(DY);
4170 if((uint32)*r_dst == 0x80000000 && src == -1)
4173 FLAG_N = NFLAG_CLEAR;
4174 FLAG_V = VFLAG_CLEAR;
4175 FLAG_C = CFLAG_CLEAR;
4180 quotient = MAKE_INT_32(*r_dst) / src;
4181 remainder = MAKE_INT_32(*r_dst) % src;
4183 if(quotient == MAKE_INT_16(quotient))
4186 FLAG_N = NFLAG_16(quotient);
4187 FLAG_V = VFLAG_CLEAR;
4188 FLAG_C = CFLAG_CLEAR;
4189 *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16));
4195 m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE);
4199 M68KMAKE_OP(divs, 16, ., .)
4202 sint src = MAKE_INT_16(M68KMAKE_GET_OPER_AY_16);
4208 if((uint32)*r_dst == 0x80000000 && src == -1)
4211 FLAG_N = NFLAG_CLEAR;
4212 FLAG_V = VFLAG_CLEAR;
4213 FLAG_C = CFLAG_CLEAR;
4218 quotient = MAKE_INT_32(*r_dst) / src;
4219 remainder = MAKE_INT_32(*r_dst) % src;
4221 if(quotient == MAKE_INT_16(quotient))
4224 FLAG_N = NFLAG_16(quotient);
4225 FLAG_V = VFLAG_CLEAR;
4226 FLAG_C = CFLAG_CLEAR;
4227 *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16));
4233 m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE);
4237 M68KMAKE_OP(divu, 16, ., d)
4240 uint src = MASK_OUT_ABOVE_16(DY);
4244 uint quotient = *r_dst / src;
4245 uint remainder = *r_dst % src;
4247 if(quotient < 0x10000)
4250 FLAG_N = NFLAG_16(quotient);
4251 FLAG_V = VFLAG_CLEAR;
4252 FLAG_C = CFLAG_CLEAR;
4253 *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16));
4259 m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE);
4263 M68KMAKE_OP(divu, 16, ., .)
4266 uint src = M68KMAKE_GET_OPER_AY_16;
4270 uint quotient = *r_dst / src;
4271 uint remainder = *r_dst % src;
4273 if(quotient < 0x10000)
4276 FLAG_N = NFLAG_16(quotient);
4277 FLAG_V = VFLAG_CLEAR;
4278 FLAG_C = CFLAG_CLEAR;
4279 *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16));
4285 m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE);
4289 M68KMAKE_OP(divl, 32, ., d)
4293 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
4295 uint word2 = OPER_I_16();
4296 uint64 divisor = DY;
4297 uint64 dividend = 0;
4298 uint64 quotient = 0;
4299 uint64 remainder = 0;
4303 if(BIT_A(word2)) /* 64 bit */
4305 dividend = REG_D[word2 & 7];
4307 dividend |= REG_D[(word2 >> 12) & 7];
4309 if(BIT_B(word2)) /* signed */
4311 quotient = (uint64)((sint64)dividend / (sint64)((sint32)divisor));
4312 remainder = (uint64)((sint64)dividend % (sint64)((sint32)divisor));
4313 if((sint64)quotient != (sint64)((sint32)quotient))
4321 quotient = dividend / divisor;
4322 if(quotient > 0xffffffff)
4327 remainder = dividend % divisor;
4332 dividend = REG_D[(word2 >> 12) & 7];
4333 if(BIT_B(word2)) /* signed */
4335 quotient = (uint64)((sint64)((sint32)dividend) / (sint64)((sint32)divisor));
4336 remainder = (uint64)((sint64)((sint32)dividend) % (sint64)((sint32)divisor));
4340 quotient = dividend / divisor;
4341 remainder = dividend % divisor;
4345 REG_D[word2 & 7] = remainder;
4346 REG_D[(word2 >> 12) & 7] = quotient;
4348 FLAG_N = NFLAG_32(quotient);
4350 FLAG_V = VFLAG_CLEAR;
4351 FLAG_C = CFLAG_CLEAR;
4354 m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE);
4357 m68ki_exception_illegal();
4361 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
4363 uint word2 = OPER_I_16();
4365 uint dividend_hi = REG_D[word2 & 7];
4366 uint dividend_lo = REG_D[(word2 >> 12) & 7];
4369 uint dividend_neg = 0;
4370 uint divisor_neg = 0;
4376 /* quad / long : long quotient, long remainder */
4379 if(BIT_B(word2)) /* signed */
4381 /* special case in signed divide */
4382 if(dividend_hi == 0 && dividend_lo == 0x80000000 && divisor == 0xffffffff)
4384 REG_D[word2 & 7] = 0;
4385 REG_D[(word2 >> 12) & 7] = 0x80000000;
4388 FLAG_Z = ZFLAG_CLEAR;
4389 FLAG_V = VFLAG_CLEAR;
4390 FLAG_C = CFLAG_CLEAR;
4393 if(GET_MSB_32(dividend_hi))
4396 dividend_hi = (uint)MASK_OUT_ABOVE_32((-(sint)dividend_hi) - (dividend_lo != 0));
4397 dividend_lo = (uint)MASK_OUT_ABOVE_32(-(sint)dividend_lo);
4399 if(GET_MSB_32(divisor))
4402 divisor = (uint)MASK_OUT_ABOVE_32(-(sint)divisor);
4407 /* if the upper long is greater than the divisor, we're overflowing. */
4408 if(dividend_hi >= divisor)
4414 for(i = 31; i >= 0; i--)
4417 remainder = (remainder << 1) + ((dividend_hi >> i) & 1);
4418 if(remainder >= divisor)
4420 remainder -= divisor;
4424 for(i = 31; i >= 0; i--)
4427 overflow = GET_MSB_32(remainder);
4428 remainder = (remainder << 1) + ((dividend_lo >> i) & 1);
4429 if(remainder >= divisor || overflow)
4431 remainder -= divisor;
4436 if(BIT_B(word2)) /* signed */
4438 if(quotient > 0x7fffffff)
4445 remainder = (uint)MASK_OUT_ABOVE_32(-(sint)remainder);
4446 quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient);
4449 quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient);
4452 REG_D[word2 & 7] = remainder;
4453 REG_D[(word2 >> 12) & 7] = quotient;
4455 FLAG_N = NFLAG_32(quotient);
4457 FLAG_V = VFLAG_CLEAR;
4458 FLAG_C = CFLAG_CLEAR;
4462 /* long / long: long quotient, maybe long remainder */
4463 if(BIT_B(word2)) /* signed */
4465 /* Special case in divide */
4466 if(dividend_lo == 0x80000000 && divisor == 0xffffffff)
4469 FLAG_Z = ZFLAG_CLEAR;
4470 FLAG_V = VFLAG_CLEAR;
4471 FLAG_C = CFLAG_CLEAR;
4472 REG_D[(word2 >> 12) & 7] = 0x80000000;
4473 REG_D[word2 & 7] = 0;
4476 REG_D[word2 & 7] = MAKE_INT_32(dividend_lo) % MAKE_INT_32(divisor);
4477 quotient = REG_D[(word2 >> 12) & 7] = MAKE_INT_32(dividend_lo) / MAKE_INT_32(divisor);
4481 REG_D[word2 & 7] = MASK_OUT_ABOVE_32(dividend_lo) % MASK_OUT_ABOVE_32(divisor);
4482 quotient = REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(dividend_lo) / MASK_OUT_ABOVE_32(divisor);
4485 FLAG_N = NFLAG_32(quotient);
4487 FLAG_V = VFLAG_CLEAR;
4488 FLAG_C = CFLAG_CLEAR;
4491 m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE);
4494 m68ki_exception_illegal();
4500 M68KMAKE_OP(divl, 32, ., .)
4504 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
4506 uint word2 = OPER_I_16();
4507 uint64 divisor = M68KMAKE_GET_OPER_AY_32;
4508 uint64 dividend = 0;
4509 uint64 quotient = 0;
4510 uint64 remainder = 0;
4514 if(BIT_A(word2)) /* 64 bit */
4516 dividend = REG_D[word2 & 7];
4518 dividend |= REG_D[(word2 >> 12) & 7];
4520 if(BIT_B(word2)) /* signed */
4522 quotient = (uint64)((sint64)dividend / (sint64)((sint32)divisor));
4523 remainder = (uint64)((sint64)dividend % (sint64)((sint32)divisor));
4524 if((sint64)quotient != (sint64)((sint32)quotient))
4532 quotient = dividend / divisor;
4533 if(quotient > 0xffffffff)
4538 remainder = dividend % divisor;
4543 dividend = REG_D[(word2 >> 12) & 7];
4544 if(BIT_B(word2)) /* signed */
4546 quotient = (uint64)((sint64)((sint32)dividend) / (sint64)((sint32)divisor));
4547 remainder = (uint64)((sint64)((sint32)dividend) % (sint64)((sint32)divisor));
4551 quotient = dividend / divisor;
4552 remainder = dividend % divisor;
4556 REG_D[word2 & 7] = remainder;
4557 REG_D[(word2 >> 12) & 7] = quotient;
4559 FLAG_N = NFLAG_32(quotient);
4561 FLAG_V = VFLAG_CLEAR;
4562 FLAG_C = CFLAG_CLEAR;
4565 m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE);
4568 m68ki_exception_illegal();
4572 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
4574 uint word2 = OPER_I_16();
4575 uint divisor = M68KMAKE_GET_OPER_AY_32;
4576 uint dividend_hi = REG_D[word2 & 7];
4577 uint dividend_lo = REG_D[(word2 >> 12) & 7];
4580 uint dividend_neg = 0;
4581 uint divisor_neg = 0;
4587 /* quad / long : long quotient, long remainder */
4590 if(BIT_B(word2)) /* signed */
4592 /* special case in signed divide */
4593 if(dividend_hi == 0 && dividend_lo == 0x80000000 && divisor == 0xffffffff)
4595 REG_D[word2 & 7] = 0;
4596 REG_D[(word2 >> 12) & 7] = 0x80000000;
4599 FLAG_Z = ZFLAG_CLEAR;
4600 FLAG_V = VFLAG_CLEAR;
4601 FLAG_C = CFLAG_CLEAR;
4604 if(GET_MSB_32(dividend_hi))
4607 dividend_hi = (uint)MASK_OUT_ABOVE_32((-(sint)dividend_hi) - (dividend_lo != 0));
4608 dividend_lo = (uint)MASK_OUT_ABOVE_32(-(sint)dividend_lo);
4610 if(GET_MSB_32(divisor))
4613 divisor = (uint)MASK_OUT_ABOVE_32(-(sint)divisor);
4618 /* if the upper long is greater than the divisor, we're overflowing. */
4619 if(dividend_hi >= divisor)
4625 for(i = 31; i >= 0; i--)
4628 remainder = (remainder << 1) + ((dividend_hi >> i) & 1);
4629 if(remainder >= divisor)
4631 remainder -= divisor;
4635 for(i = 31; i >= 0; i--)
4638 overflow = GET_MSB_32(remainder);
4639 remainder = (remainder << 1) + ((dividend_lo >> i) & 1);
4640 if(remainder >= divisor || overflow)
4642 remainder -= divisor;
4647 if(BIT_B(word2)) /* signed */
4649 if(quotient > 0x7fffffff)
4656 remainder = (uint)MASK_OUT_ABOVE_32(-(sint)remainder);
4657 quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient);
4660 quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient);
4663 REG_D[word2 & 7] = remainder;
4664 REG_D[(word2 >> 12) & 7] = quotient;
4666 FLAG_N = NFLAG_32(quotient);
4668 FLAG_V = VFLAG_CLEAR;
4669 FLAG_C = CFLAG_CLEAR;
4673 /* long / long: long quotient, maybe long remainder */
4674 if(BIT_B(word2)) /* signed */
4676 /* Special case in divide */
4677 if(dividend_lo == 0x80000000 && divisor == 0xffffffff)
4680 FLAG_Z = ZFLAG_CLEAR;
4681 FLAG_V = VFLAG_CLEAR;
4682 FLAG_C = CFLAG_CLEAR;
4683 REG_D[(word2 >> 12) & 7] = 0x80000000;
4684 REG_D[word2 & 7] = 0;
4687 REG_D[word2 & 7] = MAKE_INT_32(dividend_lo) % MAKE_INT_32(divisor);
4688 quotient = REG_D[(word2 >> 12) & 7] = MAKE_INT_32(dividend_lo) / MAKE_INT_32(divisor);
4692 REG_D[word2 & 7] = MASK_OUT_ABOVE_32(dividend_lo) % MASK_OUT_ABOVE_32(divisor);
4693 quotient = REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(dividend_lo) / MASK_OUT_ABOVE_32(divisor);
4696 FLAG_N = NFLAG_32(quotient);
4698 FLAG_V = VFLAG_CLEAR;
4699 FLAG_C = CFLAG_CLEAR;
4702 m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE);
4705 m68ki_exception_illegal();
4711 M68KMAKE_OP(eor, 8, ., d)
4713 uint res = MASK_OUT_ABOVE_8(DY ^= MASK_OUT_ABOVE_8(DX));
4715 FLAG_N = NFLAG_8(res);
4717 FLAG_C = CFLAG_CLEAR;
4718 FLAG_V = VFLAG_CLEAR;
4722 M68KMAKE_OP(eor, 8, ., .)
4724 uint ea = M68KMAKE_GET_EA_AY_8;
4725 uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea));
4727 m68ki_write_8(ea, res);
4729 FLAG_N = NFLAG_8(res);
4731 FLAG_C = CFLAG_CLEAR;
4732 FLAG_V = VFLAG_CLEAR;
4736 M68KMAKE_OP(eor, 16, ., d)
4738 uint res = MASK_OUT_ABOVE_16(DY ^= MASK_OUT_ABOVE_16(DX));
4740 FLAG_N = NFLAG_16(res);
4742 FLAG_C = CFLAG_CLEAR;
4743 FLAG_V = VFLAG_CLEAR;
4747 M68KMAKE_OP(eor, 16, ., .)
4749 uint ea = M68KMAKE_GET_EA_AY_16;
4750 uint res = MASK_OUT_ABOVE_16(DX ^ m68ki_read_16(ea));
4752 m68ki_write_16(ea, res);
4754 FLAG_N = NFLAG_16(res);
4756 FLAG_C = CFLAG_CLEAR;
4757 FLAG_V = VFLAG_CLEAR;
4761 M68KMAKE_OP(eor, 32, ., d)
4763 uint res = DY ^= DX;
4765 FLAG_N = NFLAG_32(res);
4767 FLAG_C = CFLAG_CLEAR;
4768 FLAG_V = VFLAG_CLEAR;
4772 M68KMAKE_OP(eor, 32, ., .)
4774 uint ea = M68KMAKE_GET_EA_AY_32;
4775 uint res = DX ^ m68ki_read_32(ea);
4777 m68ki_write_32(ea, res);
4779 FLAG_N = NFLAG_32(res);
4781 FLAG_C = CFLAG_CLEAR;
4782 FLAG_V = VFLAG_CLEAR;
4786 M68KMAKE_OP(eori, 8, ., d)
4788 uint res = MASK_OUT_ABOVE_8(DY ^= OPER_I_8());
4790 FLAG_N = NFLAG_8(res);
4792 FLAG_C = CFLAG_CLEAR;
4793 FLAG_V = VFLAG_CLEAR;
4797 M68KMAKE_OP(eori, 8, ., .)
4799 uint src = OPER_I_8();
4800 uint ea = M68KMAKE_GET_EA_AY_8;
4801 uint res = src ^ m68ki_read_8(ea);
4803 m68ki_write_8(ea, res);
4805 FLAG_N = NFLAG_8(res);
4807 FLAG_C = CFLAG_CLEAR;
4808 FLAG_V = VFLAG_CLEAR;
4812 M68KMAKE_OP(eori, 16, ., d)
4814 uint res = MASK_OUT_ABOVE_16(DY ^= OPER_I_16());
4816 FLAG_N = NFLAG_16(res);
4818 FLAG_C = CFLAG_CLEAR;
4819 FLAG_V = VFLAG_CLEAR;
4823 M68KMAKE_OP(eori, 16, ., .)
4825 uint src = OPER_I_16();
4826 uint ea = M68KMAKE_GET_EA_AY_16;
4827 uint res = src ^ m68ki_read_16(ea);
4829 m68ki_write_16(ea, res);
4831 FLAG_N = NFLAG_16(res);
4833 FLAG_C = CFLAG_CLEAR;
4834 FLAG_V = VFLAG_CLEAR;
4838 M68KMAKE_OP(eori, 32, ., d)
4840 uint res = DY ^= OPER_I_32();
4842 FLAG_N = NFLAG_32(res);
4844 FLAG_C = CFLAG_CLEAR;
4845 FLAG_V = VFLAG_CLEAR;
4849 M68KMAKE_OP(eori, 32, ., .)
4851 uint src = OPER_I_32();
4852 uint ea = M68KMAKE_GET_EA_AY_32;
4853 uint res = src ^ m68ki_read_32(ea);
4855 m68ki_write_32(ea, res);
4857 FLAG_N = NFLAG_32(res);
4859 FLAG_C = CFLAG_CLEAR;
4860 FLAG_V = VFLAG_CLEAR;
4864 M68KMAKE_OP(eori, 16, toc, .)
4866 m68ki_set_ccr(m68ki_get_ccr() ^ OPER_I_16());
4870 M68KMAKE_OP(eori, 16, tos, .)
4874 uint src = OPER_I_16();
4875 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
4876 m68ki_set_sr(m68ki_get_sr() ^ src);
4879 m68ki_exception_privilege_violation();
4883 M68KMAKE_OP(exg, 32, dd, .)
4893 M68KMAKE_OP(exg, 32, aa, .)
4903 M68KMAKE_OP(exg, 32, da, .)
4913 M68KMAKE_OP(ext, 16, ., .)
4917 *r_dst = MASK_OUT_BELOW_16(*r_dst) | MASK_OUT_ABOVE_8(*r_dst) | (GET_MSB_8(*r_dst) ? 0xff00 : 0);
4919 FLAG_N = NFLAG_16(*r_dst);
4920 FLAG_Z = MASK_OUT_ABOVE_16(*r_dst);
4921 FLAG_V = VFLAG_CLEAR;
4922 FLAG_C = CFLAG_CLEAR;
4926 M68KMAKE_OP(ext, 32, ., .)
4930 *r_dst = MASK_OUT_ABOVE_16(*r_dst) | (GET_MSB_16(*r_dst) ? 0xffff0000 : 0);
4932 FLAG_N = NFLAG_32(*r_dst);
4934 FLAG_V = VFLAG_CLEAR;
4935 FLAG_C = CFLAG_CLEAR;
4939 M68KMAKE_OP(extb, 32, ., .)
4941 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
4945 *r_dst = MASK_OUT_ABOVE_8(*r_dst) | (GET_MSB_8(*r_dst) ? 0xffffff00 : 0);
4947 FLAG_N = NFLAG_32(*r_dst);
4949 FLAG_V = VFLAG_CLEAR;
4950 FLAG_C = CFLAG_CLEAR;
4953 m68ki_exception_illegal();
4957 M68KMAKE_OP(illegal, 0, ., .)
4959 m68ki_exception_illegal();
4962 M68KMAKE_OP(jmp, 32, ., .)
4964 m68ki_jump(M68KMAKE_GET_EA_AY_32);
4965 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
4966 if(REG_PC == REG_PPC)
4971 M68KMAKE_OP(jsr, 32, ., .)
4973 uint ea = M68KMAKE_GET_EA_AY_32;
4974 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
4975 m68ki_push_32(REG_PC);
4980 M68KMAKE_OP(lea, 32, ., .)
4982 AX = M68KMAKE_GET_EA_AY_32;
4986 M68KMAKE_OP(link, 16, ., a7)
4989 m68ki_write_32(REG_A[7], REG_A[7]);
4990 REG_A[7] = MASK_OUT_ABOVE_32(REG_A[7] + MAKE_INT_16(OPER_I_16()));
4994 M68KMAKE_OP(link, 16, ., .)
4998 m68ki_push_32(*r_dst);
5000 REG_A[7] = MASK_OUT_ABOVE_32(REG_A[7] + MAKE_INT_16(OPER_I_16()));
5004 M68KMAKE_OP(link, 32, ., a7)
5006 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
5009 m68ki_write_32(REG_A[7], REG_A[7]);
5010 REG_A[7] = MASK_OUT_ABOVE_32(REG_A[7] + OPER_I_32());
5013 m68ki_exception_illegal();
5017 M68KMAKE_OP(link, 32, ., .)
5019 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
5023 m68ki_push_32(*r_dst);
5025 REG_A[7] = MASK_OUT_ABOVE_32(REG_A[7] + OPER_I_32());
5028 m68ki_exception_illegal();
5032 M68KMAKE_OP(lsr, 8, s, .)
5035 uint shift = (((REG_IR >> 9) - 1) & 7) + 1;
5036 uint src = MASK_OUT_ABOVE_8(*r_dst);
5037 uint res = src >> shift;
5039 *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;
5041 FLAG_N = NFLAG_CLEAR;
5043 FLAG_X = FLAG_C = src << (9-shift);
5044 FLAG_V = VFLAG_CLEAR;
5048 M68KMAKE_OP(lsr, 16, s, .)
5051 uint shift = (((REG_IR >> 9) - 1) & 7) + 1;
5052 uint src = MASK_OUT_ABOVE_16(*r_dst);
5053 uint res = src >> shift;
5055 *r_dst = MASK_OUT_BELOW_16(*r_dst) | res;
5057 FLAG_N = NFLAG_CLEAR;
5059 FLAG_X = FLAG_C = src << (9-shift);
5060 FLAG_V = VFLAG_CLEAR;
5064 M68KMAKE_OP(lsr, 32, s, .)
5067 uint shift = (((REG_IR >> 9) - 1) & 7) + 1;
5069 uint res = src >> shift;
5073 FLAG_N = NFLAG_CLEAR;
5075 FLAG_X = FLAG_C = src << (9-shift);
5076 FLAG_V = VFLAG_CLEAR;
5080 M68KMAKE_OP(lsr, 8, r, .)
5083 uint shift = DX & 0x3f;
5084 uint src = MASK_OUT_ABOVE_8(*r_dst);
5085 uint res = src >> shift;
5089 USE_CYCLES(shift<<CYC_SHIFT);
5093 *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;
5094 FLAG_X = FLAG_C = src << (9-shift);
5095 FLAG_N = NFLAG_CLEAR;
5097 FLAG_V = VFLAG_CLEAR;
5101 *r_dst &= 0xffffff00;
5102 FLAG_X = XFLAG_CLEAR;
5103 FLAG_C = CFLAG_CLEAR;
5104 FLAG_N = NFLAG_CLEAR;
5106 FLAG_V = VFLAG_CLEAR;
5110 FLAG_C = CFLAG_CLEAR;
5111 FLAG_N = NFLAG_8(src);
5113 FLAG_V = VFLAG_CLEAR;
5117 M68KMAKE_OP(lsr, 16, r, .)
5120 uint shift = DX & 0x3f;
5121 uint src = MASK_OUT_ABOVE_16(*r_dst);
5122 uint res = src >> shift;
5126 USE_CYCLES(shift<<CYC_SHIFT);
5130 *r_dst = MASK_OUT_BELOW_16(*r_dst) | res;
5131 FLAG_C = FLAG_X = (src >> (shift - 1))<<8;
5132 FLAG_N = NFLAG_CLEAR;
5134 FLAG_V = VFLAG_CLEAR;
5138 *r_dst &= 0xffff0000;
5139 FLAG_X = XFLAG_CLEAR;
5140 FLAG_C = CFLAG_CLEAR;
5141 FLAG_N = NFLAG_CLEAR;
5143 FLAG_V = VFLAG_CLEAR;
5147 FLAG_C = CFLAG_CLEAR;
5148 FLAG_N = NFLAG_16(src);
5150 FLAG_V = VFLAG_CLEAR;
5154 M68KMAKE_OP(lsr, 32, r, .)
5157 uint shift = DX & 0x3f;
5159 uint res = src >> shift;
5163 USE_CYCLES(shift<<CYC_SHIFT);
5168 FLAG_C = FLAG_X = (src >> (shift - 1))<<8;
5169 FLAG_N = NFLAG_CLEAR;
5171 FLAG_V = VFLAG_CLEAR;
5176 FLAG_X = FLAG_C = (shift == 32 ? GET_MSB_32(src)>>23 : 0);
5177 FLAG_N = NFLAG_CLEAR;
5179 FLAG_V = VFLAG_CLEAR;
5183 FLAG_C = CFLAG_CLEAR;
5184 FLAG_N = NFLAG_32(src);
5186 FLAG_V = VFLAG_CLEAR;
5190 M68KMAKE_OP(lsr, 16, ., .)
5192 uint ea = M68KMAKE_GET_EA_AY_16;
5193 uint src = m68ki_read_16(ea);
5194 uint res = src >> 1;
5196 m68ki_write_16(ea, res);
5198 FLAG_N = NFLAG_CLEAR;
5200 FLAG_C = FLAG_X = src << 8;
5201 FLAG_V = VFLAG_CLEAR;
5205 M68KMAKE_OP(lsl, 8, s, .)
5208 uint shift = (((REG_IR >> 9) - 1) & 7) + 1;
5209 uint src = MASK_OUT_ABOVE_8(*r_dst);
5210 uint res = MASK_OUT_ABOVE_8(src << shift);
5212 *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;
5214 FLAG_N = NFLAG_8(res);
5216 FLAG_X = FLAG_C = src << shift;
5217 FLAG_V = VFLAG_CLEAR;
5221 M68KMAKE_OP(lsl, 16, s, .)
5224 uint shift = (((REG_IR >> 9) - 1) & 7) + 1;
5225 uint src = MASK_OUT_ABOVE_16(*r_dst);
5226 uint res = MASK_OUT_ABOVE_16(src << shift);
5228 *r_dst = MASK_OUT_BELOW_16(*r_dst) | res;
5230 FLAG_N = NFLAG_16(res);
5232 FLAG_X = FLAG_C = src >> (8-shift);
5233 FLAG_V = VFLAG_CLEAR;
5237 M68KMAKE_OP(lsl, 32, s, .)
5240 uint shift = (((REG_IR >> 9) - 1) & 7) + 1;
5242 uint res = MASK_OUT_ABOVE_32(src << shift);
5246 FLAG_N = NFLAG_32(res);
5248 FLAG_X = FLAG_C = src >> (24-shift);
5249 FLAG_V = VFLAG_CLEAR;
5253 M68KMAKE_OP(lsl, 8, r, .)
5256 uint shift = DX & 0x3f;
5257 uint src = MASK_OUT_ABOVE_8(*r_dst);
5258 uint res = MASK_OUT_ABOVE_8(src << shift);
5262 USE_CYCLES(shift<<CYC_SHIFT);
5266 *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;
5267 FLAG_X = FLAG_C = src << shift;
5268 FLAG_N = NFLAG_8(res);
5270 FLAG_V = VFLAG_CLEAR;
5274 *r_dst &= 0xffffff00;
5275 FLAG_X = XFLAG_CLEAR;
5276 FLAG_C = CFLAG_CLEAR;
5277 FLAG_N = NFLAG_CLEAR;
5279 FLAG_V = VFLAG_CLEAR;
5283 FLAG_C = CFLAG_CLEAR;
5284 FLAG_N = NFLAG_8(src);
5286 FLAG_V = VFLAG_CLEAR;
5290 M68KMAKE_OP(lsl, 16, r, .)
5293 uint shift = DX & 0x3f;
5294 uint src = MASK_OUT_ABOVE_16(*r_dst);
5295 uint res = MASK_OUT_ABOVE_16(src << shift);
5299 USE_CYCLES(shift<<CYC_SHIFT);
5303 *r_dst = MASK_OUT_BELOW_16(*r_dst) | res;
5304 FLAG_X = FLAG_C = (src << shift) >> 8;
5305 FLAG_N = NFLAG_16(res);
5307 FLAG_V = VFLAG_CLEAR;
5311 *r_dst &= 0xffff0000;
5312 FLAG_X = XFLAG_CLEAR;
5313 FLAG_C = CFLAG_CLEAR;
5314 FLAG_N = NFLAG_CLEAR;
5316 FLAG_V = VFLAG_CLEAR;
5320 FLAG_C = CFLAG_CLEAR;
5321 FLAG_N = NFLAG_16(src);
5323 FLAG_V = VFLAG_CLEAR;
5327 M68KMAKE_OP(lsl, 32, r, .)
5330 uint shift = DX & 0x3f;
5332 uint res = MASK_OUT_ABOVE_32(src << shift);
5336 USE_CYCLES(shift<<CYC_SHIFT);
5341 FLAG_X = FLAG_C = (src >> (32 - shift)) << 8;
5342 FLAG_N = NFLAG_32(res);
5344 FLAG_V = VFLAG_CLEAR;
5349 FLAG_X = FLAG_C = ((shift == 32 ? src & 1 : 0))<<8;
5350 FLAG_N = NFLAG_CLEAR;
5352 FLAG_V = VFLAG_CLEAR;
5356 FLAG_C = CFLAG_CLEAR;
5357 FLAG_N = NFLAG_32(src);
5359 FLAG_V = VFLAG_CLEAR;
5363 M68KMAKE_OP(lsl, 16, ., .)
5365 uint ea = M68KMAKE_GET_EA_AY_16;
5366 uint src = m68ki_read_16(ea);
5367 uint res = MASK_OUT_ABOVE_16(src << 1);
5369 m68ki_write_16(ea, res);
5371 FLAG_N = NFLAG_16(res);
5373 FLAG_X = FLAG_C = src >> 7;
5374 FLAG_V = VFLAG_CLEAR;
5378 M68KMAKE_OP(move, 8, d, d)
5380 uint res = MASK_OUT_ABOVE_8(DY);
5383 *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;
5385 FLAG_N = NFLAG_8(res);
5387 FLAG_V = VFLAG_CLEAR;
5388 FLAG_C = CFLAG_CLEAR;
5392 M68KMAKE_OP(move, 8, d, .)
5394 uint res = M68KMAKE_GET_OPER_AY_8;
5397 *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;
5399 FLAG_N = NFLAG_8(res);
5401 FLAG_V = VFLAG_CLEAR;
5402 FLAG_C = CFLAG_CLEAR;
5406 M68KMAKE_OP(move, 8, ai, d)
5408 uint res = MASK_OUT_ABOVE_8(DY);
5409 uint ea = EA_AX_AI_8();
5411 m68ki_write_8(ea, res);
5413 FLAG_N = NFLAG_8(res);
5415 FLAG_V = VFLAG_CLEAR;
5416 FLAG_C = CFLAG_CLEAR;
5420 M68KMAKE_OP(move, 8, ai, .)
5422 uint res = M68KMAKE_GET_OPER_AY_8;
5423 uint ea = EA_AX_AI_8();
5425 m68ki_write_8(ea, res);
5427 FLAG_N = NFLAG_8(res);
5429 FLAG_V = VFLAG_CLEAR;
5430 FLAG_C = CFLAG_CLEAR;
5434 M68KMAKE_OP(move, 8, pi7, d)
5436 uint res = MASK_OUT_ABOVE_8(DY);
5437 uint ea = EA_A7_PI_8();
5439 m68ki_write_8(ea, res);
5441 FLAG_N = NFLAG_8(res);
5443 FLAG_V = VFLAG_CLEAR;
5444 FLAG_C = CFLAG_CLEAR;
5448 M68KMAKE_OP(move, 8, pi, d)
5450 uint res = MASK_OUT_ABOVE_8(DY);
5451 uint ea = EA_AX_PI_8();
5453 m68ki_write_8(ea, res);
5455 FLAG_N = NFLAG_8(res);
5457 FLAG_V = VFLAG_CLEAR;
5458 FLAG_C = CFLAG_CLEAR;
5462 M68KMAKE_OP(move, 8, pi7, .)
5464 uint res = M68KMAKE_GET_OPER_AY_8;
5465 uint ea = EA_A7_PI_8();
5467 m68ki_write_8(ea, res);
5469 FLAG_N = NFLAG_8(res);
5471 FLAG_V = VFLAG_CLEAR;
5472 FLAG_C = CFLAG_CLEAR;
5476 M68KMAKE_OP(move, 8, pi, .)
5478 uint res = M68KMAKE_GET_OPER_AY_8;
5479 uint ea = EA_AX_PI_8();
5481 m68ki_write_8(ea, res);
5483 FLAG_N = NFLAG_8(res);
5485 FLAG_V = VFLAG_CLEAR;
5486 FLAG_C = CFLAG_CLEAR;
5490 M68KMAKE_OP(move, 8, pd7, d)
5492 uint res = MASK_OUT_ABOVE_8(DY);
5493 uint ea = EA_A7_PD_8();
5495 m68ki_write_8(ea, res);
5497 FLAG_N = NFLAG_8(res);
5499 FLAG_V = VFLAG_CLEAR;
5500 FLAG_C = CFLAG_CLEAR;
5504 M68KMAKE_OP(move, 8, pd, d)
5506 uint res = MASK_OUT_ABOVE_8(DY);
5507 uint ea = EA_AX_PD_8();
5509 m68ki_write_8(ea, res);
5511 FLAG_N = NFLAG_8(res);
5513 FLAG_V = VFLAG_CLEAR;
5514 FLAG_C = CFLAG_CLEAR;
5518 M68KMAKE_OP(move, 8, pd7, .)
5520 uint res = M68KMAKE_GET_OPER_AY_8;
5521 uint ea = EA_A7_PD_8();
5523 m68ki_write_8(ea, res);
5525 FLAG_N = NFLAG_8(res);
5527 FLAG_V = VFLAG_CLEAR;
5528 FLAG_C = CFLAG_CLEAR;
5532 M68KMAKE_OP(move, 8, pd, .)
5534 uint res = M68KMAKE_GET_OPER_AY_8;
5535 uint ea = EA_AX_PD_8();
5537 m68ki_write_8(ea, res);
5539 FLAG_N = NFLAG_8(res);
5541 FLAG_V = VFLAG_CLEAR;
5542 FLAG_C = CFLAG_CLEAR;
5546 M68KMAKE_OP(move, 8, di, d)
5548 uint res = MASK_OUT_ABOVE_8(DY);
5549 uint ea = EA_AX_DI_8();
5551 m68ki_write_8(ea, res);
5553 FLAG_N = NFLAG_8(res);
5555 FLAG_V = VFLAG_CLEAR;
5556 FLAG_C = CFLAG_CLEAR;
5560 M68KMAKE_OP(move, 8, di, .)
5562 uint res = M68KMAKE_GET_OPER_AY_8;
5563 uint ea = EA_AX_DI_8();
5565 m68ki_write_8(ea, res);
5567 FLAG_N = NFLAG_8(res);
5569 FLAG_V = VFLAG_CLEAR;
5570 FLAG_C = CFLAG_CLEAR;
5574 M68KMAKE_OP(move, 8, ix, d)
5576 uint res = MASK_OUT_ABOVE_8(DY);
5577 uint ea = EA_AX_IX_8();
5579 m68ki_write_8(ea, res);
5581 FLAG_N = NFLAG_8(res);
5583 FLAG_V = VFLAG_CLEAR;
5584 FLAG_C = CFLAG_CLEAR;
5588 M68KMAKE_OP(move, 8, ix, .)
5590 uint res = M68KMAKE_GET_OPER_AY_8;
5591 uint ea = EA_AX_IX_8();
5593 m68ki_write_8(ea, res);
5595 FLAG_N = NFLAG_8(res);
5597 FLAG_V = VFLAG_CLEAR;
5598 FLAG_C = CFLAG_CLEAR;
5602 M68KMAKE_OP(move, 8, aw, d)
5604 uint res = MASK_OUT_ABOVE_8(DY);
5605 uint ea = EA_AW_8();
5607 m68ki_write_8(ea, res);
5609 FLAG_N = NFLAG_8(res);
5611 FLAG_V = VFLAG_CLEAR;
5612 FLAG_C = CFLAG_CLEAR;
5616 M68KMAKE_OP(move, 8, aw, .)
5618 uint res = M68KMAKE_GET_OPER_AY_8;
5619 uint ea = EA_AW_8();
5621 m68ki_write_8(ea, res);
5623 FLAG_N = NFLAG_8(res);
5625 FLAG_V = VFLAG_CLEAR;
5626 FLAG_C = CFLAG_CLEAR;
5630 M68KMAKE_OP(move, 8, al, d)
5632 uint res = MASK_OUT_ABOVE_8(DY);
5633 uint ea = EA_AL_8();
5635 m68ki_write_8(ea, res);
5637 FLAG_N = NFLAG_8(res);
5639 FLAG_V = VFLAG_CLEAR;
5640 FLAG_C = CFLAG_CLEAR;
5644 M68KMAKE_OP(move, 8, al, .)
5646 uint res = M68KMAKE_GET_OPER_AY_8;
5647 uint ea = EA_AL_8();
5649 m68ki_write_8(ea, res);
5651 FLAG_N = NFLAG_8(res);
5653 FLAG_V = VFLAG_CLEAR;
5654 FLAG_C = CFLAG_CLEAR;
5658 M68KMAKE_OP(move, 16, d, d)
5660 uint res = MASK_OUT_ABOVE_16(DY);
5663 *r_dst = MASK_OUT_BELOW_16(*r_dst) | res;
5665 FLAG_N = NFLAG_16(res);
5667 FLAG_V = VFLAG_CLEAR;
5668 FLAG_C = CFLAG_CLEAR;
5672 M68KMAKE_OP(move, 16, d, a)
5674 uint res = MASK_OUT_ABOVE_16(AY);
5677 *r_dst = MASK_OUT_BELOW_16(*r_dst) | res;
5679 FLAG_N = NFLAG_16(res);
5681 FLAG_V = VFLAG_CLEAR;
5682 FLAG_C = CFLAG_CLEAR;
5686 M68KMAKE_OP(move, 16, d, .)
5688 uint res = M68KMAKE_GET_OPER_AY_16;
5691 *r_dst = MASK_OUT_BELOW_16(*r_dst) | res;
5693 FLAG_N = NFLAG_16(res);
5695 FLAG_V = VFLAG_CLEAR;
5696 FLAG_C = CFLAG_CLEAR;
5700 M68KMAKE_OP(move, 16, ai, d)
5702 uint res = MASK_OUT_ABOVE_16(DY);
5703 uint ea = EA_AX_AI_16();
5705 m68ki_write_16(ea, res);
5707 FLAG_N = NFLAG_16(res);
5709 FLAG_V = VFLAG_CLEAR;
5710 FLAG_C = CFLAG_CLEAR;
5714 M68KMAKE_OP(move, 16, ai, a)
5716 uint res = MASK_OUT_ABOVE_16(AY);
5717 uint ea = EA_AX_AI_16();
5719 m68ki_write_16(ea, res);
5721 FLAG_N = NFLAG_16(res);
5723 FLAG_V = VFLAG_CLEAR;
5724 FLAG_C = CFLAG_CLEAR;
5728 M68KMAKE_OP(move, 16, ai, .)
5730 uint res = M68KMAKE_GET_OPER_AY_16;
5731 uint ea = EA_AX_AI_16();
5733 m68ki_write_16(ea, res);
5735 FLAG_N = NFLAG_16(res);
5737 FLAG_V = VFLAG_CLEAR;
5738 FLAG_C = CFLAG_CLEAR;
5742 M68KMAKE_OP(move, 16, pi, d)
5744 uint res = MASK_OUT_ABOVE_16(DY);
5745 uint ea = EA_AX_PI_16();
5747 m68ki_write_16(ea, res);
5749 FLAG_N = NFLAG_16(res);
5751 FLAG_V = VFLAG_CLEAR;
5752 FLAG_C = CFLAG_CLEAR;
5756 M68KMAKE_OP(move, 16, pi, a)
5758 uint res = MASK_OUT_ABOVE_16(AY);
5759 uint ea = EA_AX_PI_16();
5761 m68ki_write_16(ea, res);
5763 FLAG_N = NFLAG_16(res);
5765 FLAG_V = VFLAG_CLEAR;
5766 FLAG_C = CFLAG_CLEAR;
5770 M68KMAKE_OP(move, 16, pi, .)
5772 uint res = M68KMAKE_GET_OPER_AY_16;
5773 uint ea = EA_AX_PI_16();
5775 m68ki_write_16(ea, res);
5777 FLAG_N = NFLAG_16(res);
5779 FLAG_V = VFLAG_CLEAR;
5780 FLAG_C = CFLAG_CLEAR;
5784 M68KMAKE_OP(move, 16, pd, d)
5786 uint res = MASK_OUT_ABOVE_16(DY);
5787 uint ea = EA_AX_PD_16();
5789 m68ki_write_16(ea, res);
5791 FLAG_N = NFLAG_16(res);
5793 FLAG_V = VFLAG_CLEAR;
5794 FLAG_C = CFLAG_CLEAR;
5798 M68KMAKE_OP(move, 16, pd, a)
5800 uint res = MASK_OUT_ABOVE_16(AY);
5801 uint ea = EA_AX_PD_16();
5803 m68ki_write_16(ea, res);
5805 FLAG_N = NFLAG_16(res);
5807 FLAG_V = VFLAG_CLEAR;
5808 FLAG_C = CFLAG_CLEAR;
5812 M68KMAKE_OP(move, 16, pd, .)
5814 uint res = M68KMAKE_GET_OPER_AY_16;
5815 uint ea = EA_AX_PD_16();
5817 m68ki_write_16(ea, res);
5819 FLAG_N = NFLAG_16(res);
5821 FLAG_V = VFLAG_CLEAR;
5822 FLAG_C = CFLAG_CLEAR;
5826 M68KMAKE_OP(move, 16, di, d)
5828 uint res = MASK_OUT_ABOVE_16(DY);
5829 uint ea = EA_AX_DI_16();
5831 m68ki_write_16(ea, res);
5833 FLAG_N = NFLAG_16(res);
5835 FLAG_V = VFLAG_CLEAR;
5836 FLAG_C = CFLAG_CLEAR;
5840 M68KMAKE_OP(move, 16, di, a)
5842 uint res = MASK_OUT_ABOVE_16(AY);
5843 uint ea = EA_AX_DI_16();
5845 m68ki_write_16(ea, res);
5847 FLAG_N = NFLAG_16(res);
5849 FLAG_V = VFLAG_CLEAR;
5850 FLAG_C = CFLAG_CLEAR;
5854 M68KMAKE_OP(move, 16, di, .)
5856 uint res = M68KMAKE_GET_OPER_AY_16;
5857 uint ea = EA_AX_DI_16();
5859 m68ki_write_16(ea, res);
5861 FLAG_N = NFLAG_16(res);
5863 FLAG_V = VFLAG_CLEAR;
5864 FLAG_C = CFLAG_CLEAR;
5868 M68KMAKE_OP(move, 16, ix, d)
5870 uint res = MASK_OUT_ABOVE_16(DY);
5871 uint ea = EA_AX_IX_16();
5873 m68ki_write_16(ea, res);
5875 FLAG_N = NFLAG_16(res);
5877 FLAG_V = VFLAG_CLEAR;
5878 FLAG_C = CFLAG_CLEAR;
5882 M68KMAKE_OP(move, 16, ix, a)
5884 uint res = MASK_OUT_ABOVE_16(AY);
5885 uint ea = EA_AX_IX_16();
5887 m68ki_write_16(ea, res);
5889 FLAG_N = NFLAG_16(res);
5891 FLAG_V = VFLAG_CLEAR;
5892 FLAG_C = CFLAG_CLEAR;
5896 M68KMAKE_OP(move, 16, ix, .)
5898 uint res = M68KMAKE_GET_OPER_AY_16;
5899 uint ea = EA_AX_IX_16();
5901 m68ki_write_16(ea, res);
5903 FLAG_N = NFLAG_16(res);
5905 FLAG_V = VFLAG_CLEAR;
5906 FLAG_C = CFLAG_CLEAR;
5910 M68KMAKE_OP(move, 16, aw, d)
5912 uint res = MASK_OUT_ABOVE_16(DY);
5913 uint ea = EA_AW_16();
5915 m68ki_write_16(ea, res);
5917 FLAG_N = NFLAG_16(res);
5919 FLAG_V = VFLAG_CLEAR;
5920 FLAG_C = CFLAG_CLEAR;
5924 M68KMAKE_OP(move, 16, aw, a)
5926 uint res = MASK_OUT_ABOVE_16(AY);
5927 uint ea = EA_AW_16();
5929 m68ki_write_16(ea, res);
5931 FLAG_N = NFLAG_16(res);
5933 FLAG_V = VFLAG_CLEAR;
5934 FLAG_C = CFLAG_CLEAR;
5938 M68KMAKE_OP(move, 16, aw, .)
5940 uint res = M68KMAKE_GET_OPER_AY_16;
5941 uint ea = EA_AW_16();
5943 m68ki_write_16(ea, res);
5945 FLAG_N = NFLAG_16(res);
5947 FLAG_V = VFLAG_CLEAR;
5948 FLAG_C = CFLAG_CLEAR;
5952 M68KMAKE_OP(move, 16, al, d)
5954 uint res = MASK_OUT_ABOVE_16(DY);
5955 uint ea = EA_AL_16();
5957 m68ki_write_16(ea, res);
5959 FLAG_N = NFLAG_16(res);
5961 FLAG_V = VFLAG_CLEAR;
5962 FLAG_C = CFLAG_CLEAR;
5966 M68KMAKE_OP(move, 16, al, a)
5968 uint res = MASK_OUT_ABOVE_16(AY);
5969 uint ea = EA_AL_16();
5971 m68ki_write_16(ea, res);
5973 FLAG_N = NFLAG_16(res);
5975 FLAG_V = VFLAG_CLEAR;
5976 FLAG_C = CFLAG_CLEAR;
5980 M68KMAKE_OP(move, 16, al, .)
5982 uint res = M68KMAKE_GET_OPER_AY_16;
5983 uint ea = EA_AL_16();
5985 m68ki_write_16(ea, res);
5987 FLAG_N = NFLAG_16(res);
5989 FLAG_V = VFLAG_CLEAR;
5990 FLAG_C = CFLAG_CLEAR;
5994 M68KMAKE_OP(move, 32, d, d)
6001 FLAG_N = NFLAG_32(res);
6003 FLAG_V = VFLAG_CLEAR;
6004 FLAG_C = CFLAG_CLEAR;
6008 M68KMAKE_OP(move, 32, d, a)
6015 FLAG_N = NFLAG_32(res);
6017 FLAG_V = VFLAG_CLEAR;
6018 FLAG_C = CFLAG_CLEAR;
6022 M68KMAKE_OP(move, 32, d, .)
6024 uint res = M68KMAKE_GET_OPER_AY_32;
6029 FLAG_N = NFLAG_32(res);
6031 FLAG_V = VFLAG_CLEAR;
6032 FLAG_C = CFLAG_CLEAR;
6036 M68KMAKE_OP(move, 32, ai, d)
6039 uint ea = EA_AX_AI_32();
6041 m68ki_write_32(ea, res);
6043 FLAG_N = NFLAG_32(res);
6045 FLAG_V = VFLAG_CLEAR;
6046 FLAG_C = CFLAG_CLEAR;
6050 M68KMAKE_OP(move, 32, ai, a)
6053 uint ea = EA_AX_AI_32();
6055 m68ki_write_32(ea, res);
6057 FLAG_N = NFLAG_32(res);
6059 FLAG_V = VFLAG_CLEAR;
6060 FLAG_C = CFLAG_CLEAR;
6064 M68KMAKE_OP(move, 32, ai, .)
6066 uint res = M68KMAKE_GET_OPER_AY_32;
6067 uint ea = EA_AX_AI_32();
6069 m68ki_write_32(ea, res);
6071 FLAG_N = NFLAG_32(res);
6073 FLAG_V = VFLAG_CLEAR;
6074 FLAG_C = CFLAG_CLEAR;
6078 M68KMAKE_OP(move, 32, pi, d)
6081 uint ea = EA_AX_PI_32();
6083 m68ki_write_32(ea, res);
6085 FLAG_N = NFLAG_32(res);
6087 FLAG_V = VFLAG_CLEAR;
6088 FLAG_C = CFLAG_CLEAR;
6092 M68KMAKE_OP(move, 32, pi, a)
6095 uint ea = EA_AX_PI_32();
6097 m68ki_write_32(ea, res);
6099 FLAG_N = NFLAG_32(res);
6101 FLAG_V = VFLAG_CLEAR;
6102 FLAG_C = CFLAG_CLEAR;
6106 M68KMAKE_OP(move, 32, pi, .)
6108 uint res = M68KMAKE_GET_OPER_AY_32;
6109 uint ea = EA_AX_PI_32();
6111 m68ki_write_32(ea, res);
6113 FLAG_N = NFLAG_32(res);
6115 FLAG_V = VFLAG_CLEAR;
6116 FLAG_C = CFLAG_CLEAR;
6120 M68KMAKE_OP(move, 32, pd, d)
6123 uint ea = EA_AX_PD_32();
6125 m68ki_write_32(ea, res);
6127 FLAG_N = NFLAG_32(res);
6129 FLAG_V = VFLAG_CLEAR;
6130 FLAG_C = CFLAG_CLEAR;
6134 M68KMAKE_OP(move, 32, pd, a)
6137 uint ea = EA_AX_PD_32();
6139 m68ki_write_32(ea, res);
6141 FLAG_N = NFLAG_32(res);
6143 FLAG_V = VFLAG_CLEAR;
6144 FLAG_C = CFLAG_CLEAR;
6148 M68KMAKE_OP(move, 32, pd, .)
6150 uint res = M68KMAKE_GET_OPER_AY_32;
6151 uint ea = EA_AX_PD_32();
6153 m68ki_write_32(ea, res);
6155 FLAG_N = NFLAG_32(res);
6157 FLAG_V = VFLAG_CLEAR;
6158 FLAG_C = CFLAG_CLEAR;
6162 M68KMAKE_OP(move, 32, di, d)
6165 uint ea = EA_AX_DI_32();
6167 m68ki_write_32(ea, res);
6169 FLAG_N = NFLAG_32(res);
6171 FLAG_V = VFLAG_CLEAR;
6172 FLAG_C = CFLAG_CLEAR;
6176 M68KMAKE_OP(move, 32, di, a)
6179 uint ea = EA_AX_DI_32();
6181 m68ki_write_32(ea, res);
6183 FLAG_N = NFLAG_32(res);
6185 FLAG_V = VFLAG_CLEAR;
6186 FLAG_C = CFLAG_CLEAR;
6190 M68KMAKE_OP(move, 32, di, .)
6192 uint res = M68KMAKE_GET_OPER_AY_32;
6193 uint ea = EA_AX_DI_32();
6195 m68ki_write_32(ea, res);
6197 FLAG_N = NFLAG_32(res);
6199 FLAG_V = VFLAG_CLEAR;
6200 FLAG_C = CFLAG_CLEAR;
6204 M68KMAKE_OP(move, 32, ix, d)
6207 uint ea = EA_AX_IX_32();
6209 m68ki_write_32(ea, res);
6211 FLAG_N = NFLAG_32(res);
6213 FLAG_V = VFLAG_CLEAR;
6214 FLAG_C = CFLAG_CLEAR;
6218 M68KMAKE_OP(move, 32, ix, a)
6221 uint ea = EA_AX_IX_32();
6223 m68ki_write_32(ea, res);
6225 FLAG_N = NFLAG_32(res);
6227 FLAG_V = VFLAG_CLEAR;
6228 FLAG_C = CFLAG_CLEAR;
6232 M68KMAKE_OP(move, 32, ix, .)
6234 uint res = M68KMAKE_GET_OPER_AY_32;
6235 uint ea = EA_AX_IX_32();
6237 m68ki_write_32(ea, res);
6239 FLAG_N = NFLAG_32(res);
6241 FLAG_V = VFLAG_CLEAR;
6242 FLAG_C = CFLAG_CLEAR;
6246 M68KMAKE_OP(move, 32, aw, d)
6249 uint ea = EA_AW_32();
6251 m68ki_write_32(ea, res);
6253 FLAG_N = NFLAG_32(res);
6255 FLAG_V = VFLAG_CLEAR;
6256 FLAG_C = CFLAG_CLEAR;
6260 M68KMAKE_OP(move, 32, aw, a)
6263 uint ea = EA_AW_32();
6265 m68ki_write_32(ea, res);
6267 FLAG_N = NFLAG_32(res);
6269 FLAG_V = VFLAG_CLEAR;
6270 FLAG_C = CFLAG_CLEAR;
6274 M68KMAKE_OP(move, 32, aw, .)
6276 uint res = M68KMAKE_GET_OPER_AY_32;
6277 uint ea = EA_AW_32();
6279 m68ki_write_32(ea, res);
6281 FLAG_N = NFLAG_32(res);
6283 FLAG_V = VFLAG_CLEAR;
6284 FLAG_C = CFLAG_CLEAR;
6288 M68KMAKE_OP(move, 32, al, d)
6291 uint ea = EA_AL_32();
6293 m68ki_write_32(ea, res);
6295 FLAG_N = NFLAG_32(res);
6297 FLAG_V = VFLAG_CLEAR;
6298 FLAG_C = CFLAG_CLEAR;
6302 M68KMAKE_OP(move, 32, al, a)
6305 uint ea = EA_AL_32();
6307 m68ki_write_32(ea, res);
6309 FLAG_N = NFLAG_32(res);
6311 FLAG_V = VFLAG_CLEAR;
6312 FLAG_C = CFLAG_CLEAR;
6316 M68KMAKE_OP(move, 32, al, .)
6318 uint res = M68KMAKE_GET_OPER_AY_32;
6319 uint ea = EA_AL_32();
6321 m68ki_write_32(ea, res);
6323 FLAG_N = NFLAG_32(res);
6325 FLAG_V = VFLAG_CLEAR;
6326 FLAG_C = CFLAG_CLEAR;
6330 M68KMAKE_OP(movea, 16, ., d)
6332 AX = MAKE_INT_16(DY);
6336 M68KMAKE_OP(movea, 16, ., a)
6338 AX = MAKE_INT_16(AY);
6342 M68KMAKE_OP(movea, 16, ., .)
6344 AX = MAKE_INT_16(M68KMAKE_GET_OPER_AY_16);
6348 M68KMAKE_OP(movea, 32, ., d)
6354 M68KMAKE_OP(movea, 32, ., a)
6360 M68KMAKE_OP(movea, 32, ., .)
6362 AX = M68KMAKE_GET_OPER_AY_32;
6366 M68KMAKE_OP(move, 16, frc, d)
6368 if(CPU_TYPE_IS_010_PLUS(CPU_TYPE))
6370 DY = MASK_OUT_BELOW_16(DY) | m68ki_get_ccr();
6373 m68ki_exception_illegal();
6377 M68KMAKE_OP(move, 16, frc, .)
6379 if(CPU_TYPE_IS_010_PLUS(CPU_TYPE))
6381 m68ki_write_16(M68KMAKE_GET_EA_AY_16, m68ki_get_ccr());
6384 m68ki_exception_illegal();
6388 M68KMAKE_OP(move, 16, toc, d)
6394 M68KMAKE_OP(move, 16, toc, .)
6396 m68ki_set_ccr(M68KMAKE_GET_OPER_AY_16);
6400 M68KMAKE_OP(move, 16, frs, d)
6402 if(CPU_TYPE_IS_000(CPU_TYPE) || FLAG_S) /* NS990408 */
6404 DY = MASK_OUT_BELOW_16(DY) | m68ki_get_sr();
6407 m68ki_exception_privilege_violation();
6411 M68KMAKE_OP(move, 16, frs, .)
6413 if(CPU_TYPE_IS_000(CPU_TYPE) || FLAG_S) /* NS990408 */
6415 uint ea = M68KMAKE_GET_EA_AY_16;
6416 m68ki_write_16(ea, m68ki_get_sr());
6419 m68ki_exception_privilege_violation();
6423 M68KMAKE_OP(move, 16, tos, d)
6430 m68ki_exception_privilege_violation();
6434 M68KMAKE_OP(move, 16, tos, .)
6438 uint new_sr = M68KMAKE_GET_OPER_AY_16;
6439 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
6440 m68ki_set_sr(new_sr);
6443 m68ki_exception_privilege_violation();
6447 M68KMAKE_OP(move, 32, fru, .)
6454 m68ki_exception_privilege_violation();
6458 M68KMAKE_OP(move, 32, tou, .)
6462 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
6466 m68ki_exception_privilege_violation();
6470 M68KMAKE_OP(movec, 32, cr, .)
6472 if(CPU_TYPE_IS_010_PLUS(CPU_TYPE))
6476 uint word2 = OPER_I_16();
6478 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
6479 switch (word2 & 0xfff)
6481 case 0x000: /* SFC */
6482 REG_DA[(word2 >> 12) & 15] = REG_SFC;
6484 case 0x001: /* DFC */
6485 REG_DA[(word2 >> 12) & 15] = REG_DFC;
6487 case 0x002: /* CACR */
6488 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
6490 REG_DA[(word2 >> 12) & 15] = REG_CACR;
6494 case 0x800: /* USP */
6495 REG_DA[(word2 >> 12) & 15] = REG_USP;
6497 case 0x801: /* VBR */
6498 REG_DA[(word2 >> 12) & 15] = REG_VBR;
6500 case 0x802: /* CAAR */
6501 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
6503 REG_DA[(word2 >> 12) & 15] = REG_CAAR;
6506 m68ki_exception_illegal();
6508 case 0x803: /* MSP */
6509 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
6511 REG_DA[(word2 >> 12) & 15] = FLAG_M ? REG_SP : REG_MSP;
6514 m68ki_exception_illegal();
6516 case 0x804: /* ISP */
6517 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
6519 REG_DA[(word2 >> 12) & 15] = FLAG_M ? REG_ISP : REG_SP;
6522 m68ki_exception_illegal();
6525 m68ki_exception_illegal();
6529 m68ki_exception_privilege_violation();
6532 m68ki_exception_illegal();
6536 M68KMAKE_OP(movec, 32, rc, .)
6538 if(CPU_TYPE_IS_010_PLUS(CPU_TYPE))
6542 uint word2 = OPER_I_16();
6544 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
6545 switch (word2 & 0xfff)
6547 case 0x000: /* SFC */
6548 REG_SFC = REG_DA[(word2 >> 12) & 15] & 7;
6550 case 0x001: /* DFC */
6551 REG_DFC = REG_DA[(word2 >> 12) & 15] & 7;
6553 case 0x002: /* CACR */
6554 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
6556 REG_CACR = REG_DA[(word2 >> 12) & 15];
6559 m68ki_exception_illegal();
6561 case 0x800: /* USP */
6562 REG_USP = REG_DA[(word2 >> 12) & 15];
6564 case 0x801: /* VBR */
6565 REG_VBR = REG_DA[(word2 >> 12) & 15];
6567 case 0x802: /* CAAR */
6568 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
6570 REG_CAAR = REG_DA[(word2 >> 12) & 15];
6573 m68ki_exception_illegal();
6575 case 0x803: /* MSP */
6576 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
6578 /* we are in supervisor mode so just check for M flag */
6581 REG_MSP = REG_DA[(word2 >> 12) & 15];
6584 REG_SP = REG_DA[(word2 >> 12) & 15];
6587 m68ki_exception_illegal();
6589 case 0x804: /* ISP */
6590 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
6594 REG_SP = REG_DA[(word2 >> 12) & 15];
6597 REG_ISP = REG_DA[(word2 >> 12) & 15];
6600 m68ki_exception_illegal();
6603 m68ki_exception_illegal();
6607 m68ki_exception_privilege_violation();
6610 m68ki_exception_illegal();
6614 M68KMAKE_OP(movem, 16, re, pd)
6617 uint register_list = OPER_I_16();
6622 if(register_list & (1 << i))
6625 m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_DA[15-i]));
6630 USE_CYCLES(count<<CYC_MOVEM_W);
6634 M68KMAKE_OP(movem, 16, re, .)
6637 uint register_list = OPER_I_16();
6638 uint ea = M68KMAKE_GET_EA_AY_16;
6642 if(register_list & (1 << i))
6644 m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_DA[i]));
6649 USE_CYCLES(count<<CYC_MOVEM_W);
6653 M68KMAKE_OP(movem, 32, re, pd)
6656 uint register_list = OPER_I_16();
6661 if(register_list & (1 << i))
6664 m68ki_write_32(ea, REG_DA[15-i]);
6669 USE_CYCLES(count<<CYC_MOVEM_L);
6673 M68KMAKE_OP(movem, 32, re, .)
6676 uint register_list = OPER_I_16();
6677 uint ea = M68KMAKE_GET_EA_AY_32;
6681 if(register_list & (1 << i))
6683 m68ki_write_32(ea, REG_DA[i]);
6688 USE_CYCLES(count<<CYC_MOVEM_L);
6692 M68KMAKE_OP(movem, 16, er, pi)
6695 uint register_list = OPER_I_16();
6700 if(register_list & (1 << i))
6702 REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_16(ea)));
6708 USE_CYCLES(count<<CYC_MOVEM_W);
6712 M68KMAKE_OP(movem, 16, er, .)
6715 uint register_list = OPER_I_16();
6716 uint ea = M68KMAKE_GET_EA_AY_16;
6720 if(register_list & (1 << i))
6722 REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_16(ea)));
6727 USE_CYCLES(count<<CYC_MOVEM_W);
6731 M68KMAKE_OP(movem, 32, er, pi)
6734 uint register_list = OPER_I_16();
6739 if(register_list & (1 << i))
6741 REG_DA[i] = m68ki_read_32(ea);
6747 USE_CYCLES(count<<CYC_MOVEM_L);
6751 M68KMAKE_OP(movem, 32, er, .)
6754 uint register_list = OPER_I_16();
6755 uint ea = M68KMAKE_GET_EA_AY_32;
6759 if(register_list & (1 << i))
6761 REG_DA[i] = m68ki_read_32(ea);
6766 USE_CYCLES(count<<CYC_MOVEM_L);
6770 M68KMAKE_OP(movep, 16, re, .)
6772 uint ea = EA_AY_DI_16();
6775 m68ki_write_8(ea, MASK_OUT_ABOVE_8(src >> 8));
6776 m68ki_write_8(ea += 2, MASK_OUT_ABOVE_8(src));
6780 M68KMAKE_OP(movep, 32, re, .)
6782 uint ea = EA_AY_DI_32();
6785 m68ki_write_8(ea, MASK_OUT_ABOVE_8(src >> 24));
6786 m68ki_write_8(ea += 2, MASK_OUT_ABOVE_8(src >> 16));
6787 m68ki_write_8(ea += 2, MASK_OUT_ABOVE_8(src >> 8));
6788 m68ki_write_8(ea += 2, MASK_OUT_ABOVE_8(src));
6792 M68KMAKE_OP(movep, 16, er, .)
6794 uint ea = EA_AY_DI_16();
6797 *r_dst = MASK_OUT_BELOW_16(*r_dst) | ((m68ki_read_8(ea) << 8) + m68ki_read_8(ea + 2));
6801 M68KMAKE_OP(movep, 32, er, .)
6803 uint ea = EA_AY_DI_32();
6805 DX = (m68ki_read_8(ea) << 24) + (m68ki_read_8(ea + 2) << 16)
6806 + (m68ki_read_8(ea + 4) << 8) + m68ki_read_8(ea + 6);
6810 M68KMAKE_OP(moves, 8, ., .)
6812 if(CPU_TYPE_IS_010_PLUS(CPU_TYPE))
6816 uint word2 = OPER_I_16();
6817 uint ea = M68KMAKE_GET_EA_AY_8;
6819 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
6820 if(BIT_B(word2)) /* Register to memory */
6822 m68ki_write_8_fc(ea, REG_DFC, MASK_OUT_ABOVE_8(REG_DA[(word2 >> 12) & 15]));
6825 if(BIT_F(word2)) /* Memory to address register */
6827 REG_A[(word2 >> 12) & 7] = MAKE_INT_8(m68ki_read_8_fc(ea, REG_SFC));
6828 if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE))
6832 /* Memory to data register */
6833 REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_8(REG_D[(word2 >> 12) & 7]) | m68ki_read_8_fc(ea, REG_SFC);
6834 if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE))
6838 m68ki_exception_privilege_violation();
6841 m68ki_exception_illegal();
6845 M68KMAKE_OP(moves, 16, ., .)
6847 if(CPU_TYPE_IS_010_PLUS(CPU_TYPE))
6851 uint word2 = OPER_I_16();
6852 uint ea = M68KMAKE_GET_EA_AY_16;
6854 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
6855 if(BIT_B(word2)) /* Register to memory */
6857 m68ki_write_16_fc(ea, REG_DFC, MASK_OUT_ABOVE_16(REG_DA[(word2 >> 12) & 15]));
6860 if(BIT_F(word2)) /* Memory to address register */
6862 REG_A[(word2 >> 12) & 7] = MAKE_INT_16(m68ki_read_16_fc(ea, REG_SFC));
6863 if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE))
6867 /* Memory to data register */
6868 REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_16(REG_D[(word2 >> 12) & 7]) | m68ki_read_16_fc(ea, REG_SFC);
6869 if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE))
6873 m68ki_exception_privilege_violation();
6876 m68ki_exception_illegal();
6880 M68KMAKE_OP(moves, 32, ., .)
6882 if(CPU_TYPE_IS_010_PLUS(CPU_TYPE))
6886 uint word2 = OPER_I_16();
6887 uint ea = M68KMAKE_GET_EA_AY_32;
6889 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
6890 if(BIT_B(word2)) /* Register to memory */
6892 m68ki_write_32_fc(ea, REG_DFC, REG_DA[(word2 >> 12) & 15]);
6893 if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE))
6897 /* Memory to register */
6898 REG_DA[(word2 >> 12) & 15] = m68ki_read_32_fc(ea, REG_SFC);
6899 if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE))
6903 m68ki_exception_privilege_violation();
6906 m68ki_exception_illegal();
6910 M68KMAKE_OP(moveq, 32, ., .)
6912 uint res = DX = MAKE_INT_8(MASK_OUT_ABOVE_8(REG_IR));
6914 FLAG_N = NFLAG_32(res);
6916 FLAG_V = VFLAG_CLEAR;
6917 FLAG_C = CFLAG_CLEAR;
6921 M68KMAKE_OP(muls, 16, ., d)
6924 uint res = MASK_OUT_ABOVE_32(MAKE_INT_16(DY) * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst)));
6929 FLAG_N = NFLAG_32(res);
6930 FLAG_V = VFLAG_CLEAR;
6931 FLAG_C = CFLAG_CLEAR;
6935 M68KMAKE_OP(muls, 16, ., .)
6938 uint res = MASK_OUT_ABOVE_32(MAKE_INT_16(M68KMAKE_GET_OPER_AY_16) * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst)));
6943 FLAG_N = NFLAG_32(res);
6944 FLAG_V = VFLAG_CLEAR;
6945 FLAG_C = CFLAG_CLEAR;
6949 M68KMAKE_OP(mulu, 16, ., d)
6952 uint res = MASK_OUT_ABOVE_16(DY) * MASK_OUT_ABOVE_16(*r_dst);
6957 FLAG_N = NFLAG_32(res);
6958 FLAG_V = VFLAG_CLEAR;
6959 FLAG_C = CFLAG_CLEAR;
6963 M68KMAKE_OP(mulu, 16, ., .)
6966 uint res = M68KMAKE_GET_OPER_AY_16 * MASK_OUT_ABOVE_16(*r_dst);
6971 FLAG_N = NFLAG_32(res);
6972 FLAG_V = VFLAG_CLEAR;
6973 FLAG_C = CFLAG_CLEAR;
6977 M68KMAKE_OP(mull, 32, ., d)
6981 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
6983 uint word2 = OPER_I_16();
6985 uint64 dst = REG_D[(word2 >> 12) & 7];
6988 FLAG_C = CFLAG_CLEAR;
6990 if(BIT_B(word2)) /* signed */
6992 res = (sint64)((sint32)src) * (sint64)((sint32)dst);
6995 FLAG_Z = MASK_OUT_ABOVE_32(res);
6996 FLAG_N = NFLAG_32(res);
6997 FLAG_V = ((sint64)res != (sint32)res)<<7;
6998 REG_D[(word2 >> 12) & 7] = FLAG_Z;
7001 FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32);
7002 FLAG_N = NFLAG_64(res);
7003 FLAG_V = VFLAG_CLEAR;
7004 REG_D[word2 & 7] = (res >> 32);
7005 REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res);
7012 FLAG_Z = MASK_OUT_ABOVE_32(res);
7013 FLAG_N = NFLAG_32(res);
7014 FLAG_V = (res > 0xffffffff)<<7;
7015 REG_D[(word2 >> 12) & 7] = FLAG_Z;
7018 FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32);
7019 FLAG_N = NFLAG_64(res);
7020 FLAG_V = VFLAG_CLEAR;
7021 REG_D[word2 & 7] = (res >> 32);
7022 REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res);
7025 m68ki_exception_illegal();
7029 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
7031 uint word2 = OPER_I_16();
7033 uint dst = REG_D[(word2 >> 12) & 7];
7034 uint neg = GET_MSB_32(src ^ dst);
7046 FLAG_C = CFLAG_CLEAR;
7048 if(BIT_B(word2)) /* signed */
7051 src = (uint)MASK_OUT_ABOVE_32(-(sint)src);
7053 dst = (uint)MASK_OUT_ABOVE_32(-(sint)dst);
7056 src1 = MASK_OUT_ABOVE_16(src);
7058 dst1 = MASK_OUT_ABOVE_16(dst);
7067 lo = r1 + (MASK_OUT_ABOVE_16(r2)<<16) + (MASK_OUT_ABOVE_16(r3)<<16);
7068 hi = r4 + (r2>>16) + (r3>>16) + (((r1>>16) + MASK_OUT_ABOVE_16(r2) + MASK_OUT_ABOVE_16(r3)) >> 16);
7070 if(BIT_B(word2) && neg)
7072 hi = (uint)MASK_OUT_ABOVE_32((-(sint)hi) - (lo != 0));
7073 lo = (uint)MASK_OUT_ABOVE_32(-(sint)lo);
7078 REG_D[word2 & 7] = hi;
7079 REG_D[(word2 >> 12) & 7] = lo;
7080 FLAG_N = NFLAG_32(hi);
7082 FLAG_V = VFLAG_CLEAR;
7086 REG_D[(word2 >> 12) & 7] = lo;
7087 FLAG_N = NFLAG_32(lo);
7090 FLAG_V = (!((GET_MSB_32(lo) && hi == 0xffffffff) || (!GET_MSB_32(lo) && !hi)))<<7;
7092 FLAG_V = (hi != 0) << 7;
7095 m68ki_exception_illegal();
7101 M68KMAKE_OP(mull, 32, ., .)
7105 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
7107 uint word2 = OPER_I_16();
7108 uint64 src = M68KMAKE_GET_OPER_AY_32;
7109 uint64 dst = REG_D[(word2 >> 12) & 7];
7112 FLAG_C = CFLAG_CLEAR;
7114 if(BIT_B(word2)) /* signed */
7116 res = (sint64)((sint32)src) * (sint64)((sint32)dst);
7119 FLAG_Z = MASK_OUT_ABOVE_32(res);
7120 FLAG_N = NFLAG_32(res);
7121 FLAG_V = ((sint64)res != (sint32)res)<<7;
7122 REG_D[(word2 >> 12) & 7] = FLAG_Z;
7125 FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32);
7126 FLAG_N = NFLAG_64(res);
7127 FLAG_V = VFLAG_CLEAR;
7128 REG_D[word2 & 7] = (res >> 32);
7129 REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res);
7136 FLAG_Z = MASK_OUT_ABOVE_32(res);
7137 FLAG_N = NFLAG_32(res);
7138 FLAG_V = (res > 0xffffffff)<<7;
7139 REG_D[(word2 >> 12) & 7] = FLAG_Z;
7142 FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32);
7143 FLAG_N = NFLAG_64(res);
7144 FLAG_V = VFLAG_CLEAR;
7145 REG_D[word2 & 7] = (res >> 32);
7146 REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res);
7149 m68ki_exception_illegal();
7153 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
7155 uint word2 = OPER_I_16();
7156 uint src = M68KMAKE_GET_OPER_AY_32;
7157 uint dst = REG_D[(word2 >> 12) & 7];
7158 uint neg = GET_MSB_32(src ^ dst);
7170 FLAG_C = CFLAG_CLEAR;
7172 if(BIT_B(word2)) /* signed */
7175 src = (uint)MASK_OUT_ABOVE_32(-(sint)src);
7177 dst = (uint)MASK_OUT_ABOVE_32(-(sint)dst);
7180 src1 = MASK_OUT_ABOVE_16(src);
7182 dst1 = MASK_OUT_ABOVE_16(dst);
7191 lo = r1 + (MASK_OUT_ABOVE_16(r2)<<16) + (MASK_OUT_ABOVE_16(r3)<<16);
7192 hi = r4 + (r2>>16) + (r3>>16) + (((r1>>16) + MASK_OUT_ABOVE_16(r2) + MASK_OUT_ABOVE_16(r3)) >> 16);
7194 if(BIT_B(word2) && neg)
7196 hi = (uint)MASK_OUT_ABOVE_32((-(sint)hi) - (lo != 0));
7197 lo = (uint)MASK_OUT_ABOVE_32(-(sint)lo);
7202 REG_D[word2 & 7] = hi;
7203 REG_D[(word2 >> 12) & 7] = lo;
7204 FLAG_N = NFLAG_32(hi);
7206 FLAG_V = VFLAG_CLEAR;
7210 REG_D[(word2 >> 12) & 7] = lo;
7211 FLAG_N = NFLAG_32(lo);
7214 FLAG_V = (!((GET_MSB_32(lo) && hi == 0xffffffff) || (!GET_MSB_32(lo) && !hi)))<<7;
7216 FLAG_V = (hi != 0) << 7;
7219 m68ki_exception_illegal();
7225 M68KMAKE_OP(nbcd, 8, ., d)
7229 uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1());
7233 if((res & 0x0f) == 0xa)
7234 res = (res & 0xf0) + 0x10;
7236 res = MASK_OUT_ABOVE_8(res);
7238 *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;
7246 FLAG_C = CFLAG_CLEAR;
7247 FLAG_X = XFLAG_CLEAR;
7249 FLAG_N = NFLAG_8(res); /* officially undefined */
7253 M68KMAKE_OP(nbcd, 8, ., .)
7255 uint ea = M68KMAKE_GET_EA_AY_8;
7256 uint dst = m68ki_read_8(ea);
7257 uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1());
7261 if((res & 0x0f) == 0xa)
7262 res = (res & 0xf0) + 0x10;
7264 res = MASK_OUT_ABOVE_8(res);
7266 m68ki_write_8(ea, MASK_OUT_ABOVE_8(res));
7274 FLAG_C = CFLAG_CLEAR;
7275 FLAG_X = XFLAG_CLEAR;
7277 FLAG_N = NFLAG_8(res); /* officially undefined */
7281 M68KMAKE_OP(neg, 8, ., d)
7284 uint res = 0 - MASK_OUT_ABOVE_8(*r_dst);
7286 FLAG_N = NFLAG_8(res);
7287 FLAG_C = FLAG_X = CFLAG_8(res);
7288 FLAG_V = *r_dst & res;
7289 FLAG_Z = MASK_OUT_ABOVE_8(res);
7291 *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z;
7295 M68KMAKE_OP(neg, 8, ., .)
7297 uint ea = M68KMAKE_GET_EA_AY_8;
7298 uint src = m68ki_read_8(ea);
7301 FLAG_N = NFLAG_8(res);
7302 FLAG_C = FLAG_X = CFLAG_8(res);
7304 FLAG_Z = MASK_OUT_ABOVE_8(res);
7306 m68ki_write_8(ea, FLAG_Z);
7310 M68KMAKE_OP(neg, 16, ., d)
7313 uint res = 0 - MASK_OUT_ABOVE_16(*r_dst);
7315 FLAG_N = NFLAG_16(res);
7316 FLAG_C = FLAG_X = CFLAG_16(res);
7317 FLAG_V = (*r_dst & res)>>8;
7318 FLAG_Z = MASK_OUT_ABOVE_16(res);
7320 *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z;
7324 M68KMAKE_OP(neg, 16, ., .)
7326 uint ea = M68KMAKE_GET_EA_AY_16;
7327 uint src = m68ki_read_16(ea);
7330 FLAG_N = NFLAG_16(res);
7331 FLAG_C = FLAG_X = CFLAG_16(res);
7332 FLAG_V = (src & res)>>8;
7333 FLAG_Z = MASK_OUT_ABOVE_16(res);
7335 m68ki_write_16(ea, FLAG_Z);
7339 M68KMAKE_OP(neg, 32, ., d)
7342 uint res = 0 - *r_dst;
7344 FLAG_N = NFLAG_32(res);
7345 FLAG_C = FLAG_X = CFLAG_SUB_32(*r_dst, 0, res);
7346 FLAG_V = (*r_dst & res)>>24;
7347 FLAG_Z = MASK_OUT_ABOVE_32(res);
7353 M68KMAKE_OP(neg, 32, ., .)
7355 uint ea = M68KMAKE_GET_EA_AY_32;
7356 uint src = m68ki_read_32(ea);
7359 FLAG_N = NFLAG_32(res);
7360 FLAG_C = FLAG_X = CFLAG_SUB_32(src, 0, res);
7361 FLAG_V = (src & res)>>24;
7362 FLAG_Z = MASK_OUT_ABOVE_32(res);
7364 m68ki_write_32(ea, FLAG_Z);
7368 M68KMAKE_OP(negx, 8, ., d)
7371 uint res = 0 - MASK_OUT_ABOVE_8(*r_dst) - XFLAG_AS_1();
7373 FLAG_N = NFLAG_8(res);
7374 FLAG_X = FLAG_C = CFLAG_8(res);
7375 FLAG_V = *r_dst & res;
7377 res = MASK_OUT_ABOVE_8(res);
7380 *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;
7384 M68KMAKE_OP(negx, 8, ., .)
7386 uint ea = M68KMAKE_GET_EA_AY_8;
7387 uint src = m68ki_read_8(ea);
7388 uint res = 0 - src - XFLAG_AS_1();
7390 FLAG_N = NFLAG_8(res);
7391 FLAG_X = FLAG_C = CFLAG_8(res);
7394 res = MASK_OUT_ABOVE_8(res);
7397 m68ki_write_8(ea, res);
7401 M68KMAKE_OP(negx, 16, ., d)
7404 uint res = 0 - MASK_OUT_ABOVE_16(*r_dst) - XFLAG_AS_1();
7406 FLAG_N = NFLAG_16(res);
7407 FLAG_X = FLAG_C = CFLAG_16(res);
7408 FLAG_V = (*r_dst & res)>>8;
7410 res = MASK_OUT_ABOVE_16(res);
7413 *r_dst = MASK_OUT_BELOW_16(*r_dst) | res;
7417 M68KMAKE_OP(negx, 16, ., .)
7419 uint ea = M68KMAKE_GET_EA_AY_16;
7420 uint src = m68ki_read_16(ea);
7421 uint res = 0 - MASK_OUT_ABOVE_16(src) - XFLAG_AS_1();
7423 FLAG_N = NFLAG_16(res);
7424 FLAG_X = FLAG_C = CFLAG_16(res);
7425 FLAG_V = (src & res)>>8;
7427 res = MASK_OUT_ABOVE_16(res);
7430 m68ki_write_16(ea, res);
7434 M68KMAKE_OP(negx, 32, ., d)
7437 uint res = 0 - MASK_OUT_ABOVE_32(*r_dst) - XFLAG_AS_1();
7439 FLAG_N = NFLAG_32(res);
7440 FLAG_X = FLAG_C = CFLAG_SUB_32(*r_dst, 0, res);
7441 FLAG_V = (*r_dst & res)>>24;
7443 res = MASK_OUT_ABOVE_32(res);
7450 M68KMAKE_OP(negx, 32, ., .)
7452 uint ea = M68KMAKE_GET_EA_AY_32;
7453 uint src = m68ki_read_32(ea);
7454 uint res = 0 - MASK_OUT_ABOVE_32(src) - XFLAG_AS_1();
7456 FLAG_N = NFLAG_32(res);
7457 FLAG_X = FLAG_C = CFLAG_SUB_32(src, 0, res);
7458 FLAG_V = (src & res)>>24;
7460 res = MASK_OUT_ABOVE_32(res);
7463 m68ki_write_32(ea, res);
7467 M68KMAKE_OP(nop, 0, ., .)
7469 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
7473 M68KMAKE_OP(not, 8, ., d)
7476 uint res = MASK_OUT_ABOVE_8(~*r_dst);
7478 *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;
7480 FLAG_N = NFLAG_8(res);
7482 FLAG_C = CFLAG_CLEAR;
7483 FLAG_V = VFLAG_CLEAR;
7487 M68KMAKE_OP(not, 8, ., .)
7489 uint ea = M68KMAKE_GET_EA_AY_8;
7490 uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea));
7492 m68ki_write_8(ea, res);
7494 FLAG_N = NFLAG_8(res);
7496 FLAG_C = CFLAG_CLEAR;
7497 FLAG_V = VFLAG_CLEAR;
7501 M68KMAKE_OP(not, 16, ., d)
7504 uint res = MASK_OUT_ABOVE_16(~*r_dst);
7506 *r_dst = MASK_OUT_BELOW_16(*r_dst) | res;
7508 FLAG_N = NFLAG_16(res);
7510 FLAG_C = CFLAG_CLEAR;
7511 FLAG_V = VFLAG_CLEAR;
7515 M68KMAKE_OP(not, 16, ., .)
7517 uint ea = M68KMAKE_GET_EA_AY_16;
7518 uint res = MASK_OUT_ABOVE_16(~m68ki_read_16(ea));
7520 m68ki_write_16(ea, res);
7522 FLAG_N = NFLAG_16(res);
7524 FLAG_C = CFLAG_CLEAR;
7525 FLAG_V = VFLAG_CLEAR;
7529 M68KMAKE_OP(not, 32, ., d)
7532 uint res = *r_dst = MASK_OUT_ABOVE_32(~*r_dst);
7534 FLAG_N = NFLAG_32(res);
7536 FLAG_C = CFLAG_CLEAR;
7537 FLAG_V = VFLAG_CLEAR;
7541 M68KMAKE_OP(not, 32, ., .)
7543 uint ea = M68KMAKE_GET_EA_AY_32;
7544 uint res = MASK_OUT_ABOVE_32(~m68ki_read_32(ea));
7546 m68ki_write_32(ea, res);
7548 FLAG_N = NFLAG_32(res);
7550 FLAG_C = CFLAG_CLEAR;
7551 FLAG_V = VFLAG_CLEAR;
7555 M68KMAKE_OP(or, 8, er, d)
7557 uint res = MASK_OUT_ABOVE_8((DX |= MASK_OUT_ABOVE_8(DY)));
7559 FLAG_N = NFLAG_8(res);
7561 FLAG_C = CFLAG_CLEAR;
7562 FLAG_V = VFLAG_CLEAR;
7566 M68KMAKE_OP(or, 8, er, .)
7568 uint res = MASK_OUT_ABOVE_8((DX |= M68KMAKE_GET_OPER_AY_8));
7570 FLAG_N = NFLAG_8(res);
7572 FLAG_C = CFLAG_CLEAR;
7573 FLAG_V = VFLAG_CLEAR;
7577 M68KMAKE_OP(or, 16, er, d)
7579 uint res = MASK_OUT_ABOVE_16((DX |= MASK_OUT_ABOVE_16(DY)));
7581 FLAG_N = NFLAG_16(res);
7583 FLAG_C = CFLAG_CLEAR;
7584 FLAG_V = VFLAG_CLEAR;
7588 M68KMAKE_OP(or, 16, er, .)
7590 uint res = MASK_OUT_ABOVE_16((DX |= M68KMAKE_GET_OPER_AY_16));
7592 FLAG_N = NFLAG_16(res);
7594 FLAG_C = CFLAG_CLEAR;
7595 FLAG_V = VFLAG_CLEAR;
7599 M68KMAKE_OP(or, 32, er, d)
7601 uint res = DX |= DY;
7603 FLAG_N = NFLAG_32(res);
7605 FLAG_C = CFLAG_CLEAR;
7606 FLAG_V = VFLAG_CLEAR;
7610 M68KMAKE_OP(or, 32, er, .)
7612 uint res = DX |= M68KMAKE_GET_OPER_AY_32;
7614 FLAG_N = NFLAG_32(res);
7616 FLAG_C = CFLAG_CLEAR;
7617 FLAG_V = VFLAG_CLEAR;
7621 M68KMAKE_OP(or, 8, re, .)
7623 uint ea = M68KMAKE_GET_EA_AY_8;
7624 uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea));
7626 m68ki_write_8(ea, res);
7628 FLAG_N = NFLAG_8(res);
7630 FLAG_C = CFLAG_CLEAR;
7631 FLAG_V = VFLAG_CLEAR;
7635 M68KMAKE_OP(or, 16, re, .)
7637 uint ea = M68KMAKE_GET_EA_AY_16;
7638 uint res = MASK_OUT_ABOVE_16(DX | m68ki_read_16(ea));
7640 m68ki_write_16(ea, res);
7642 FLAG_N = NFLAG_16(res);
7644 FLAG_C = CFLAG_CLEAR;
7645 FLAG_V = VFLAG_CLEAR;
7649 M68KMAKE_OP(or, 32, re, .)
7651 uint ea = M68KMAKE_GET_EA_AY_32;
7652 uint res = DX | m68ki_read_32(ea);
7654 m68ki_write_32(ea, res);
7656 FLAG_N = NFLAG_32(res);
7658 FLAG_C = CFLAG_CLEAR;
7659 FLAG_V = VFLAG_CLEAR;
7663 M68KMAKE_OP(ori, 8, ., d)
7665 uint res = MASK_OUT_ABOVE_8((DY |= OPER_I_8()));
7667 FLAG_N = NFLAG_8(res);
7669 FLAG_C = CFLAG_CLEAR;
7670 FLAG_V = VFLAG_CLEAR;
7674 M68KMAKE_OP(ori, 8, ., .)
7676 uint src = OPER_I_8();
7677 uint ea = M68KMAKE_GET_EA_AY_8;
7678 uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea));
7680 m68ki_write_8(ea, res);
7682 FLAG_N = NFLAG_8(res);
7684 FLAG_C = CFLAG_CLEAR;
7685 FLAG_V = VFLAG_CLEAR;
7689 M68KMAKE_OP(ori, 16, ., d)
7691 uint res = MASK_OUT_ABOVE_16(DY |= OPER_I_16());
7693 FLAG_N = NFLAG_16(res);
7695 FLAG_C = CFLAG_CLEAR;
7696 FLAG_V = VFLAG_CLEAR;
7700 M68KMAKE_OP(ori, 16, ., .)
7702 uint src = OPER_I_16();
7703 uint ea = M68KMAKE_GET_EA_AY_16;
7704 uint res = MASK_OUT_ABOVE_16(src | m68ki_read_16(ea));
7706 m68ki_write_16(ea, res);
7708 FLAG_N = NFLAG_16(res);
7710 FLAG_C = CFLAG_CLEAR;
7711 FLAG_V = VFLAG_CLEAR;
7715 M68KMAKE_OP(ori, 32, ., d)
7717 uint res = DY |= OPER_I_32();
7719 FLAG_N = NFLAG_32(res);
7721 FLAG_C = CFLAG_CLEAR;
7722 FLAG_V = VFLAG_CLEAR;
7726 M68KMAKE_OP(ori, 32, ., .)
7728 uint src = OPER_I_32();
7729 uint ea = M68KMAKE_GET_EA_AY_32;
7730 uint res = src | m68ki_read_32(ea);
7732 m68ki_write_32(ea, res);
7734 FLAG_N = NFLAG_32(res);
7736 FLAG_C = CFLAG_CLEAR;
7737 FLAG_V = VFLAG_CLEAR;
7741 M68KMAKE_OP(ori, 16, toc, .)
7743 m68ki_set_ccr(m68ki_get_ccr() | OPER_I_16());
7747 M68KMAKE_OP(ori, 16, tos, .)
7751 uint src = OPER_I_16();
7752 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
7753 m68ki_set_sr(m68ki_get_sr() | src);
7756 m68ki_exception_privilege_violation();
7760 M68KMAKE_OP(pack, 16, rr, .)
7762 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
7764 /* Note: DX and DY are reversed in Motorola's docs */
7765 uint src = DY + OPER_I_16();
7768 *r_dst = MASK_OUT_BELOW_8(*r_dst) | ((src >> 4) & 0x00f0) | (src & 0x000f);
7771 m68ki_exception_illegal();
7775 M68KMAKE_OP(pack, 16, mm, ax7)
7777 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
7779 /* Note: AX and AY are reversed in Motorola's docs */
7780 uint ea_src = EA_AY_PD_8();
7781 uint src = m68ki_read_8(ea_src);
7782 ea_src = EA_AY_PD_8();
7783 src = ((src << 8) | m68ki_read_8(ea_src)) + OPER_I_16();
7785 m68ki_write_8(EA_A7_PD_8(), ((src >> 4) & 0x00f0) | (src & 0x000f));
7788 m68ki_exception_illegal();
7792 M68KMAKE_OP(pack, 16, mm, ay7)
7794 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
7796 /* Note: AX and AY are reversed in Motorola's docs */
7797 uint ea_src = EA_A7_PD_8();
7798 uint src = m68ki_read_8(ea_src);
7799 ea_src = EA_A7_PD_8();
7800 src = ((src << 8) | m68ki_read_8(ea_src)) + OPER_I_16();
7802 m68ki_write_8(EA_AX_PD_8(), ((src >> 4) & 0x00f0) | (src & 0x000f));
7805 m68ki_exception_illegal();
7809 M68KMAKE_OP(pack, 16, mm, axy7)
7811 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
7813 uint ea_src = EA_A7_PD_8();
7814 uint src = m68ki_read_8(ea_src);
7815 ea_src = EA_A7_PD_8();
7816 src = ((src << 8) | m68ki_read_8(ea_src)) + OPER_I_16();
7818 m68ki_write_8(EA_A7_PD_8(), ((src >> 4) & 0x00f0) | (src & 0x000f));
7821 m68ki_exception_illegal();
7825 M68KMAKE_OP(pack, 16, mm, .)
7827 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
7829 /* Note: AX and AY are reversed in Motorola's docs */
7830 uint ea_src = EA_AY_PD_8();
7831 uint src = m68ki_read_8(ea_src);
7832 ea_src = EA_AY_PD_8();
7833 src = ((src << 8) | m68ki_read_8(ea_src)) + OPER_I_16();
7835 m68ki_write_8(EA_AX_PD_8(), ((src >> 4) & 0x00f0) | (src & 0x000f));
7838 m68ki_exception_illegal();
7842 M68KMAKE_OP(pea, 32, ., .)
7844 uint ea = M68KMAKE_GET_EA_AY_32;
7850 M68KMAKE_OP(reset, 0, ., .)
7854 m68ki_output_reset(); /* auto-disable (see m68kcpu.h) */
7855 USE_CYCLES(CYC_RESET);
7858 m68ki_exception_privilege_violation();
7862 M68KMAKE_OP(ror, 8, s, .)
7865 uint orig_shift = (((REG_IR >> 9) - 1) & 7) + 1;
7866 uint shift = orig_shift & 7;
7867 uint src = MASK_OUT_ABOVE_8(*r_dst);
7868 uint res = ROR_8(src, shift);
7870 *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;
7872 FLAG_N = NFLAG_8(res);
7874 FLAG_C = src << (9-orig_shift);
7875 FLAG_V = VFLAG_CLEAR;
7879 M68KMAKE_OP(ror, 16, s, .)
7882 uint shift = (((REG_IR >> 9) - 1) & 7) + 1;
7883 uint src = MASK_OUT_ABOVE_16(*r_dst);
7884 uint res = ROR_16(src, shift);
7886 *r_dst = MASK_OUT_BELOW_16(*r_dst) | res;
7888 FLAG_N = NFLAG_16(res);
7890 FLAG_C = src << (9-shift);
7891 FLAG_V = VFLAG_CLEAR;
7895 M68KMAKE_OP(ror, 32, s, .)
7898 uint shift = (((REG_IR >> 9) - 1) & 7) + 1;
7899 uint64 src = *r_dst;
7900 uint res = ROR_32(src, shift);
7904 FLAG_N = NFLAG_32(res);
7906 FLAG_C = src << (9-shift);
7907 FLAG_V = VFLAG_CLEAR;
7911 M68KMAKE_OP(ror, 8, r, .)
7914 uint orig_shift = DX & 0x3f;
7915 uint shift = orig_shift & 7;
7916 uint src = MASK_OUT_ABOVE_8(*r_dst);
7917 uint res = ROR_8(src, shift);
7921 USE_CYCLES(orig_shift<<CYC_SHIFT);
7923 *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;
7924 FLAG_C = src << (8-((shift-1)&7));
7925 FLAG_N = NFLAG_8(res);
7927 FLAG_V = VFLAG_CLEAR;
7931 FLAG_C = CFLAG_CLEAR;
7932 FLAG_N = NFLAG_8(src);
7934 FLAG_V = VFLAG_CLEAR;
7938 M68KMAKE_OP(ror, 16, r, .)
7941 uint orig_shift = DX & 0x3f;
7942 uint shift = orig_shift & 15;
7943 uint src = MASK_OUT_ABOVE_16(*r_dst);
7944 uint res = ROR_16(src, shift);
7948 USE_CYCLES(orig_shift<<CYC_SHIFT);
7950 *r_dst = MASK_OUT_BELOW_16(*r_dst) | res;
7951 FLAG_C = (src >> ((shift - 1) & 15)) << 8;
7952 FLAG_N = NFLAG_16(res);
7954 FLAG_V = VFLAG_CLEAR;
7958 FLAG_C = CFLAG_CLEAR;
7959 FLAG_N = NFLAG_16(src);
7961 FLAG_V = VFLAG_CLEAR;
7965 M68KMAKE_OP(ror, 32, r, .)
7968 uint orig_shift = DX & 0x3f;
7969 uint shift = orig_shift & 31;
7970 uint64 src = *r_dst;
7971 uint res = ROR_32(src, shift);
7975 USE_CYCLES(orig_shift<<CYC_SHIFT);
7978 FLAG_C = (src >> ((shift - 1) & 31)) << 8;
7979 FLAG_N = NFLAG_32(res);
7981 FLAG_V = VFLAG_CLEAR;
7985 FLAG_C = CFLAG_CLEAR;
7986 FLAG_N = NFLAG_32(src);
7988 FLAG_V = VFLAG_CLEAR;
7992 M68KMAKE_OP(ror, 16, ., .)
7994 uint ea = M68KMAKE_GET_EA_AY_16;
7995 uint src = m68ki_read_16(ea);
7996 uint res = ROR_16(src, 1);
7998 m68ki_write_16(ea, res);
8000 FLAG_N = NFLAG_16(res);
8003 FLAG_V = VFLAG_CLEAR;
8007 M68KMAKE_OP(rol, 8, s, .)
8010 uint orig_shift = (((REG_IR >> 9) - 1) & 7) + 1;
8011 uint shift = orig_shift & 7;
8012 uint src = MASK_OUT_ABOVE_8(*r_dst);
8013 uint res = ROL_8(src, shift);
8015 *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;
8017 FLAG_N = NFLAG_8(res);
8019 FLAG_C = src << orig_shift;
8020 FLAG_V = VFLAG_CLEAR;
8024 M68KMAKE_OP(rol, 16, s, .)
8027 uint shift = (((REG_IR >> 9) - 1) & 7) + 1;
8028 uint src = MASK_OUT_ABOVE_16(*r_dst);
8029 uint res = ROL_16(src, shift);
8031 *r_dst = MASK_OUT_BELOW_16(*r_dst) | res;
8033 FLAG_N = NFLAG_16(res);
8035 FLAG_C = src >> (8-shift);
8036 FLAG_V = VFLAG_CLEAR;
8040 M68KMAKE_OP(rol, 32, s, .)
8043 uint shift = (((REG_IR >> 9) - 1) & 7) + 1;
8044 uint64 src = *r_dst;
8045 uint res = ROL_32(src, shift);
8049 FLAG_N = NFLAG_32(res);
8051 FLAG_C = src >> (24-shift);
8052 FLAG_V = VFLAG_CLEAR;
8056 M68KMAKE_OP(rol, 8, r, .)
8059 uint orig_shift = DX & 0x3f;
8060 uint shift = orig_shift & 7;
8061 uint src = MASK_OUT_ABOVE_8(*r_dst);
8062 uint res = ROL_8(src, shift);
8066 USE_CYCLES(orig_shift<<CYC_SHIFT);
8070 *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;
8071 FLAG_C = src << shift;
8072 FLAG_N = NFLAG_8(res);
8074 FLAG_V = VFLAG_CLEAR;
8077 FLAG_C = (src & 1)<<8;
8078 FLAG_N = NFLAG_8(src);
8080 FLAG_V = VFLAG_CLEAR;
8084 FLAG_C = CFLAG_CLEAR;
8085 FLAG_N = NFLAG_8(src);
8087 FLAG_V = VFLAG_CLEAR;
8091 M68KMAKE_OP(rol, 16, r, .)
8094 uint orig_shift = DX & 0x3f;
8095 uint shift = orig_shift & 15;
8096 uint src = MASK_OUT_ABOVE_16(*r_dst);
8097 uint res = MASK_OUT_ABOVE_16(ROL_16(src, shift));
8101 USE_CYCLES(orig_shift<<CYC_SHIFT);
8105 *r_dst = MASK_OUT_BELOW_16(*r_dst) | res;
8106 FLAG_C = (src << shift) >> 8;
8107 FLAG_N = NFLAG_16(res);
8109 FLAG_V = VFLAG_CLEAR;
8112 FLAG_C = (src & 1)<<8;
8113 FLAG_N = NFLAG_16(src);
8115 FLAG_V = VFLAG_CLEAR;
8119 FLAG_C = CFLAG_CLEAR;
8120 FLAG_N = NFLAG_16(src);
8122 FLAG_V = VFLAG_CLEAR;
8126 M68KMAKE_OP(rol, 32, r, .)
8129 uint orig_shift = DX & 0x3f;
8130 uint shift = orig_shift & 31;
8131 uint64 src = *r_dst;
8132 uint res = ROL_32(src, shift);
8136 USE_CYCLES(orig_shift<<CYC_SHIFT);
8140 FLAG_C = (src >> (32 - shift)) << 8;
8141 FLAG_N = NFLAG_32(res);
8143 FLAG_V = VFLAG_CLEAR;
8147 FLAG_C = CFLAG_CLEAR;
8148 FLAG_N = NFLAG_32(src);
8150 FLAG_V = VFLAG_CLEAR;
8154 M68KMAKE_OP(rol, 16, ., .)
8156 uint ea = M68KMAKE_GET_EA_AY_16;
8157 uint src = m68ki_read_16(ea);
8158 uint res = MASK_OUT_ABOVE_16(ROL_16(src, 1));
8160 m68ki_write_16(ea, res);
8162 FLAG_N = NFLAG_16(res);
8165 FLAG_V = VFLAG_CLEAR;
8169 M68KMAKE_OP(roxr, 8, s, .)
8172 uint shift = (((REG_IR >> 9) - 1) & 7) + 1;
8173 uint src = MASK_OUT_ABOVE_8(*r_dst);
8174 uint res = ROR_9(src | (XFLAG_AS_1() << 8), shift);
8176 FLAG_C = FLAG_X = res;
8177 res = MASK_OUT_ABOVE_8(res);
8179 *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;
8181 FLAG_N = NFLAG_8(res);
8183 FLAG_V = VFLAG_CLEAR;
8187 M68KMAKE_OP(roxr, 16, s, .)
8190 uint shift = (((REG_IR >> 9) - 1) & 7) + 1;
8191 uint src = MASK_OUT_ABOVE_16(*r_dst);
8192 uint res = ROR_17(src | (XFLAG_AS_1() << 16), shift);
8194 FLAG_C = FLAG_X = res >> 8;
8195 res = MASK_OUT_ABOVE_16(res);
8197 *r_dst = MASK_OUT_BELOW_16(*r_dst) | res;
8199 FLAG_N = NFLAG_16(res);
8201 FLAG_V = VFLAG_CLEAR;
8205 M68KMAKE_OP(roxr, 32, s, .)
8210 uint shift = (((REG_IR >> 9) - 1) & 7) + 1;
8211 uint64 src = *r_dst;
8212 uint64 res = src | (((uint64)XFLAG_AS_1()) << 32);
8214 res = ROR_33_64(res, shift);
8216 FLAG_C = FLAG_X = res >> 24;
8217 res = MASK_OUT_ABOVE_32(res);
8221 FLAG_N = NFLAG_32(res);
8223 FLAG_V = VFLAG_CLEAR;
8228 uint shift = (((REG_IR >> 9) - 1) & 7) + 1;
8230 uint res = MASK_OUT_ABOVE_32((ROR_33(src, shift) & ~(1 << (32 - shift))) | (XFLAG_AS_1() << (32 - shift)));
8231 uint new_x_flag = src & (1 << (shift - 1));
8235 FLAG_C = FLAG_X = (new_x_flag != 0)<<8;
8236 FLAG_N = NFLAG_32(res);
8238 FLAG_V = VFLAG_CLEAR;
8244 M68KMAKE_OP(roxr, 8, r, .)
8247 uint orig_shift = DX & 0x3f;
8251 uint shift = orig_shift % 9;
8252 uint src = MASK_OUT_ABOVE_8(*r_dst);
8253 uint res = ROR_9(src | (XFLAG_AS_1() << 8), shift);
8255 USE_CYCLES(orig_shift<<CYC_SHIFT);
8257 FLAG_C = FLAG_X = res;
8258 res = MASK_OUT_ABOVE_8(res);
8260 *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;
8261 FLAG_N = NFLAG_8(res);
8263 FLAG_V = VFLAG_CLEAR;
8268 FLAG_N = NFLAG_8(*r_dst);
8269 FLAG_Z = MASK_OUT_ABOVE_8(*r_dst);
8270 FLAG_V = VFLAG_CLEAR;
8274 M68KMAKE_OP(roxr, 16, r, .)
8277 uint orig_shift = DX & 0x3f;
8281 uint shift = orig_shift % 17;
8282 uint src = MASK_OUT_ABOVE_16(*r_dst);
8283 uint res = ROR_17(src | (XFLAG_AS_1() << 16), shift);
8285 USE_CYCLES(orig_shift<<CYC_SHIFT);
8287 FLAG_C = FLAG_X = res >> 8;
8288 res = MASK_OUT_ABOVE_16(res);
8290 *r_dst = MASK_OUT_BELOW_16(*r_dst) | res;
8291 FLAG_N = NFLAG_16(res);
8293 FLAG_V = VFLAG_CLEAR;
8298 FLAG_N = NFLAG_16(*r_dst);
8299 FLAG_Z = MASK_OUT_ABOVE_16(*r_dst);
8300 FLAG_V = VFLAG_CLEAR;
8304 M68KMAKE_OP(roxr, 32, r, .)
8309 uint orig_shift = DX & 0x3f;
8313 uint shift = orig_shift % 33;
8314 uint64 src = *r_dst;
8315 uint64 res = src | (((uint64)XFLAG_AS_1()) << 32);
8317 res = ROR_33_64(res, shift);
8319 USE_CYCLES(orig_shift<<CYC_SHIFT);
8321 FLAG_C = FLAG_X = res >> 24;
8322 res = MASK_OUT_ABOVE_32(res);
8325 FLAG_N = NFLAG_32(res);
8327 FLAG_V = VFLAG_CLEAR;
8332 FLAG_N = NFLAG_32(*r_dst);
8334 FLAG_V = VFLAG_CLEAR;
8339 uint orig_shift = DX & 0x3f;
8340 uint shift = orig_shift % 33;
8342 uint res = MASK_OUT_ABOVE_32((ROR_33(src, shift) & ~(1 << (32 - shift))) | (XFLAG_AS_1() << (32 - shift)));
8343 uint new_x_flag = src & (1 << (shift - 1));
8346 USE_CYCLES(orig_shift<<CYC_SHIFT);
8351 FLAG_X = (new_x_flag != 0)<<8;
8356 FLAG_N = NFLAG_32(res);
8358 FLAG_V = VFLAG_CLEAR;
8364 M68KMAKE_OP(roxr, 16, ., .)
8366 uint ea = M68KMAKE_GET_EA_AY_16;
8367 uint src = m68ki_read_16(ea);
8368 uint res = ROR_17(src | (XFLAG_AS_1() << 16), 1);
8370 FLAG_C = FLAG_X = res >> 8;
8371 res = MASK_OUT_ABOVE_16(res);
8373 m68ki_write_16(ea, res);
8375 FLAG_N = NFLAG_16(res);
8377 FLAG_V = VFLAG_CLEAR;
8381 M68KMAKE_OP(roxl, 8, s, .)
8384 uint shift = (((REG_IR >> 9) - 1) & 7) + 1;
8385 uint src = MASK_OUT_ABOVE_8(*r_dst);
8386 uint res = ROL_9(src | (XFLAG_AS_1() << 8), shift);
8388 FLAG_C = FLAG_X = res;
8389 res = MASK_OUT_ABOVE_8(res);
8391 *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;
8393 FLAG_N = NFLAG_8(res);
8395 FLAG_V = VFLAG_CLEAR;
8399 M68KMAKE_OP(roxl, 16, s, .)
8402 uint shift = (((REG_IR >> 9) - 1) & 7) + 1;
8403 uint src = MASK_OUT_ABOVE_16(*r_dst);
8404 uint res = ROL_17(src | (XFLAG_AS_1() << 16), shift);
8406 FLAG_C = FLAG_X = res >> 8;
8407 res = MASK_OUT_ABOVE_16(res);
8409 *r_dst = MASK_OUT_BELOW_16(*r_dst) | res;
8411 FLAG_N = NFLAG_16(res);
8413 FLAG_V = VFLAG_CLEAR;
8417 M68KMAKE_OP(roxl, 32, s, .)
8422 uint shift = (((REG_IR >> 9) - 1) & 7) + 1;
8423 uint64 src = *r_dst;
8424 uint64 res = src | (((uint64)XFLAG_AS_1()) << 32);
8426 res = ROL_33_64(res, shift);
8428 FLAG_C = FLAG_X = res >> 24;
8429 res = MASK_OUT_ABOVE_32(res);
8433 FLAG_N = NFLAG_32(res);
8435 FLAG_V = VFLAG_CLEAR;
8440 uint shift = (((REG_IR >> 9) - 1) & 7) + 1;
8442 uint res = MASK_OUT_ABOVE_32((ROL_33(src, shift) & ~(1 << (shift - 1))) | (XFLAG_AS_1() << (shift - 1)));
8443 uint new_x_flag = src & (1 << (32 - shift));
8447 FLAG_C = FLAG_X = (new_x_flag != 0)<<8;
8448 FLAG_N = NFLAG_32(res);
8450 FLAG_V = VFLAG_CLEAR;
8456 M68KMAKE_OP(roxl, 8, r, .)
8459 uint orig_shift = DX & 0x3f;
8464 uint shift = orig_shift % 9;
8465 uint src = MASK_OUT_ABOVE_8(*r_dst);
8466 uint res = ROL_9(src | (XFLAG_AS_1() << 8), shift);
8468 USE_CYCLES(orig_shift<<CYC_SHIFT);
8470 FLAG_C = FLAG_X = res;
8471 res = MASK_OUT_ABOVE_8(res);
8473 *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;
8474 FLAG_N = NFLAG_8(res);
8476 FLAG_V = VFLAG_CLEAR;
8481 FLAG_N = NFLAG_8(*r_dst);
8482 FLAG_Z = MASK_OUT_ABOVE_8(*r_dst);
8483 FLAG_V = VFLAG_CLEAR;
8487 M68KMAKE_OP(roxl, 16, r, .)
8490 uint orig_shift = DX & 0x3f;
8494 uint shift = orig_shift % 17;
8495 uint src = MASK_OUT_ABOVE_16(*r_dst);
8496 uint res = ROL_17(src | (XFLAG_AS_1() << 16), shift);
8498 USE_CYCLES(orig_shift<<CYC_SHIFT);
8500 FLAG_C = FLAG_X = res >> 8;
8501 res = MASK_OUT_ABOVE_16(res);
8503 *r_dst = MASK_OUT_BELOW_16(*r_dst) | res;
8504 FLAG_N = NFLAG_16(res);
8506 FLAG_V = VFLAG_CLEAR;
8511 FLAG_N = NFLAG_16(*r_dst);
8512 FLAG_Z = MASK_OUT_ABOVE_16(*r_dst);
8513 FLAG_V = VFLAG_CLEAR;
8517 M68KMAKE_OP(roxl, 32, r, .)
8522 uint orig_shift = DX & 0x3f;
8526 uint shift = orig_shift % 33;
8527 uint64 src = *r_dst;
8528 uint64 res = src | (((uint64)XFLAG_AS_1()) << 32);
8530 res = ROL_33_64(res, shift);
8532 USE_CYCLES(orig_shift<<CYC_SHIFT);
8534 FLAG_C = FLAG_X = res >> 24;
8535 res = MASK_OUT_ABOVE_32(res);
8538 FLAG_N = NFLAG_32(res);
8540 FLAG_V = VFLAG_CLEAR;
8545 FLAG_N = NFLAG_32(*r_dst);
8547 FLAG_V = VFLAG_CLEAR;
8552 uint orig_shift = DX & 0x3f;
8553 uint shift = orig_shift % 33;
8555 uint res = MASK_OUT_ABOVE_32((ROL_33(src, shift) & ~(1 << (shift - 1))) | (XFLAG_AS_1() << (shift - 1)));
8556 uint new_x_flag = src & (1 << (32 - shift));
8559 USE_CYCLES(orig_shift<<CYC_SHIFT);
8564 FLAG_X = (new_x_flag != 0)<<8;
8569 FLAG_N = NFLAG_32(res);
8571 FLAG_V = VFLAG_CLEAR;
8577 M68KMAKE_OP(roxl, 16, ., .)
8579 uint ea = M68KMAKE_GET_EA_AY_16;
8580 uint src = m68ki_read_16(ea);
8581 uint res = ROL_17(src | (XFLAG_AS_1() << 16), 1);
8583 FLAG_C = FLAG_X = res >> 8;
8584 res = MASK_OUT_ABOVE_16(res);
8586 m68ki_write_16(ea, res);
8588 FLAG_N = NFLAG_16(res);
8590 FLAG_V = VFLAG_CLEAR;
8594 M68KMAKE_OP(rtd, 32, ., .)
8596 if(CPU_TYPE_IS_010_PLUS(CPU_TYPE))
8598 uint new_pc = m68ki_pull_32();
8600 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
8601 REG_A[7] = MASK_OUT_ABOVE_32(REG_A[7] + MAKE_INT_16(OPER_I_16()));
8605 m68ki_exception_illegal();
8609 M68KMAKE_OP(rte, 32, ., .)
8617 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
8619 if(CPU_TYPE_IS_000(CPU_TYPE))
8621 new_sr = m68ki_pull_16();
8622 new_pc = m68ki_pull_32();
8624 m68ki_set_sr(new_sr);
8628 if(CPU_TYPE_IS_010(CPU_TYPE))
8630 format_word = m68ki_read_16(REG_A[7]+6) >> 12;
8631 if(format_word == 0)
8633 new_sr = m68ki_pull_16();
8634 new_pc = m68ki_pull_32();
8635 m68ki_fake_pull_16(); /* format word */
8637 m68ki_set_sr(new_sr);
8640 /* Not handling bus fault (9) */
8641 m68ki_exception_format_error();
8645 /* Otherwise it's 020 */
8647 format_word = m68ki_read_16(REG_A[7]+6) >> 12;
8650 case 0: /* Normal */
8651 new_sr = m68ki_pull_16();
8652 new_pc = m68ki_pull_32();
8653 m68ki_fake_pull_16(); /* format word */
8655 m68ki_set_sr(new_sr);
8657 case 1: /* Throwaway */
8658 new_sr = m68ki_pull_16();
8659 m68ki_fake_pull_32(); /* program counter */
8660 m68ki_fake_pull_16(); /* format word */
8661 m68ki_set_sr_noint(new_sr);
8664 new_sr = m68ki_pull_16();
8665 new_pc = m68ki_pull_32();
8666 m68ki_fake_pull_16(); /* format word */
8667 m68ki_fake_pull_32(); /* address */
8669 m68ki_set_sr(new_sr);
8672 /* Not handling long or short bus fault */
8673 m68ki_exception_format_error();
8676 m68ki_exception_privilege_violation();
8680 M68KMAKE_OP(rtm, 32, ., .)
8682 if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE))
8684 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
8685 M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n",
8686 m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR,
8687 m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2))));
8690 m68ki_exception_illegal();
8694 M68KMAKE_OP(rtr, 32, ., .)
8696 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
8697 m68ki_set_ccr(m68ki_pull_16());
8698 m68ki_jump(m68ki_pull_32());
8702 M68KMAKE_OP(rts, 32, ., .)
8704 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
8705 m68ki_jump(m68ki_pull_32());
8709 M68KMAKE_OP(sbcd, 8, rr, .)
8714 uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1();
8718 res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src);
8719 FLAG_X = FLAG_C = (res > 0x99) << 8;
8723 res = MASK_OUT_ABOVE_8(res);
8725 FLAG_N = NFLAG_8(res); /* officially undefined */
8728 *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;
8732 M68KMAKE_OP(sbcd, 8, mm, ax7)
8734 uint src = OPER_AY_PD_8();
8735 uint ea = EA_A7_PD_8();
8736 uint dst = m68ki_read_8(ea);
8737 uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1();
8741 res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src);
8742 FLAG_X = FLAG_C = (res > 0x99) << 8;
8746 res = MASK_OUT_ABOVE_8(res);
8748 FLAG_N = NFLAG_8(res); /* officially undefined */
8751 m68ki_write_8(ea, res);
8755 M68KMAKE_OP(sbcd, 8, mm, ay7)
8757 uint src = OPER_A7_PD_8();
8758 uint ea = EA_AX_PD_8();
8759 uint dst = m68ki_read_8(ea);
8760 uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1();
8764 res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src);
8765 FLAG_X = FLAG_C = (res > 0x99) << 8;
8769 res = MASK_OUT_ABOVE_8(res);
8771 FLAG_N = NFLAG_8(res); /* officially undefined */
8774 m68ki_write_8(ea, res);
8778 M68KMAKE_OP(sbcd, 8, mm, axy7)
8780 uint src = OPER_A7_PD_8();
8781 uint ea = EA_A7_PD_8();
8782 uint dst = m68ki_read_8(ea);
8783 uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1();
8787 res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src);
8788 FLAG_X = FLAG_C = (res > 0x99) << 8;
8792 res = MASK_OUT_ABOVE_8(res);
8794 FLAG_N = NFLAG_8(res); /* officially undefined */
8797 m68ki_write_8(ea, res);
8801 M68KMAKE_OP(sbcd, 8, mm, .)
8803 uint src = OPER_AY_PD_8();
8804 uint ea = EA_AX_PD_8();
8805 uint dst = m68ki_read_8(ea);
8806 uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1();
8810 res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src);
8811 FLAG_X = FLAG_C = (res > 0x99) << 8;
8815 res = MASK_OUT_ABOVE_8(res);
8817 FLAG_N = NFLAG_8(res); /* officially undefined */
8820 m68ki_write_8(ea, res);
8824 M68KMAKE_OP(st, 8, ., d)
8830 M68KMAKE_OP(st, 8, ., .)
8832 m68ki_write_8(M68KMAKE_GET_EA_AY_8, 0xff);
8836 M68KMAKE_OP(sf, 8, ., d)
8842 M68KMAKE_OP(sf, 8, ., .)
8844 m68ki_write_8(M68KMAKE_GET_EA_AY_8, 0);
8848 M68KMAKE_OP(scc, 8, ., d)
8859 M68KMAKE_OP(scc, 8, ., .)
8861 m68ki_write_8(M68KMAKE_GET_EA_AY_8, M68KMAKE_CC ? 0xff : 0);
8865 M68KMAKE_OP(stop, 0, ., .)
8869 uint new_sr = OPER_I_16();
8870 m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
8871 CPU_STOPPED |= STOP_LEVEL_STOP;
8872 m68ki_set_sr(new_sr);
8873 m68ki_remaining_cycles = 0;
8876 m68ki_exception_privilege_violation();
8880 M68KMAKE_OP(sub, 8, er, d)
8883 uint src = MASK_OUT_ABOVE_8(DY);
8884 uint dst = MASK_OUT_ABOVE_8(*r_dst);
8885 uint res = dst - src;
8887 FLAG_N = NFLAG_8(res);
8888 FLAG_X = FLAG_C = CFLAG_8(res);
8889 FLAG_V = VFLAG_SUB_8(src, dst, res);
8890 FLAG_Z = MASK_OUT_ABOVE_8(res);
8892 *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z;
8896 M68KMAKE_OP(sub, 8, er, .)
8899 uint src = M68KMAKE_GET_OPER_AY_8;
8900 uint dst = MASK_OUT_ABOVE_8(*r_dst);
8901 uint res = dst - src;
8903 FLAG_N = NFLAG_8(res);
8904 FLAG_X = FLAG_C = CFLAG_8(res);
8905 FLAG_V = VFLAG_SUB_8(src, dst, res);
8906 FLAG_Z = MASK_OUT_ABOVE_8(res);
8908 *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z;
8912 M68KMAKE_OP(sub, 16, er, d)
8915 uint src = MASK_OUT_ABOVE_16(DY);
8916 uint dst = MASK_OUT_ABOVE_16(*r_dst);
8917 uint res = dst - src;
8919 FLAG_N = NFLAG_16(res);
8920 FLAG_X = FLAG_C = CFLAG_16(res);
8921 FLAG_V = VFLAG_SUB_16(src, dst, res);
8922 FLAG_Z = MASK_OUT_ABOVE_16(res);
8924 *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z;
8928 M68KMAKE_OP(sub, 16, er, a)
8931 uint src = MASK_OUT_ABOVE_16(AY);
8932 uint dst = MASK_OUT_ABOVE_16(*r_dst);
8933 uint res = dst - src;
8935 FLAG_N = NFLAG_16(res);
8936 FLAG_X = FLAG_C = CFLAG_16(res);
8937 FLAG_V = VFLAG_SUB_16(src, dst, res);
8938 FLAG_Z = MASK_OUT_ABOVE_16(res);
8940 *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z;
8944 M68KMAKE_OP(sub, 16, er, .)
8947 uint src = M68KMAKE_GET_OPER_AY_16;
8948 uint dst = MASK_OUT_ABOVE_16(*r_dst);
8949 uint res = dst - src;
8951 FLAG_N = NFLAG_16(res);
8952 FLAG_X = FLAG_C = CFLAG_16(res);
8953 FLAG_V = VFLAG_SUB_16(src, dst, res);
8954 FLAG_Z = MASK_OUT_ABOVE_16(res);
8956 *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z;
8960 M68KMAKE_OP(sub, 32, er, d)
8965 uint res = dst - src;
8967 FLAG_N = NFLAG_32(res);
8968 FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res);
8969 FLAG_V = VFLAG_SUB_32(src, dst, res);
8970 FLAG_Z = MASK_OUT_ABOVE_32(res);
8976 M68KMAKE_OP(sub, 32, er, a)
8981 uint res = dst - src;
8983 FLAG_N = NFLAG_32(res);
8984 FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res);
8985 FLAG_V = VFLAG_SUB_32(src, dst, res);
8986 FLAG_Z = MASK_OUT_ABOVE_32(res);
8992 M68KMAKE_OP(sub, 32, er, .)
8995 uint src = M68KMAKE_GET_OPER_AY_32;
8997 uint res = dst - src;
8999 FLAG_N = NFLAG_32(res);
9000 FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res);
9001 FLAG_V = VFLAG_SUB_32(src, dst, res);
9002 FLAG_Z = MASK_OUT_ABOVE_32(res);
9008 M68KMAKE_OP(sub, 8, re, .)
9010 uint ea = M68KMAKE_GET_EA_AY_8;
9011 uint src = MASK_OUT_ABOVE_8(DX);
9012 uint dst = m68ki_read_8(ea);
9013 uint res = dst - src;
9015 FLAG_N = NFLAG_8(res);
9016 FLAG_Z = MASK_OUT_ABOVE_8(res);
9017 FLAG_X = FLAG_C = CFLAG_8(res);
9018 FLAG_V = VFLAG_SUB_8(src, dst, res);
9020 m68ki_write_8(ea, FLAG_Z);
9024 M68KMAKE_OP(sub, 16, re, .)
9026 uint ea = M68KMAKE_GET_EA_AY_16;
9027 uint src = MASK_OUT_ABOVE_16(DX);
9028 uint dst = m68ki_read_16(ea);
9029 uint res = dst - src;
9031 FLAG_N = NFLAG_16(res);
9032 FLAG_Z = MASK_OUT_ABOVE_16(res);
9033 FLAG_X = FLAG_C = CFLAG_16(res);
9034 FLAG_V = VFLAG_SUB_16(src, dst, res);
9036 m68ki_write_16(ea, FLAG_Z);
9040 M68KMAKE_OP(sub, 32, re, .)
9042 uint ea = M68KMAKE_GET_EA_AY_32;
9044 uint dst = m68ki_read_32(ea);
9045 uint res = dst - src;
9047 FLAG_N = NFLAG_32(res);
9048 FLAG_Z = MASK_OUT_ABOVE_32(res);
9049 FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res);
9050 FLAG_V = VFLAG_SUB_32(src, dst, res);
9052 m68ki_write_32(ea, FLAG_Z);
9056 M68KMAKE_OP(suba, 16, ., d)
9060 *r_dst = MASK_OUT_ABOVE_32(*r_dst - MAKE_INT_16(DY));
9064 M68KMAKE_OP(suba, 16, ., a)
9068 *r_dst = MASK_OUT_ABOVE_32(*r_dst - MAKE_INT_16(AY));
9072 M68KMAKE_OP(suba, 16, ., .)
9076 *r_dst = MASK_OUT_ABOVE_32(*r_dst - MAKE_INT_16(M68KMAKE_GET_OPER_AY_16));
9080 M68KMAKE_OP(suba, 32, ., d)
9084 *r_dst = MASK_OUT_ABOVE_32(*r_dst - DY);
9088 M68KMAKE_OP(suba, 32, ., a)
9092 *r_dst = MASK_OUT_ABOVE_32(*r_dst - AY);
9096 M68KMAKE_OP(suba, 32, ., .)
9100 *r_dst = MASK_OUT_ABOVE_32(*r_dst - M68KMAKE_GET_OPER_AY_32);
9104 M68KMAKE_OP(subi, 8, ., d)
9107 uint src = OPER_I_8();
9108 uint dst = MASK_OUT_ABOVE_8(*r_dst);
9109 uint res = dst - src;
9111 FLAG_N = NFLAG_8(res);
9112 FLAG_Z = MASK_OUT_ABOVE_8(res);
9113 FLAG_X = FLAG_C = CFLAG_8(res);
9114 FLAG_V = VFLAG_SUB_8(src, dst, res);
9116 *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z;
9120 M68KMAKE_OP(subi, 8, ., .)
9122 uint src = OPER_I_8();
9123 uint ea = M68KMAKE_GET_EA_AY_8;
9124 uint dst = m68ki_read_8(ea);
9125 uint res = dst - src;
9127 FLAG_N = NFLAG_8(res);
9128 FLAG_Z = MASK_OUT_ABOVE_8(res);
9129 FLAG_X = FLAG_C = CFLAG_8(res);
9130 FLAG_V = VFLAG_SUB_8(src, dst, res);
9132 m68ki_write_8(ea, FLAG_Z);
9136 M68KMAKE_OP(subi, 16, ., d)
9139 uint src = OPER_I_16();
9140 uint dst = MASK_OUT_ABOVE_16(*r_dst);
9141 uint res = dst - src;
9143 FLAG_N = NFLAG_16(res);
9144 FLAG_Z = MASK_OUT_ABOVE_16(res);
9145 FLAG_X = FLAG_C = CFLAG_16(res);
9146 FLAG_V = VFLAG_SUB_16(src, dst, res);
9148 *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z;
9152 M68KMAKE_OP(subi, 16, ., .)
9154 uint src = OPER_I_16();
9155 uint ea = M68KMAKE_GET_EA_AY_16;
9156 uint dst = m68ki_read_16(ea);
9157 uint res = dst - src;
9159 FLAG_N = NFLAG_16(res);
9160 FLAG_Z = MASK_OUT_ABOVE_16(res);
9161 FLAG_X = FLAG_C = CFLAG_16(res);
9162 FLAG_V = VFLAG_SUB_16(src, dst, res);
9164 m68ki_write_16(ea, FLAG_Z);
9168 M68KMAKE_OP(subi, 32, ., d)
9171 uint src = OPER_I_32();
9173 uint res = dst - src;
9175 FLAG_N = NFLAG_32(res);
9176 FLAG_Z = MASK_OUT_ABOVE_32(res);
9177 FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res);
9178 FLAG_V = VFLAG_SUB_32(src, dst, res);
9184 M68KMAKE_OP(subi, 32, ., .)
9186 uint src = OPER_I_32();
9187 uint ea = M68KMAKE_GET_EA_AY_32;
9188 uint dst = m68ki_read_32(ea);
9189 uint res = dst - src;
9191 FLAG_N = NFLAG_32(res);
9192 FLAG_Z = MASK_OUT_ABOVE_32(res);
9193 FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res);
9194 FLAG_V = VFLAG_SUB_32(src, dst, res);
9196 m68ki_write_32(ea, FLAG_Z);
9200 M68KMAKE_OP(subq, 8, ., d)
9203 uint src = (((REG_IR >> 9) - 1) & 7) + 1;
9204 uint dst = MASK_OUT_ABOVE_8(*r_dst);
9205 uint res = dst - src;
9207 FLAG_N = NFLAG_8(res);
9208 FLAG_Z = MASK_OUT_ABOVE_8(res);
9209 FLAG_X = FLAG_C = CFLAG_8(res);
9210 FLAG_V = VFLAG_SUB_8(src, dst, res);
9212 *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z;
9216 M68KMAKE_OP(subq, 8, ., .)
9218 uint src = (((REG_IR >> 9) - 1) & 7) + 1;
9219 uint ea = M68KMAKE_GET_EA_AY_8;
9220 uint dst = m68ki_read_8(ea);
9221 uint res = dst - src;
9223 FLAG_N = NFLAG_8(res);
9224 FLAG_Z = MASK_OUT_ABOVE_8(res);
9225 FLAG_X = FLAG_C = CFLAG_8(res);
9226 FLAG_V = VFLAG_SUB_8(src, dst, res);
9228 m68ki_write_8(ea, FLAG_Z);
9232 M68KMAKE_OP(subq, 16, ., d)
9235 uint src = (((REG_IR >> 9) - 1) & 7) + 1;
9236 uint dst = MASK_OUT_ABOVE_16(*r_dst);
9237 uint res = dst - src;
9239 FLAG_N = NFLAG_16(res);
9240 FLAG_Z = MASK_OUT_ABOVE_16(res);
9241 FLAG_X = FLAG_C = CFLAG_16(res);
9242 FLAG_V = VFLAG_SUB_16(src, dst, res);
9244 *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z;
9248 M68KMAKE_OP(subq, 16, ., a)
9252 *r_dst = MASK_OUT_ABOVE_32(*r_dst - ((((REG_IR >> 9) - 1) & 7) + 1));
9256 M68KMAKE_OP(subq, 16, ., .)
9258 uint src = (((REG_IR >> 9) - 1) & 7) + 1;
9259 uint ea = M68KMAKE_GET_EA_AY_16;
9260 uint dst = m68ki_read_16(ea);
9261 uint res = dst - src;
9263 FLAG_N = NFLAG_16(res);
9264 FLAG_Z = MASK_OUT_ABOVE_16(res);
9265 FLAG_X = FLAG_C = CFLAG_16(res);
9266 FLAG_V = VFLAG_SUB_16(src, dst, res);
9268 m68ki_write_16(ea, FLAG_Z);
9272 M68KMAKE_OP(subq, 32, ., d)
9275 uint src = (((REG_IR >> 9) - 1) & 7) + 1;
9277 uint res = dst - src;
9279 FLAG_N = NFLAG_32(res);
9280 FLAG_Z = MASK_OUT_ABOVE_32(res);
9281 FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res);
9282 FLAG_V = VFLAG_SUB_32(src, dst, res);
9288 M68KMAKE_OP(subq, 32, ., a)
9292 *r_dst = MASK_OUT_ABOVE_32(*r_dst - ((((REG_IR >> 9) - 1) & 7) + 1));
9296 M68KMAKE_OP(subq, 32, ., .)
9298 uint src = (((REG_IR >> 9) - 1) & 7) + 1;
9299 uint ea = M68KMAKE_GET_EA_AY_32;
9300 uint dst = m68ki_read_32(ea);
9301 uint res = dst - src;
9303 FLAG_N = NFLAG_32(res);
9304 FLAG_Z = MASK_OUT_ABOVE_32(res);
9305 FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res);
9306 FLAG_V = VFLAG_SUB_32(src, dst, res);
9308 m68ki_write_32(ea, FLAG_Z);
9312 M68KMAKE_OP(subx, 8, rr, .)
9315 uint src = MASK_OUT_ABOVE_8(DY);
9316 uint dst = MASK_OUT_ABOVE_8(*r_dst);
9317 uint res = dst - src - XFLAG_AS_1();
9319 FLAG_N = NFLAG_8(res);
9320 FLAG_X = FLAG_C = CFLAG_8(res);
9321 FLAG_V = VFLAG_SUB_8(src, dst, res);
9323 res = MASK_OUT_ABOVE_8(res);
9326 *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;
9330 M68KMAKE_OP(subx, 16, rr, .)
9333 uint src = MASK_OUT_ABOVE_16(DY);
9334 uint dst = MASK_OUT_ABOVE_16(*r_dst);
9335 uint res = dst - src - XFLAG_AS_1();
9337 FLAG_N = NFLAG_16(res);
9338 FLAG_X = FLAG_C = CFLAG_16(res);
9339 FLAG_V = VFLAG_SUB_16(src, dst, res);
9341 res = MASK_OUT_ABOVE_16(res);
9344 *r_dst = MASK_OUT_BELOW_16(*r_dst) | res;
9348 M68KMAKE_OP(subx, 32, rr, .)
9353 uint res = dst - src - XFLAG_AS_1();
9355 FLAG_N = NFLAG_32(res);
9356 FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res);
9357 FLAG_V = VFLAG_SUB_32(src, dst, res);
9359 res = MASK_OUT_ABOVE_32(res);
9366 M68KMAKE_OP(subx, 8, mm, ax7)
9368 uint src = OPER_AY_PD_8();
9369 uint ea = EA_A7_PD_8();
9370 uint dst = m68ki_read_8(ea);
9371 uint res = dst - src - XFLAG_AS_1();
9373 FLAG_N = NFLAG_8(res);
9374 FLAG_X = FLAG_C = CFLAG_8(res);
9375 FLAG_V = VFLAG_SUB_8(src, dst, res);
9377 res = MASK_OUT_ABOVE_8(res);
9380 m68ki_write_8(ea, res);
9384 M68KMAKE_OP(subx, 8, mm, ay7)
9386 uint src = OPER_A7_PD_8();
9387 uint ea = EA_AX_PD_8();
9388 uint dst = m68ki_read_8(ea);
9389 uint res = dst - src - XFLAG_AS_1();
9391 FLAG_N = NFLAG_8(res);
9392 FLAG_X = FLAG_C = CFLAG_8(res);
9393 FLAG_V = VFLAG_SUB_8(src, dst, res);
9395 res = MASK_OUT_ABOVE_8(res);
9398 m68ki_write_8(ea, res);
9402 M68KMAKE_OP(subx, 8, mm, axy7)
9404 uint src = OPER_A7_PD_8();
9405 uint ea = EA_A7_PD_8();
9406 uint dst = m68ki_read_8(ea);
9407 uint res = dst - src - XFLAG_AS_1();
9409 FLAG_N = NFLAG_8(res);
9410 FLAG_X = FLAG_C = CFLAG_8(res);
9411 FLAG_V = VFLAG_SUB_8(src, dst, res);
9413 res = MASK_OUT_ABOVE_8(res);
9416 m68ki_write_8(ea, res);
9420 M68KMAKE_OP(subx, 8, mm, .)
9422 uint src = OPER_AY_PD_8();
9423 uint ea = EA_AX_PD_8();
9424 uint dst = m68ki_read_8(ea);
9425 uint res = dst - src - XFLAG_AS_1();
9427 FLAG_N = NFLAG_8(res);
9428 FLAG_X = FLAG_C = CFLAG_8(res);
9429 FLAG_V = VFLAG_SUB_8(src, dst, res);
9431 res = MASK_OUT_ABOVE_8(res);
9434 m68ki_write_8(ea, res);
9438 M68KMAKE_OP(subx, 16, mm, .)
9440 uint src = OPER_AY_PD_16();
9441 uint ea = EA_AX_PD_16();
9442 uint dst = m68ki_read_16(ea);
9443 uint res = dst - src - XFLAG_AS_1();
9445 FLAG_N = NFLAG_16(res);
9446 FLAG_X = FLAG_C = CFLAG_16(res);
9447 FLAG_V = VFLAG_SUB_16(src, dst, res);
9449 res = MASK_OUT_ABOVE_16(res);
9452 m68ki_write_16(ea, res);
9456 M68KMAKE_OP(subx, 32, mm, .)
9458 uint src = OPER_AY_PD_32();
9459 uint ea = EA_AX_PD_32();
9460 uint dst = m68ki_read_32(ea);
9461 uint res = dst - src - XFLAG_AS_1();
9463 FLAG_N = NFLAG_32(res);
9464 FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res);
9465 FLAG_V = VFLAG_SUB_32(src, dst, res);
9467 res = MASK_OUT_ABOVE_32(res);
9470 m68ki_write_32(ea, res);
9474 M68KMAKE_OP(swap, 32, ., .)
9478 FLAG_Z = MASK_OUT_ABOVE_32(*r_dst<<16);
9479 *r_dst = (*r_dst>>16) | FLAG_Z;
9482 FLAG_N = NFLAG_32(*r_dst);
9483 FLAG_C = CFLAG_CLEAR;
9484 FLAG_V = VFLAG_CLEAR;
9488 M68KMAKE_OP(tas, 8, ., d)
9492 FLAG_Z = MASK_OUT_ABOVE_8(*r_dst);
9493 FLAG_N = NFLAG_8(*r_dst);
9494 FLAG_V = VFLAG_CLEAR;
9495 FLAG_C = CFLAG_CLEAR;
9500 M68KMAKE_OP(tas, 8, ., .)
9502 uint ea = M68KMAKE_GET_EA_AY_8;
9503 uint dst = m68ki_read_8(ea);
9506 FLAG_N = NFLAG_8(dst);
9507 FLAG_V = VFLAG_CLEAR;
9508 FLAG_C = CFLAG_CLEAR;
9509 m68ki_write_8(ea, dst | 0x80);
9513 M68KMAKE_OP(trap, 0, ., .)
9515 /* Trap#n stacks exception frame type 0 */
9516 m68ki_exception_trapN(EXCEPTION_TRAP_BASE + (REG_IR & 0xf)); /* HJB 990403 */
9520 M68KMAKE_OP(trapt, 0, ., .)
9522 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
9524 m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */
9527 m68ki_exception_illegal();
9531 M68KMAKE_OP(trapt, 16, ., .)
9533 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
9535 m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */
9538 m68ki_exception_illegal();
9542 M68KMAKE_OP(trapt, 32, ., .)
9544 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
9546 m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */
9549 m68ki_exception_illegal();
9553 M68KMAKE_OP(trapf, 0, ., .)
9555 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
9559 m68ki_exception_illegal();
9563 M68KMAKE_OP(trapf, 16, ., .)
9565 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
9570 m68ki_exception_illegal();
9574 M68KMAKE_OP(trapf, 32, ., .)
9576 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
9581 m68ki_exception_illegal();
9585 M68KMAKE_OP(trapcc, 0, ., .)
9587 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
9590 m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */
9593 m68ki_exception_illegal();
9597 M68KMAKE_OP(trapcc, 16, ., .)
9599 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
9603 m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */
9609 m68ki_exception_illegal();
9613 M68KMAKE_OP(trapcc, 32, ., .)
9615 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
9619 m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */
9625 m68ki_exception_illegal();
9629 M68KMAKE_OP(trapv, 0, ., .)
9635 m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */
9639 M68KMAKE_OP(tst, 8, ., d)
9641 uint res = MASK_OUT_ABOVE_8(DY);
9643 FLAG_N = NFLAG_8(res);
9645 FLAG_V = VFLAG_CLEAR;
9646 FLAG_C = CFLAG_CLEAR;
9650 M68KMAKE_OP(tst, 8, ., .)
9652 uint ea = M68KMAKE_GET_EA_AY_8;
9653 uint res = m68ki_read_8(ea);
9655 FLAG_N = NFLAG_8(res);
9657 FLAG_V = VFLAG_CLEAR;
9658 FLAG_C = CFLAG_CLEAR;
9662 M68KMAKE_OP(tst, 8, ., pcdi)
9664 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
9666 uint res = OPER_PCDI_8();
9668 FLAG_N = NFLAG_8(res);
9670 FLAG_V = VFLAG_CLEAR;
9671 FLAG_C = CFLAG_CLEAR;
9674 m68ki_exception_illegal();
9678 M68KMAKE_OP(tst, 8, ., pcix)
9680 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
9682 uint res = OPER_PCIX_8();
9684 FLAG_N = NFLAG_8(res);
9686 FLAG_V = VFLAG_CLEAR;
9687 FLAG_C = CFLAG_CLEAR;
9690 m68ki_exception_illegal();
9694 M68KMAKE_OP(tst, 8, ., i)
9696 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
9698 uint res = OPER_I_8();
9700 FLAG_N = NFLAG_8(res);
9702 FLAG_V = VFLAG_CLEAR;
9703 FLAG_C = CFLAG_CLEAR;
9706 m68ki_exception_illegal();
9710 M68KMAKE_OP(tst, 16, ., d)
9712 uint res = MASK_OUT_ABOVE_16(DY);
9714 FLAG_N = NFLAG_16(res);
9716 FLAG_V = VFLAG_CLEAR;
9717 FLAG_C = CFLAG_CLEAR;
9721 M68KMAKE_OP(tst, 16, ., a)
9723 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
9725 uint res = MAKE_INT_16(AY);
9727 FLAG_N = NFLAG_16(res);
9729 FLAG_V = VFLAG_CLEAR;
9730 FLAG_C = CFLAG_CLEAR;
9733 m68ki_exception_illegal();
9737 M68KMAKE_OP(tst, 16, ., .)
9739 uint res = M68KMAKE_GET_OPER_AY_16;
9741 FLAG_N = NFLAG_16(res);
9743 FLAG_V = VFLAG_CLEAR;
9744 FLAG_C = CFLAG_CLEAR;
9748 M68KMAKE_OP(tst, 16, ., pcdi)
9750 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
9752 uint res = OPER_PCDI_16();
9754 FLAG_N = NFLAG_16(res);
9756 FLAG_V = VFLAG_CLEAR;
9757 FLAG_C = CFLAG_CLEAR;
9760 m68ki_exception_illegal();
9764 M68KMAKE_OP(tst, 16, ., pcix)
9766 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
9768 uint res = OPER_PCIX_16();
9770 FLAG_N = NFLAG_16(res);
9772 FLAG_V = VFLAG_CLEAR;
9773 FLAG_C = CFLAG_CLEAR;
9776 m68ki_exception_illegal();
9780 M68KMAKE_OP(tst, 16, ., i)
9782 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
9784 uint res = OPER_I_16();
9786 FLAG_N = NFLAG_16(res);
9788 FLAG_V = VFLAG_CLEAR;
9789 FLAG_C = CFLAG_CLEAR;
9792 m68ki_exception_illegal();
9796 M68KMAKE_OP(tst, 32, ., d)
9800 FLAG_N = NFLAG_32(res);
9802 FLAG_V = VFLAG_CLEAR;
9803 FLAG_C = CFLAG_CLEAR;
9807 M68KMAKE_OP(tst, 32, ., a)
9809 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
9813 FLAG_N = NFLAG_32(res);
9815 FLAG_V = VFLAG_CLEAR;
9816 FLAG_C = CFLAG_CLEAR;
9819 m68ki_exception_illegal();
9823 M68KMAKE_OP(tst, 32, ., .)
9825 uint res = M68KMAKE_GET_OPER_AY_32;
9827 FLAG_N = NFLAG_32(res);
9829 FLAG_V = VFLAG_CLEAR;
9830 FLAG_C = CFLAG_CLEAR;
9834 M68KMAKE_OP(tst, 32, ., pcdi)
9836 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
9838 uint res = OPER_PCDI_32();
9840 FLAG_N = NFLAG_32(res);
9842 FLAG_V = VFLAG_CLEAR;
9843 FLAG_C = CFLAG_CLEAR;
9846 m68ki_exception_illegal();
9850 M68KMAKE_OP(tst, 32, ., pcix)
9852 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
9854 uint res = OPER_PCIX_32();
9856 FLAG_N = NFLAG_32(res);
9858 FLAG_V = VFLAG_CLEAR;
9859 FLAG_C = CFLAG_CLEAR;
9862 m68ki_exception_illegal();
9866 M68KMAKE_OP(tst, 32, ., i)
9868 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
9870 uint res = OPER_I_32();
9872 FLAG_N = NFLAG_32(res);
9874 FLAG_V = VFLAG_CLEAR;
9875 FLAG_C = CFLAG_CLEAR;
9878 m68ki_exception_illegal();
9882 M68KMAKE_OP(unlk, 32, ., a7)
9884 REG_A[7] = m68ki_read_32(REG_A[7]);
9888 M68KMAKE_OP(unlk, 32, ., .)
9893 *r_dst = m68ki_pull_32();
9897 M68KMAKE_OP(unpk, 16, rr, .)
9899 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
9901 /* Note: DX and DY are reversed in Motorola's docs */
9905 *r_dst = MASK_OUT_BELOW_16(*r_dst) | (((((src << 4) & 0x0f00) | (src & 0x000f)) + OPER_I_16()) & 0xffff);
9908 m68ki_exception_illegal();
9912 M68KMAKE_OP(unpk, 16, mm, ax7)
9914 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
9916 /* Note: AX and AY are reversed in Motorola's docs */
9917 uint src = OPER_AY_PD_8();
9920 src = (((src << 4) & 0x0f00) | (src & 0x000f)) + OPER_I_16();
9921 ea_dst = EA_A7_PD_8();
9922 m68ki_write_8(ea_dst, (src >> 8) & 0xff);
9923 ea_dst = EA_A7_PD_8();
9924 m68ki_write_8(ea_dst, src & 0xff);
9927 m68ki_exception_illegal();
9931 M68KMAKE_OP(unpk, 16, mm, ay7)
9933 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
9935 /* Note: AX and AY are reversed in Motorola's docs */
9936 uint src = OPER_A7_PD_8();
9939 src = (((src << 4) & 0x0f00) | (src & 0x000f)) + OPER_I_16();
9940 ea_dst = EA_AX_PD_8();
9941 m68ki_write_8(ea_dst, (src >> 8) & 0xff);
9942 ea_dst = EA_AX_PD_8();
9943 m68ki_write_8(ea_dst, src & 0xff);
9946 m68ki_exception_illegal();
9950 M68KMAKE_OP(unpk, 16, mm, axy7)
9952 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
9954 uint src = OPER_A7_PD_8();
9957 src = (((src << 4) & 0x0f00) | (src & 0x000f)) + OPER_I_16();
9958 ea_dst = EA_A7_PD_8();
9959 m68ki_write_8(ea_dst, (src >> 8) & 0xff);
9960 ea_dst = EA_A7_PD_8();
9961 m68ki_write_8(ea_dst, src & 0xff);
9964 m68ki_exception_illegal();
9968 M68KMAKE_OP(unpk, 16, mm, .)
9970 if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
9972 /* Note: AX and AY are reversed in Motorola's docs */
9973 uint src = OPER_AY_PD_8();
9976 src = (((src << 4) & 0x0f00) | (src & 0x000f)) + OPER_I_16();
9977 ea_dst = EA_AX_PD_8();
9978 m68ki_write_8(ea_dst, (src >> 8) & 0xff);
9979 ea_dst = EA_AX_PD_8();
9980 m68ki_write_8(ea_dst, src & 0xff);
9983 m68ki_exception_illegal();
9988 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX