comparison m68k_core_x86.c @ 586:aa35ccb90aa9

Minor refactor to translate_m68k_move_ccr_sr and translate_m68k_stop to reduce code duplication
author Michael Pavone <pavone@retrodev.com>
date Fri, 07 Mar 2014 19:45:05 -0800
parents 82aadd5d103a
children 55c5b0f913ce
comparison
equal deleted inserted replaced
585:82aadd5d103a 586:aa35ccb90aa9
2050 call(code, opts->do_sync); 2050 call(code, opts->do_sync);
2051 } 2051 }
2052 } 2052 }
2053 } 2053 }
2054 2054
2055 void set_all_flags(m68k_options *opts, uint8_t flags)
2056 {
2057 uint32_t flag_mask = flags & 0x10 ? X1 : X0;
2058 flag_mask |= flags & 0x8 ? N1 : N0;
2059 flag_mask |= flags & 0x4 ? Z1 : Z0;
2060 flag_mask |= flags & 0x2 ? V1 : V0;
2061 flag_mask |= flags & 0x1 ? C1 : C0;
2062 update_flags(opts, flag_mask);
2063 }
2064
2055 void translate_m68k_move_ccr_sr(m68k_options *opts, m68kinst *inst, host_ea *src_op, host_ea *dst_op) 2065 void translate_m68k_move_ccr_sr(m68k_options *opts, m68kinst *inst, host_ea *src_op, host_ea *dst_op)
2056 { 2066 {
2057 code_info *code = &opts->gen.code; 2067 code_info *code = &opts->gen.code;
2058 //TODO: Privilege check for MOVE to SR 2068 //TODO: Privilege check for MOVE to SR
2059 if (src_op->mode == MODE_IMMED) { 2069 if (src_op->mode == MODE_IMMED) {
2060 uint32_t flag_mask = src_op->disp & 0x10 ? X1 : X0; 2070 set_all_flags(opts, src_op->disp);
2061 flag_mask |= src_op->disp & 0x8 ? N1 : N0;
2062 flag_mask |= src_op->disp & 0x4 ? Z1 : Z0;
2063 flag_mask |= src_op->disp & 0x2 ? V1 : V0;
2064 flag_mask |= src_op->disp & 0x1 ? C1 : C0;
2065 update_flags(opts, flag_mask);
2066 if (inst->op == M68K_MOVE_SR) { 2071 if (inst->op == M68K_MOVE_SR) {
2067 mov_irdisp(code, (src_op->disp >> 8), opts->gen.context_reg, offsetof(m68k_context, status), SZ_B); 2072 mov_irdisp(code, (src_op->disp >> 8), opts->gen.context_reg, offsetof(m68k_context, status), SZ_B);
2068 if (!((inst->src.params.immed >> 8) & (1 << BIT_SUPERVISOR))) { 2073 if (!((inst->src.params.immed >> 8) & (1 << BIT_SUPERVISOR))) {
2069 //leave supervisor mode 2074 //leave supervisor mode
2070 swap_ssp_usp(opts); 2075 swap_ssp_usp(opts);
2092 //possibly even 12 since that's how long MOVE to SR takes 2097 //possibly even 12 since that's how long MOVE to SR takes
2093 //On further thought prefetch + the fact that this stops the CPU may make 2098 //On further thought prefetch + the fact that this stops the CPU may make
2094 //Motorola's accounting make sense here 2099 //Motorola's accounting make sense here
2095 code_info *code = &opts->gen.code; 2100 code_info *code = &opts->gen.code;
2096 cycles(&opts->gen, BUS*2); 2101 cycles(&opts->gen, BUS*2);
2097 uint32_t flag_mask = inst->src.params.immed & 0x10 ? X1 : X0; 2102 set_all_flags(opts, inst->src.params.immed);
2098 flag_mask |= inst->src.params.immed & 0x8 ? N1 : N0;
2099 flag_mask |= inst->src.params.immed & 0x4 ? Z1 : Z0;
2100 flag_mask |= inst->src.params.immed & 0x2 ? V1 : V0;
2101 flag_mask |= inst->src.params.immed & 0x1 ? C1 : C0;
2102 update_flags(opts, flag_mask);
2103 mov_irdisp(code, (inst->src.params.immed >> 8), opts->gen.context_reg, offsetof(m68k_context, status), SZ_B); 2103 mov_irdisp(code, (inst->src.params.immed >> 8), opts->gen.context_reg, offsetof(m68k_context, status), SZ_B);
2104 if (!((inst->src.params.immed >> 8) & (1 << BIT_SUPERVISOR))) { 2104 if (!((inst->src.params.immed >> 8) & (1 << BIT_SUPERVISOR))) {
2105 //leave supervisor mode 2105 //leave supervisor mode
2106 swap_ssp_usp(opts); 2106 swap_ssp_usp(opts);
2107 } 2107 }