summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
Diffstat (limited to 'py')
-rw-r--r--py/nlrthumb.S26
-rw-r--r--py/nlrx64.S60
-rw-r--r--py/nlrx86.S24
3 files changed, 86 insertions, 24 deletions
diff --git a/py/nlrthumb.S b/py/nlrthumb.S
index dabf57cf85..5443edfe84 100644
--- a/py/nlrthumb.S
+++ b/py/nlrthumb.S
@@ -25,7 +25,12 @@
*/
#if !MICROPY_NLR_SETJMP && (defined(__thumb2__) || defined(__thumb__) || defined(__arm__))
-/* arm callee save: bx, bp, sp, r12, r14, r14, r15 */
+
+// We only need the functions here if we are on arm/thumb, and we are not
+// using setjmp/longjmp.
+//
+// For reference, arm/thumb callee save regs are:
+// r4-r11, r13=sp
.syntax unified
/*.cpu cortex-m4*/
@@ -33,7 +38,9 @@
.text
.align 2
-/* uint nlr_push(r0=nlr_buf_t *nlr) */
+/**************************************/
+// mp_uint_t nlr_push(r0=nlr_buf_t *nlr)
+
.global nlr_push
#if defined(__thumb2__)
.thumb
@@ -64,7 +71,9 @@ nlr_push:
.word .LANCHOR0
.size nlr_push, .-nlr_push
-@ void nlr_pop()
+/**************************************/
+// void nlr_pop()
+
.global nlr_pop
#if defined(__thumb2__)
.thumb
@@ -82,7 +91,9 @@ nlr_pop:
.word .LANCHOR0
.size nlr_pop, .-nlr_pop
-/* void nlr_jump(r0=uint val) */
+/**************************************/
+// void nlr_jump(r0=mp_uint_t val)
+
.global nlr_jump
#if defined(__thumb2__)
.thumb
@@ -116,7 +127,9 @@ nlr_jump:
.word .LANCHOR0
.size nlr_jump, .-nlr_jump
-/* local variable nlr_top */
+/**************************************/
+// local variable nlr_top
+
.bss
.align 2
.set .LANCHOR0,. + 0
@@ -124,4 +137,5 @@ nlr_jump:
.size nlr_top, 4
nlr_top:
.space 4
-#endif
+
+#endif // !MICROPY_NLR_SETJMP && (defined(__thumb2__) || defined(__thumb__) || defined(__arm__))
diff --git a/py/nlrx64.S b/py/nlrx64.S
index baed6cabd6..d00102050b 100644
--- a/py/nlrx64.S
+++ b/py/nlrx64.S
@@ -25,18 +25,28 @@
*/
#if defined(__x86_64__) && !MICROPY_NLR_SETJMP
-/* x64 callee save: bx, bp, sp, r12, r13, r14, r15 */
+
+// We only need the functions here if we are on x86-64, and we are not
+// using setjmp/longjmp.
+//
+// For reference, x86-64 callee save regs are:
+// rbx, rbp, rsp, r12, r13, r14, r15
.file "nlr.s"
.text
#if !defined(__CYGWIN__)
-#if (defined(__APPLE__) && defined(__MACH__))
-#define nlr_jump_fail _nlr_jump_fail
-#endif // (defined(__APPLE__) && defined(__MACH__))
+/******************************************************************************/
+//
+// Functions for *nix and OSX.
+// OSX needs _ prefix for binding to C, and doesn't support some directives.
+//
+/******************************************************************************/
+
+/**************************************/
+// mp_uint_t nlr_push(rdi=nlr_buf_t *nlr)
-/* uint nlr_push(rdi=nlr_buf_t *nlr) */
#if !(defined(__APPLE__) && defined(__MACH__))
.globl nlr_push
.type nlr_push, @function
@@ -63,7 +73,9 @@ _nlr_push:
.size nlr_push, .-nlr_push
#endif
-/* void nlr_pop() */
+/**************************************/
+// void nlr_pop()
+
#if !(defined(__APPLE__) && defined(__MACH__))
.globl nlr_pop
.type nlr_pop, @function
@@ -80,7 +92,9 @@ _nlr_pop:
.size nlr_pop, .-nlr_pop
#endif
-/* void nlr_jump(rdi=uint val) */
+/**************************************/
+// void nlr_jump(rdi=mp_uint_t val)
+
#if !(defined(__APPLE__) && defined(__MACH__))
.globl nlr_jump
.type nlr_jump, @function
@@ -110,20 +124,33 @@ nlr_jump:
ret # return
.fail:
movq %rax, %rdi # put argument back in first-arg register
- je nlr_jump_fail # transfer control to nlr_jump_fail
#if !(defined(__APPLE__) && defined(__MACH__))
+ je nlr_jump_fail # transfer control to nlr_jump_fail
.size nlr_jump, .-nlr_jump
+#else
+ je _nlr_jump_fail # transfer control to nlr_jump_fail
#endif
- .bss
+/**************************************/
+// local variable nlr_top
+
#if !(defined(__APPLE__) && defined(__MACH__))
+ .bss
.local nlr_top
#endif
.comm nlr_top,8,8
#else // !defined(__CYGWIN__)
-/* uint nlr_push(rcx=nlr_buf_t *nlr) */
+/******************************************************************************/
+//
+// Functions for Cygwin
+//
+/******************************************************************************/
+
+/**************************************/
+// mp_uint_t nlr_push(rcx=nlr_buf_t *nlr)
+
.globl nlr_push
nlr_push:
movq (%rsp), %rax # load return %rip
@@ -143,7 +170,9 @@ nlr_push:
xorq %rax, %rax # return 0, normal return
ret # return
-/* void nlr_pop() */
+/**************************************/
+// void nlr_pop()
+
.globl nlr_pop
nlr_pop:
movq nlr_top(%rip), %rax # get nlr_top into %rax
@@ -151,7 +180,9 @@ nlr_pop:
movq %rax, nlr_top(%rip) # store prev nlr_buf (to unlink list)
ret # return
-/* void nlr_jump(rcx=uint val) */
+/**************************************/
+// void nlr_jump(rcx=mp_uint_t val)
+
.globl nlr_jump
nlr_jump:
movq %rcx, %rax # put return value in %rax
@@ -179,9 +210,12 @@ nlr_jump:
movq %rax, %rcx # put argument back in first-arg register
je nlr_jump_fail # transfer control to nlr_jump_fail
+/**************************************/
+// local variable nlr_top
+
.bss
.comm nlr_top,8,8
#endif // !defined(__CYGWIN__)
-#endif // __x86_64__
+#endif // defined(__x86_64__) && !MICROPY_NLR_SETJMP
diff --git a/py/nlrx86.S b/py/nlrx86.S
index 6d3b855fcc..8ce93f227b 100644
--- a/py/nlrx86.S
+++ b/py/nlrx86.S
@@ -25,12 +25,19 @@
*/
#if defined(__i386__) && !MICROPY_NLR_SETJMP
-/* x86 callee save: bx, di, si, bp, sp */
+
+// We only need the functions here if we are on x86, and we are not
+// using setjmp/longjmp.
+//
+// For reference, x86 callee save regs are:
+// ebx, esi, edi, ebp, esp, eip
.file "nlr.s"
.text
-/* uint nlr_push(4(%esp)=nlr_buf_t *nlr) */
+/**************************************/
+// mp_uint_t nlr_push(4(%esp)=nlr_buf_t *nlr)
+
#ifdef _WIN32
.globl _nlr_push
.def _nlr_push; .scl 2; .type 32; .endef
@@ -57,7 +64,9 @@ nlr_push:
.size nlr_push, .-nlr_push
#endif
-/* void nlr_pop() */
+/**************************************/
+// void nlr_pop()
+
#ifdef _WIN32
.globl _nlr_pop
.def _nlr_pop; .scl 2; .type 32; .endef
@@ -75,7 +84,9 @@ nlr_pop:
.size nlr_pop, .-nlr_pop
#endif
-/* void nlr_jump(4(%esp)=uint val) */
+/**************************************/
+// void nlr_jump(4(%esp)=mp_uint_t val)
+
#ifdef _WIN32
.globl _nlr_jump
.def _nlr_jump; .scl 2; .type 32; .endef
@@ -110,10 +121,13 @@ nlr_jump:
.size nlr_jump, .-nlr_jump
#endif
+/**************************************/
+// local variable nlr_top
+
.bss
#ifndef _WIN32
.local nlr_top
#endif
.comm nlr_top,4,4
-#endif /* __i386__ */
+#endif // defined(__i386__) && !MICROPY_NLR_SETJMP