summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
Diffstat (limited to 'py')
-rw-r--r--py/asmx86.c6
-rw-r--r--py/asmx86.h8
-rw-r--r--py/emitnative.c6
3 files changed, 14 insertions, 6 deletions
diff --git a/py/asmx86.c b/py/asmx86.c
index 1946973bad..1570d9f7c0 100644
--- a/py/asmx86.c
+++ b/py/asmx86.c
@@ -496,13 +496,13 @@ void asm_x86_call_ind(asm_x86_t *as, void *ptr, mp_uint_t n_args, int temp_r32)
// TODO align stack on 16-byte boundary before the call
assert(n_args <= 3);
if (n_args > 2) {
- asm_x86_push_r32(as, REG_ARG_3);
+ asm_x86_push_r32(as, ASM_X86_REG_ARG_3);
}
if (n_args > 1) {
- asm_x86_push_r32(as, REG_ARG_2);
+ asm_x86_push_r32(as, ASM_X86_REG_ARG_2);
}
if (n_args > 0) {
- asm_x86_push_r32(as, REG_ARG_1);
+ asm_x86_push_r32(as, ASM_X86_REG_ARG_1);
}
#ifdef __LP64__
// We wouldn't run x86 code on an x64 machine. This is here to enable
diff --git a/py/asmx86.h b/py/asmx86.h
index 5af19cbf61..6099325c7e 100644
--- a/py/asmx86.h
+++ b/py/asmx86.h
@@ -44,6 +44,14 @@
#define REG_ESI (6)
#define REG_EDI (7)
+// x86 passes values on the stack, but the emitter is register based, so we need
+// to define registers that can temporarily hold the function arguments. They
+// need to be defined here so that asm_x86_call_ind can push them onto the stack
+// before the call.
+#define ASM_X86_REG_ARG_1 REG_EAX
+#define ASM_X86_REG_ARG_2 REG_ECX
+#define ASM_X86_REG_ARG_3 REG_EDX
+
// condition codes, used for jcc and setcc (despite their j-name!)
#define ASM_X86_CC_JB (0x2) // below, unsigned
#define ASM_X86_CC_JZ (0x4)
diff --git a/py/emitnative.c b/py/emitnative.c
index 685c6177e7..078ad5fc1e 100644
--- a/py/emitnative.c
+++ b/py/emitnative.c
@@ -200,9 +200,9 @@ STATIC byte mp_f_n_args[MP_F_NUMBER_OF] = {
#define EXPORT_FUN(name) emit_native_x86_##name
#define REG_RET REG_EAX
-#define REG_ARG_1 REG_EAX
-#define REG_ARG_2 REG_ECX
-#define REG_ARG_3 REG_EDX
+#define REG_ARG_1 ASM_X86_REG_ARG_1
+#define REG_ARG_2 ASM_X86_REG_ARG_2
+#define REG_ARG_3 ASM_X86_REG_ARG_3
// caller-save, so can be used as temporaries
#define REG_TEMP0 REG_EAX