Skip to content

Commit a96cc82

Browse files
committed
py: Support arm and thumb ARM ISAs, in addition to thumb2.
These changes were tested with QEMU, and by few people of real hardware.
1 parent 59c675a commit a96cc82

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

py/nlr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct _nlr_buf_t {
4545
#else
4646
void *regs[8];
4747
#endif
48-
#elif defined(__thumb2__)
48+
#elif defined(__thumb2__) || defined(__thumb__) || defined(__arm__)
4949
void *regs[10];
5050
#else
5151
#define MICROPY_NLR_SETJMP (1)

py/nlrthumb.S

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,21 @@
2424
* THE SOFTWARE.
2525
*/
2626

27-
#if defined(__thumb2__) && !MICROPY_NLR_SETJMP
28-
/* thumb callee save: bx, bp, sp, r12, r14, r14, r15 */
27+
#if !MICROPY_NLR_SETJMP && (defined(__thumb2__) || defined(__thumb__) || defined(__arm__))
28+
/* arm callee save: bx, bp, sp, r12, r14, r14, r15 */
2929

3030
.syntax unified
3131
/*.cpu cortex-m4*/
32-
.thumb
32+
/*.thumb*/
3333
.text
3434
.align 2
3535

3636
/* uint nlr_push(r0=nlr_buf_t *nlr) */
3737
.global nlr_push
38+
#if defined(__thumb2__)
3839
.thumb
3940
.thumb_func
41+
#endif
4042
.type nlr_push, %function
4143
nlr_push:
4244
str lr, [r0, #8] @ store lr into nlr_buf
@@ -64,8 +66,10 @@ nlr_push:
6466

6567
@ void nlr_pop()
6668
.global nlr_pop
69+
#if defined(__thumb2__)
6770
.thumb
6871
.thumb_func
72+
#endif
6973
.type nlr_pop, %function
7074
nlr_pop:
7175
ldr r3, .L5 @ load addr of nlr_top
@@ -80,8 +84,10 @@ nlr_pop:
8084

8185
/* void nlr_jump(r0=uint val) */
8286
.global nlr_jump
87+
#if defined(__thumb2__)
8388
.thumb
8489
.thumb_func
90+
#endif
8591
.type nlr_jump, %function
8692
nlr_jump:
8793
ldr r3, .L2 @ load addr of nlr_top

unix/gccollect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void gc_helper_get_regs(regs_t arr) {
9797
}
9898
#endif
9999

100-
#ifdef __thumb2__
100+
#if defined(__thumb2__) || defined(__thumb__) || defined(__arm__)
101101
typedef machine_uint_t regs_t[10];
102102

103103
void gc_helper_get_regs(regs_t arr) {

0 commit comments

Comments
 (0)