Fix SR read/write and a test

This commit is contained in:
lazymio
2021-12-04 23:20:24 +01:00
parent 3020d7b82a
commit 8a0ca8715e
2 changed files with 32 additions and 2 deletions

View File

@ -78,7 +78,7 @@ static void reg_write(CPUM68KState *env, unsigned int regid, const void *value)
env->pc = *(uint32_t *)value; env->pc = *(uint32_t *)value;
break; break;
case UC_M68K_REG_SR: case UC_M68K_REG_SR:
env->sr = *(uint32_t *)value; cpu_m68k_set_sr(env, *(uint32_t *)value);
break; break;
} }
} }

View File

@ -3,4 +3,34 @@
const uint64_t code_start = 0x1000; const uint64_t code_start = 0x1000;
const uint64_t code_len = 0x4000; const uint64_t code_len = 0x4000;
TEST_LIST = {{NULL, NULL}}; static void uc_common_setup(uc_engine **uc, uc_arch arch, uc_mode mode,
const char *code, uint64_t size,
uc_cpu_m68k cpu_model)
{
OK(uc_open(arch, mode, uc));
OK(uc_ctl_set_cpu_model(*uc, cpu_model));
OK(uc_mem_map(*uc, code_start, code_len, UC_PROT_ALL));
OK(uc_mem_write(*uc, code_start, code, size));
}
static void test_move_to_sr()
{
uc_engine *uc;
char code[] = "\x46\xfc\x27\x00"; // move #$2700,sr
int r_sr;
uc_common_setup(&uc, UC_ARCH_M68K, UC_MODE_BIG_ENDIAN, code,
sizeof(code) - 1, UC_CPU_M68K_M68000);
OK(uc_reg_read(uc, UC_M68K_REG_SR, &r_sr));
r_sr = r_sr | 0x2000;
OK(uc_reg_write(uc, UC_M68K_REG_SR, &r_sr));
OK(uc_emu_start(uc, code_start, code_start + sizeof(code) - 1, 0, 0));
OK(uc_close(uc));
}
TEST_LIST = {{"test_move_to_sr", test_move_to_sr}, {NULL, NULL}};