diff --git a/bindings/python/sample_m68k.py b/bindings/python/sample_m68k.py index 6f05dd4b..9a85f96f 100755 --- a/bindings/python/sample_m68k.py +++ b/bindings/python/sample_m68k.py @@ -37,7 +37,7 @@ def test_m68k(): mu.mem_write(ADDRESS, M68K_CODE) # 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 mu.hook_add(UC_HOOK_BLOCK, hook_block) @@ -51,7 +51,7 @@ def test_m68k(): # now print out some registers 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) except UcError as e: diff --git a/bindings/python/unicorn/m68k_const.py b/bindings/python/unicorn/m68k_const.py index ae44706a..37b00b99 100644 --- a/bindings/python/unicorn/m68k_const.py +++ b/bindings/python/unicorn/m68k_const.py @@ -2,23 +2,23 @@ # M68K registers -M68K_REG_INVALID = 0 -M68K_REG_A0 = 1 -M68K_REG_A1 = 2 -M68K_REG_A2 = 3 -M68K_REG_A3 = 4 -M68K_REG_A4 = 5 -M68K_REG_A5 = 6 -M68K_REG_A6 = 7 -M68K_REG_A7 = 8 -M68K_REG_D0 = 9 -M68K_REG_D1 = 10 -M68K_REG_D2 = 11 -M68K_REG_D3 = 12 -M68K_REG_D4 = 13 -M68K_REG_D5 = 14 -M68K_REG_D6 = 15 -M68K_REG_D7 = 16 -M68K_REG_SR = 17 -M68K_REG_PC = 18 -M68K_REG_ENDING = 19 +UC_M68K_REG_INVALID = 0 +UC_M68K_REG_A0 = 1 +UC_M68K_REG_A1 = 2 +UC_M68K_REG_A2 = 3 +UC_M68K_REG_A3 = 4 +UC_M68K_REG_A4 = 5 +UC_M68K_REG_A5 = 6 +UC_M68K_REG_A6 = 7 +UC_M68K_REG_A7 = 8 +UC_M68K_REG_D0 = 9 +UC_M68K_REG_D1 = 10 +UC_M68K_REG_D2 = 11 +UC_M68K_REG_D3 = 12 +UC_M68K_REG_D4 = 13 +UC_M68K_REG_D5 = 14 +UC_M68K_REG_D6 = 15 +UC_M68K_REG_D7 = 16 +UC_M68K_REG_SR = 17 +UC_M68K_REG_PC = 18 +UC_M68K_REG_ENDING = 19 diff --git a/include/unicorn/m68k.h b/include/unicorn/m68k.h index ff080a1c..36aa85a7 100644 --- a/include/unicorn/m68k.h +++ b/include/unicorn/m68k.h @@ -17,30 +17,30 @@ extern "C" { //> M68K registers typedef enum m68k_reg { - M68K_REG_INVALID = 0, + UC_M68K_REG_INVALID = 0, - M68K_REG_A0, - M68K_REG_A1, - M68K_REG_A2, - M68K_REG_A3, - M68K_REG_A4, - M68K_REG_A5, - M68K_REG_A6, - M68K_REG_A7, + UC_M68K_REG_A0, + UC_M68K_REG_A1, + UC_M68K_REG_A2, + UC_M68K_REG_A3, + UC_M68K_REG_A4, + UC_M68K_REG_A5, + UC_M68K_REG_A6, + UC_M68K_REG_A7, - M68K_REG_D0, - M68K_REG_D1, - M68K_REG_D2, - M68K_REG_D3, - M68K_REG_D4, - M68K_REG_D5, - M68K_REG_D6, - M68K_REG_D7, + UC_M68K_REG_D0, + UC_M68K_REG_D1, + UC_M68K_REG_D2, + UC_M68K_REG_D3, + UC_M68K_REG_D4, + UC_M68K_REG_D5, + UC_M68K_REG_D6, + UC_M68K_REG_D7, - M68K_REG_SR, - M68K_REG_PC, + UC_M68K_REG_SR, + 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; #ifdef __cplusplus diff --git a/qemu/target-m68k/unicorn.c b/qemu/target-m68k/unicorn.c index 45cc3a65..e765d909 100644 --- a/qemu/target-m68k/unicorn.c +++ b/qemu/target-m68k/unicorn.c @@ -38,14 +38,14 @@ int m68k_reg_read(uch handle, unsigned int regid, void *value) struct uc_struct *uc = (struct uc_struct *)handle; CPUState *mycpu = first_cpu; - if (regid >= M68K_REG_A0 && regid <= M68K_REG_A7) - *(int32_t *)value = M68K_CPU(uc, mycpu)->env.aregs[regid - M68K_REG_A0]; - else if (regid >= M68K_REG_D0 && regid <= M68K_REG_D7) - *(int32_t *)value = M68K_CPU(uc, mycpu)->env.dregs[regid - M68K_REG_D0]; + if (regid >= UC_M68K_REG_A0 && regid <= UC_M68K_REG_A7) + *(int32_t *)value = M68K_CPU(uc, mycpu)->env.aregs[regid - UC_M68K_REG_A0]; + else if (regid >= UC_M68K_REG_D0 && regid <= UC_M68K_REG_D7) + *(int32_t *)value = M68K_CPU(uc, mycpu)->env.dregs[regid - UC_M68K_REG_D0]; else { switch(regid) { default: break; - case M68K_REG_PC: + case UC_M68K_REG_PC: *(int32_t *)value = M68K_CPU(uc, mycpu)->env.pc; break; } @@ -65,14 +65,14 @@ int m68k_reg_write(uch handle, unsigned int regid, void *value) struct uc_struct *uc = (struct uc_struct *) handle; CPUState *mycpu = first_cpu; - if (regid >= M68K_REG_A0 && regid <= M68K_REG_A7) - M68K_CPU(uc, mycpu)->env.aregs[regid - M68K_REG_A0] = *(int32_t *)value; - else if (regid >= M68K_REG_D0 && regid <= M68K_REG_D7) - M68K_CPU(uc, mycpu)->env.dregs[regid - M68K_REG_D0] = *(int32_t *)value; + if (regid >= UC_M68K_REG_A0 && regid <= UC_M68K_REG_A7) + M68K_CPU(uc, mycpu)->env.aregs[regid - UC_M68K_REG_A0] = *(int32_t *)value; + else if (regid >= UC_M68K_REG_D0 && regid <= UC_M68K_REG_D7) + M68K_CPU(uc, mycpu)->env.dregs[regid - UC_M68K_REG_D0] = *(int32_t *)value; else { switch(regid) { default: break; - case M68K_REG_PC: + case UC_M68K_REG_PC: M68K_CPU(uc, mycpu)->env.pc = *(uint32_t *)value; break; } diff --git a/samples/sample_m68k.c b/samples/sample_m68k.c index d1f5e469..02452e5d 100644 --- a/samples/sample_m68k.c +++ b/samples/sample_m68k.c @@ -66,26 +66,26 @@ static void test_m68k(void) uc_mem_write(handle, ADDRESS, (uint8_t *)M68K_CODE, sizeof(M68K_CODE) - 1); // initialize machine registers - uc_reg_write(handle, M68K_REG_D0, &d0); - uc_reg_write(handle, M68K_REG_D1, &d1); - uc_reg_write(handle, M68K_REG_D2, &d2); - uc_reg_write(handle, M68K_REG_D3, &d3); - uc_reg_write(handle, M68K_REG_D4, &d4); - uc_reg_write(handle, M68K_REG_D5, &d5); - uc_reg_write(handle, M68K_REG_D6, &d6); - uc_reg_write(handle, M68K_REG_D7, &d7); + uc_reg_write(handle, UC_M68K_REG_D0, &d0); + uc_reg_write(handle, UC_M68K_REG_D1, &d1); + uc_reg_write(handle, UC_M68K_REG_D2, &d2); + uc_reg_write(handle, UC_M68K_REG_D3, &d3); + uc_reg_write(handle, UC_M68K_REG_D4, &d4); + uc_reg_write(handle, UC_M68K_REG_D5, &d5); + uc_reg_write(handle, UC_M68K_REG_D6, &d6); + uc_reg_write(handle, UC_M68K_REG_D7, &d7); - uc_reg_write(handle, M68K_REG_A0, &a0); - uc_reg_write(handle, M68K_REG_A1, &a1); - uc_reg_write(handle, M68K_REG_A2, &a2); - uc_reg_write(handle, M68K_REG_A3, &a3); - uc_reg_write(handle, M68K_REG_A4, &a4); - uc_reg_write(handle, M68K_REG_A5, &a5); - uc_reg_write(handle, M68K_REG_A6, &a6); - uc_reg_write(handle, M68K_REG_A7, &a7); + uc_reg_write(handle, UC_M68K_REG_A0, &a0); + uc_reg_write(handle, UC_M68K_REG_A1, &a1); + uc_reg_write(handle, UC_M68K_REG_A2, &a2); + uc_reg_write(handle, UC_M68K_REG_A3, &a3); + uc_reg_write(handle, UC_M68K_REG_A4, &a4); + uc_reg_write(handle, UC_M68K_REG_A5, &a5); + uc_reg_write(handle, UC_M68K_REG_A6, &a6); + uc_reg_write(handle, UC_M68K_REG_A7, &a7); - uc_reg_write(handle, M68K_REG_PC, &pc); - uc_reg_write(handle, M68K_REG_SR, &sr); + uc_reg_write(handle, UC_M68K_REG_PC, &pc); + uc_reg_write(handle, UC_M68K_REG_SR, &sr); // tracing all basic blocks with customized callback 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 printf(">>> Emulation done. Below is the CPU context\n"); - uc_reg_read(handle, M68K_REG_D0, &d0); - uc_reg_read(handle, M68K_REG_D1, &d1); - uc_reg_read(handle, M68K_REG_D2, &d2); - uc_reg_read(handle, M68K_REG_D3, &d3); - uc_reg_read(handle, M68K_REG_D4, &d4); - uc_reg_read(handle, M68K_REG_D5, &d5); - uc_reg_read(handle, M68K_REG_D6, &d6); - uc_reg_read(handle, M68K_REG_D7, &d7); + uc_reg_read(handle, UC_M68K_REG_D0, &d0); + uc_reg_read(handle, UC_M68K_REG_D1, &d1); + uc_reg_read(handle, UC_M68K_REG_D2, &d2); + uc_reg_read(handle, UC_M68K_REG_D3, &d3); + uc_reg_read(handle, UC_M68K_REG_D4, &d4); + uc_reg_read(handle, UC_M68K_REG_D5, &d5); + uc_reg_read(handle, UC_M68K_REG_D6, &d6); + uc_reg_read(handle, UC_M68K_REG_D7, &d7); - uc_reg_read(handle, M68K_REG_A0, &a0); - uc_reg_read(handle, M68K_REG_A1, &a1); - uc_reg_read(handle, M68K_REG_A2, &a2); - uc_reg_read(handle, M68K_REG_A3, &a3); - uc_reg_read(handle, M68K_REG_A4, &a4); - uc_reg_read(handle, M68K_REG_A5, &a5); - uc_reg_read(handle, M68K_REG_A6, &a6); - uc_reg_read(handle, M68K_REG_A7, &a7); + uc_reg_read(handle, UC_M68K_REG_A0, &a0); + uc_reg_read(handle, UC_M68K_REG_A1, &a1); + uc_reg_read(handle, UC_M68K_REG_A2, &a2); + uc_reg_read(handle, UC_M68K_REG_A3, &a3); + uc_reg_read(handle, UC_M68K_REG_A4, &a4); + uc_reg_read(handle, UC_M68K_REG_A5, &a5); + uc_reg_read(handle, UC_M68K_REG_A6, &a6); + uc_reg_read(handle, UC_M68K_REG_A7, &a7); - uc_reg_read(handle, M68K_REG_PC, &pc); - uc_reg_read(handle, M68K_REG_SR, &sr); + uc_reg_read(handle, UC_M68K_REG_PC, &pc); + uc_reg_read(handle, UC_M68K_REG_SR, &sr); printf(">>> A0 = 0x%x\t\t>>> D0 = 0x%x\n", a0, d0); printf(">>> A1 = 0x%x\t\t>>> D1 = 0x%x\n", a1, d1); diff --git a/uc.c b/uc.c index 398701fe..ec337d36 100644 --- a/uc.c +++ b/uc.c @@ -415,7 +415,7 @@ uc_err uc_emu_start(uch handle, uint64_t begin, uint64_t until, uint64_t timeout break; case UC_ARCH_M68K: - uc_reg_write(handle, M68K_REG_PC, &begin); + uc_reg_write(handle, UC_M68K_REG_PC, &begin); break; case UC_ARCH_X86: