11/ *
2- * This file is part of the Micro Python project, http://micropython.org/
2+ * This file is part of the MicroPython project , http://micropython.org/
33 *
44 * The MIT License (MIT)
55 *
6- * Copyright (c) 2013, 2014 Damien P. George
6+ * Copyright (c) 2013 - 2015 Damien P. George
77 *
88 * Permission is hereby granted , free of charge , to any person obtaining a copy
99 * of this software and associated documentation files (the "Software" ) , to deal
5151#endif
5252 .type nlr_push , %function
5353nlr_push:
54- str lr, [r0, #8] @ store lr into nlr_buf
5554 str r4 , [ r0 , # 12 ] @ store r4 into nlr_buf
5655 str r5 , [ r0 , # 16 ] @ store r5 into nlr_buf
5756 str r6 , [ r0 , # 20 ] @ store r6 into nlr_buf
5857 str r7 , [ r0 , # 24 ] @ store r7 into nlr_buf
58+
59+ #if defined(__ARM_ARCH_6M__)
60+ mov r1 , r8
61+ str r1 , [ r0 , # 28 ] @ store r8 into nlr_buf
62+ mov r1 , r9
63+ str r1 , [ r0 , # 32 ] @ store r9 into nlr_buf
64+ mov r1 , r10
65+ str r1 , [ r0 , # 36 ] @ store r10 into nlr_buf
66+ mov r1 , r11
67+ str r1 , [ r0 , # 40 ] @ store r11 into nlr_buf
68+ mov r1 , r13
69+ str r1 , [ r0 , # 44 ] @ store r13 = sp into nlr_buf
70+ mov r1 , lr
71+ str r1 , [ r0 , # 8 ] @ store lr into nlr_buf
72+ #else
5973 str r8 , [ r0 , # 28 ] @ store r8 into nlr_buf
6074 str r9 , [ r0 , # 32 ] @ store r9 into nlr_buf
6175 str r10 , [ r0 , # 36 ] @ store r10 into nlr_buf
6276 str r11 , [ r0 , # 40 ] @ store r11 into nlr_buf
6377 str r13 , [ r0 , # 44 ] @ store r13 = sp into nlr_buf
78+ str lr , [ r0 , # 8 ] @ store lr into nlr_buf
79+ #endif
6480
6581 ldr r3 , nlr_top_addr @ load addr of nlr_top
6682 ldr r2 , [ r3 ] @ load nlr_top
@@ -69,9 +85,6 @@ nlr_push:
6985
7086 movs r0 , # 0 @ return 0 , normal return
7187 bx lr @ return
72- .align 2
73- nlr_top_addr:
74- .word mp_state_ctx + NLR_TOP_OFFSET
7588 .size nlr_push , . - nlr_push
7689
7790/ ************************************** /
@@ -104,24 +117,49 @@ nlr_jump:
104117 ldr r3 , nlr_top_addr @ load addr of nlr_top
105118 ldr r2 , [ r3 ] @ load nlr_top
106119 cmp r2 , # 0 @ test if nlr_top is NULL
120+ #if defined(__ARM_ARCH_6M__)
121+ bne nlr_jump_non_null @ if nlr_top is NULL , transfer control to nlr_jump_fail
122+ bl nlr_jump_fail
123+ nlr_jump_non_null:
124+ #else
107125 beq nlr_jump_fail @ if nlr_top is NULL , transfer control to nlr_jump_fail
126+ #endif
108127 str r0 , [ r2 , # 4 ] @ store return value
109128 ldr r0 , [ r2 ] @ load prev nlr_buf
110129 str r0 , [ r3 ] @ store prev nol_buf into nlr_top (to unlink list)
111130
112- ldr lr, [r2, #8] @ load lr from nlr_buf
113131 ldr r4 , [ r2 , # 12 ] @ load r4 from nlr_buf
114132 ldr r5 , [ r2 , # 16 ] @ load r5 from nlr_buf
115133 ldr r6 , [ r2 , # 20 ] @ load r6 from nlr_buf
116134 ldr r7 , [ r2 , # 24 ] @ load r7 from nlr_buf
135+ #if defined(__ARM_ARCH_6M__)
136+ ldr r1 , [ r2 , # 28 ] @ load r8 from nlr_buf
137+ mov r8 , r1
138+ ldr r1 , [ r2 , # 32 ] @ load r9 from nlr_buf
139+ mov r9 , r1
140+ ldr r1 , [ r2 , # 36 ] @ load r10 from nlr_buf
141+ mov r10 , r1
142+ ldr r1 , [ r2 , # 40 ] @ load r11 from nlr_buf
143+ mov r11 , r1
144+ ldr r1 , [ r2 , # 44 ] @ load r13 = sp from nlr_buf
145+ mov r13 , r1
146+ ldr r1 , [ r2 , # 8 ] @ load lr from nlr_buf
147+ mov lr , r1
148+ #else
117149 ldr r8 , [ r2 , # 28 ] @ load r8 from nlr_buf
118150 ldr r9 , [ r2 , # 32 ] @ load r9 from nlr_buf
119151 ldr r10 , [ r2 , # 36 ] @ load r10 from nlr_buf
120152 ldr r11 , [ r2 , # 40 ] @ load r11 from nlr_buf
121153 ldr r13 , [ r2 , # 44 ] @ load r13 = sp from nlr_buf
154+ ldr lr , [ r2 , # 8 ] @ load lr from nlr_buf
155+ #endif
122156
123157 movs r0 , # 1 @ return 1 , non - local return
124158 bx lr @ return
125159 .size nlr_jump , . - nlr_jump
126160
161+ . align 2
162+ nlr_top_addr:
163+ . word mp_state_ctx + NLR_TOP_OFFSET
164+
127165#endif // (!defined(MICROPY_NLR_SETJMP) || !MICROPY_NLR_SETJMP) && (defined(__thumb2__) || defined(__thumb__) || defined(__arm__))
0 commit comments