summaryrefslogtreecommitdiff
path: root/py/emitnative.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/emitnative.c')
-rw-r--r--py/emitnative.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/py/emitnative.c b/py/emitnative.c
index 7d856e13f..f846e8bb4 100644
--- a/py/emitnative.c
+++ b/py/emitnative.c
@@ -288,6 +288,11 @@ struct _emit_t {
ASM_T *as;
};
+#ifndef REG_ZERO
+#define REG_ZERO REG_TEMP0
+#define ASM_CLR_REG(state, rd) ASM_XOR_REG_REG(state, rd, rd)
+#endif
+
static void emit_load_reg_with_object(emit_t *emit, int reg, mp_obj_t obj);
static void emit_native_global_exc_entry(emit_t *emit);
static void emit_native_global_exc_exit(emit_t *emit);
@@ -1200,12 +1205,12 @@ static void emit_native_global_exc_entry(emit_t *emit) {
ASM_JUMP_IF_REG_ZERO(emit->as, REG_RET, start_label, true);
} else {
// Clear the unwind state
- ASM_XOR_REG_REG(emit->as, REG_TEMP0, REG_TEMP0);
- ASM_MOV_LOCAL_REG(emit->as, LOCAL_IDX_EXC_HANDLER_UNWIND(emit), REG_TEMP0);
+ ASM_CLR_REG(emit->as, REG_ZERO);
+ ASM_MOV_LOCAL_REG(emit->as, LOCAL_IDX_EXC_HANDLER_UNWIND(emit), REG_ZERO);
// clear nlr.ret_val, because it's passed to mp_native_raise regardless
// of whether there was an exception or not
- ASM_MOV_LOCAL_REG(emit->as, LOCAL_IDX_EXC_VAL(emit), REG_TEMP0);
+ ASM_MOV_LOCAL_REG(emit->as, LOCAL_IDX_EXC_VAL(emit), REG_ZERO);
// Put PC of start code block into REG_LOCAL_1
ASM_MOV_REG_PCREL(emit->as, REG_LOCAL_1, start_label);
@@ -1221,8 +1226,8 @@ static void emit_native_global_exc_entry(emit_t *emit) {
ASM_JUMP_IF_REG_NONZERO(emit->as, REG_RET, global_except_label, true);
// Clear PC of current code block, and jump there to resume execution
- ASM_XOR_REG_REG(emit->as, REG_TEMP0, REG_TEMP0);
- ASM_MOV_LOCAL_REG(emit->as, LOCAL_IDX_EXC_HANDLER_PC(emit), REG_TEMP0);
+ ASM_CLR_REG(emit->as, REG_ZERO);
+ ASM_MOV_LOCAL_REG(emit->as, LOCAL_IDX_EXC_HANDLER_PC(emit), REG_ZERO);
ASM_JUMP_REG(emit->as, REG_LOCAL_1);
// Global exception handler: check for valid exception handler