renamed m68k enum constants

This commit is contained in:
mothran 2015-08-23 21:56:24 -07:00
parent 1dd3334f87
commit 2516de7ed8
6 changed files with 89 additions and 89 deletions

View file

@ -37,7 +37,7 @@ def test_m68k():
mu.mem_write(ADDRESS, M68K_CODE) mu.mem_write(ADDRESS, M68K_CODE)
# initialize machine registers # initialize machine registers
mu.reg_write(M68K_REG_D3, 0x1234) mu.reg_write(UC_M68K_REG_D3, 0x1234)
# tracing all basic blocks with customized callback # tracing all basic blocks with customized callback
mu.hook_add(UC_HOOK_BLOCK, hook_block) mu.hook_add(UC_HOOK_BLOCK, hook_block)
@ -51,7 +51,7 @@ def test_m68k():
# now print out some registers # now print out some registers
print(">>> Emulation done. Below is the CPU context") print(">>> Emulation done. Below is the CPU context")
d3 = mu.reg_read(M68K_REG_D3) d3 = mu.reg_read(UC_M68K_REG_D3)
print(">>> D3 = 0x%x" %d3) print(">>> D3 = 0x%x" %d3)
except UcError as e: except UcError as e:

View file

@ -2,23 +2,23 @@
# M68K registers # M68K registers
M68K_REG_INVALID = 0 UC_M68K_REG_INVALID = 0
M68K_REG_A0 = 1 UC_M68K_REG_A0 = 1
M68K_REG_A1 = 2 UC_M68K_REG_A1 = 2
M68K_REG_A2 = 3 UC_M68K_REG_A2 = 3
M68K_REG_A3 = 4 UC_M68K_REG_A3 = 4
M68K_REG_A4 = 5 UC_M68K_REG_A4 = 5
M68K_REG_A5 = 6 UC_M68K_REG_A5 = 6
M68K_REG_A6 = 7 UC_M68K_REG_A6 = 7
M68K_REG_A7 = 8 UC_M68K_REG_A7 = 8
M68K_REG_D0 = 9 UC_M68K_REG_D0 = 9
M68K_REG_D1 = 10 UC_M68K_REG_D1 = 10
M68K_REG_D2 = 11 UC_M68K_REG_D2 = 11
M68K_REG_D3 = 12 UC_M68K_REG_D3 = 12
M68K_REG_D4 = 13 UC_M68K_REG_D4 = 13
M68K_REG_D5 = 14 UC_M68K_REG_D5 = 14
M68K_REG_D6 = 15 UC_M68K_REG_D6 = 15
M68K_REG_D7 = 16 UC_M68K_REG_D7 = 16
M68K_REG_SR = 17 UC_M68K_REG_SR = 17
M68K_REG_PC = 18 UC_M68K_REG_PC = 18
M68K_REG_ENDING = 19 UC_M68K_REG_ENDING = 19

View file

@ -17,30 +17,30 @@ extern "C" {
//> M68K registers //> M68K registers
typedef enum m68k_reg { typedef enum m68k_reg {
M68K_REG_INVALID = 0, UC_M68K_REG_INVALID = 0,
M68K_REG_A0, UC_M68K_REG_A0,
M68K_REG_A1, UC_M68K_REG_A1,
M68K_REG_A2, UC_M68K_REG_A2,
M68K_REG_A3, UC_M68K_REG_A3,
M68K_REG_A4, UC_M68K_REG_A4,
M68K_REG_A5, UC_M68K_REG_A5,
M68K_REG_A6, UC_M68K_REG_A6,
M68K_REG_A7, UC_M68K_REG_A7,
M68K_REG_D0, UC_M68K_REG_D0,
M68K_REG_D1, UC_M68K_REG_D1,
M68K_REG_D2, UC_M68K_REG_D2,
M68K_REG_D3, UC_M68K_REG_D3,
M68K_REG_D4, UC_M68K_REG_D4,
M68K_REG_D5, UC_M68K_REG_D5,
M68K_REG_D6, UC_M68K_REG_D6,
M68K_REG_D7, UC_M68K_REG_D7,
M68K_REG_SR, UC_M68K_REG_SR,
M68K_REG_PC, UC_M68K_REG_PC,
M68K_REG_ENDING, // <-- mark the end of the list of registers UC_M68K_REG_ENDING, // <-- mark the end of the list of registers
} m68k_reg; } m68k_reg;
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -38,14 +38,14 @@ int m68k_reg_read(uch handle, unsigned int regid, void *value)
struct uc_struct *uc = (struct uc_struct *)handle; struct uc_struct *uc = (struct uc_struct *)handle;
CPUState *mycpu = first_cpu; CPUState *mycpu = first_cpu;
if (regid >= M68K_REG_A0 && regid <= M68K_REG_A7) if (regid >= UC_M68K_REG_A0 && regid <= UC_M68K_REG_A7)
*(int32_t *)value = M68K_CPU(uc, mycpu)->env.aregs[regid - M68K_REG_A0]; *(int32_t *)value = M68K_CPU(uc, mycpu)->env.aregs[regid - UC_M68K_REG_A0];
else if (regid >= M68K_REG_D0 && regid <= M68K_REG_D7) else if (regid >= UC_M68K_REG_D0 && regid <= UC_M68K_REG_D7)
*(int32_t *)value = M68K_CPU(uc, mycpu)->env.dregs[regid - M68K_REG_D0]; *(int32_t *)value = M68K_CPU(uc, mycpu)->env.dregs[regid - UC_M68K_REG_D0];
else { else {
switch(regid) { switch(regid) {
default: break; default: break;
case M68K_REG_PC: case UC_M68K_REG_PC:
*(int32_t *)value = M68K_CPU(uc, mycpu)->env.pc; *(int32_t *)value = M68K_CPU(uc, mycpu)->env.pc;
break; break;
} }
@ -65,14 +65,14 @@ int m68k_reg_write(uch handle, unsigned int regid, void *value)
struct uc_struct *uc = (struct uc_struct *) handle; struct uc_struct *uc = (struct uc_struct *) handle;
CPUState *mycpu = first_cpu; CPUState *mycpu = first_cpu;
if (regid >= M68K_REG_A0 && regid <= M68K_REG_A7) if (regid >= UC_M68K_REG_A0 && regid <= UC_M68K_REG_A7)
M68K_CPU(uc, mycpu)->env.aregs[regid - M68K_REG_A0] = *(int32_t *)value; M68K_CPU(uc, mycpu)->env.aregs[regid - UC_M68K_REG_A0] = *(int32_t *)value;
else if (regid >= M68K_REG_D0 && regid <= M68K_REG_D7) else if (regid >= UC_M68K_REG_D0 && regid <= UC_M68K_REG_D7)
M68K_CPU(uc, mycpu)->env.dregs[regid - M68K_REG_D0] = *(int32_t *)value; M68K_CPU(uc, mycpu)->env.dregs[regid - UC_M68K_REG_D0] = *(int32_t *)value;
else { else {
switch(regid) { switch(regid) {
default: break; default: break;
case M68K_REG_PC: case UC_M68K_REG_PC:
M68K_CPU(uc, mycpu)->env.pc = *(uint32_t *)value; M68K_CPU(uc, mycpu)->env.pc = *(uint32_t *)value;
break; break;
} }

View file

@ -66,26 +66,26 @@ static void test_m68k(void)
uc_mem_write(handle, ADDRESS, (uint8_t *)M68K_CODE, sizeof(M68K_CODE) - 1); uc_mem_write(handle, ADDRESS, (uint8_t *)M68K_CODE, sizeof(M68K_CODE) - 1);
// initialize machine registers // initialize machine registers
uc_reg_write(handle, M68K_REG_D0, &d0); uc_reg_write(handle, UC_M68K_REG_D0, &d0);
uc_reg_write(handle, M68K_REG_D1, &d1); uc_reg_write(handle, UC_M68K_REG_D1, &d1);
uc_reg_write(handle, M68K_REG_D2, &d2); uc_reg_write(handle, UC_M68K_REG_D2, &d2);
uc_reg_write(handle, M68K_REG_D3, &d3); uc_reg_write(handle, UC_M68K_REG_D3, &d3);
uc_reg_write(handle, M68K_REG_D4, &d4); uc_reg_write(handle, UC_M68K_REG_D4, &d4);
uc_reg_write(handle, M68K_REG_D5, &d5); uc_reg_write(handle, UC_M68K_REG_D5, &d5);
uc_reg_write(handle, M68K_REG_D6, &d6); uc_reg_write(handle, UC_M68K_REG_D6, &d6);
uc_reg_write(handle, M68K_REG_D7, &d7); uc_reg_write(handle, UC_M68K_REG_D7, &d7);
uc_reg_write(handle, M68K_REG_A0, &a0); uc_reg_write(handle, UC_M68K_REG_A0, &a0);
uc_reg_write(handle, M68K_REG_A1, &a1); uc_reg_write(handle, UC_M68K_REG_A1, &a1);
uc_reg_write(handle, M68K_REG_A2, &a2); uc_reg_write(handle, UC_M68K_REG_A2, &a2);
uc_reg_write(handle, M68K_REG_A3, &a3); uc_reg_write(handle, UC_M68K_REG_A3, &a3);
uc_reg_write(handle, M68K_REG_A4, &a4); uc_reg_write(handle, UC_M68K_REG_A4, &a4);
uc_reg_write(handle, M68K_REG_A5, &a5); uc_reg_write(handle, UC_M68K_REG_A5, &a5);
uc_reg_write(handle, M68K_REG_A6, &a6); uc_reg_write(handle, UC_M68K_REG_A6, &a6);
uc_reg_write(handle, M68K_REG_A7, &a7); uc_reg_write(handle, UC_M68K_REG_A7, &a7);
uc_reg_write(handle, M68K_REG_PC, &pc); uc_reg_write(handle, UC_M68K_REG_PC, &pc);
uc_reg_write(handle, M68K_REG_SR, &sr); uc_reg_write(handle, UC_M68K_REG_SR, &sr);
// tracing all basic blocks with customized callback // tracing all basic blocks with customized callback
uc_hook_add(handle, &trace1, UC_HOOK_BLOCK, hook_block, NULL, (uint64_t)1, (uint64_t)0); uc_hook_add(handle, &trace1, UC_HOOK_BLOCK, hook_block, NULL, (uint64_t)1, (uint64_t)0);
@ -103,26 +103,26 @@ static void test_m68k(void)
// now print out some registers // now print out some registers
printf(">>> Emulation done. Below is the CPU context\n"); printf(">>> Emulation done. Below is the CPU context\n");
uc_reg_read(handle, M68K_REG_D0, &d0); uc_reg_read(handle, UC_M68K_REG_D0, &d0);
uc_reg_read(handle, M68K_REG_D1, &d1); uc_reg_read(handle, UC_M68K_REG_D1, &d1);
uc_reg_read(handle, M68K_REG_D2, &d2); uc_reg_read(handle, UC_M68K_REG_D2, &d2);
uc_reg_read(handle, M68K_REG_D3, &d3); uc_reg_read(handle, UC_M68K_REG_D3, &d3);
uc_reg_read(handle, M68K_REG_D4, &d4); uc_reg_read(handle, UC_M68K_REG_D4, &d4);
uc_reg_read(handle, M68K_REG_D5, &d5); uc_reg_read(handle, UC_M68K_REG_D5, &d5);
uc_reg_read(handle, M68K_REG_D6, &d6); uc_reg_read(handle, UC_M68K_REG_D6, &d6);
uc_reg_read(handle, M68K_REG_D7, &d7); uc_reg_read(handle, UC_M68K_REG_D7, &d7);
uc_reg_read(handle, M68K_REG_A0, &a0); uc_reg_read(handle, UC_M68K_REG_A0, &a0);
uc_reg_read(handle, M68K_REG_A1, &a1); uc_reg_read(handle, UC_M68K_REG_A1, &a1);
uc_reg_read(handle, M68K_REG_A2, &a2); uc_reg_read(handle, UC_M68K_REG_A2, &a2);
uc_reg_read(handle, M68K_REG_A3, &a3); uc_reg_read(handle, UC_M68K_REG_A3, &a3);
uc_reg_read(handle, M68K_REG_A4, &a4); uc_reg_read(handle, UC_M68K_REG_A4, &a4);
uc_reg_read(handle, M68K_REG_A5, &a5); uc_reg_read(handle, UC_M68K_REG_A5, &a5);
uc_reg_read(handle, M68K_REG_A6, &a6); uc_reg_read(handle, UC_M68K_REG_A6, &a6);
uc_reg_read(handle, M68K_REG_A7, &a7); uc_reg_read(handle, UC_M68K_REG_A7, &a7);
uc_reg_read(handle, M68K_REG_PC, &pc); uc_reg_read(handle, UC_M68K_REG_PC, &pc);
uc_reg_read(handle, M68K_REG_SR, &sr); uc_reg_read(handle, UC_M68K_REG_SR, &sr);
printf(">>> A0 = 0x%x\t\t>>> D0 = 0x%x\n", a0, d0); printf(">>> A0 = 0x%x\t\t>>> D0 = 0x%x\n", a0, d0);
printf(">>> A1 = 0x%x\t\t>>> D1 = 0x%x\n", a1, d1); printf(">>> A1 = 0x%x\t\t>>> D1 = 0x%x\n", a1, d1);

2
uc.c
View file

@ -415,7 +415,7 @@ uc_err uc_emu_start(uch handle, uint64_t begin, uint64_t until, uint64_t timeout
break; break;
case UC_ARCH_M68K: case UC_ARCH_M68K:
uc_reg_write(handle, M68K_REG_PC, &begin); uc_reg_write(handle, UC_M68K_REG_PC, &begin);
break; break;
case UC_ARCH_X86: case UC_ARCH_X86: