Skip to content

Commit ac9e846

Browse files
authored
Merge pull request adafruit#10805 from dhalbert/nlrthumb-clobbers
py/nlrthumb.c: restore r1,r2,r3 clobbers to nlr_push(); fixes many Thonny issues
2 parents 726edf7 + b975d1d commit ac9e846

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

ports/atmel-samd/peripherals

py/nlrthumb.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@
3636
// For reference, arm/thumb callee save regs are:
3737
// r4-r11, r13=sp
3838

39-
// CIRCUITPY-CHANGE: added returns_twice
40-
__attribute__((naked, returns_twice)) unsigned int nlr_push(nlr_buf_t *nlr) {
39+
__attribute__((naked)) unsigned int nlr_push(nlr_buf_t *nlr) {
4140

4241
// If you get a linker error here, indicating that a relocation doesn't
4342
// fit, try the following (in that order):
@@ -92,6 +91,10 @@ __attribute__((naked, returns_twice)) unsigned int nlr_push(nlr_buf_t *nlr) {
9291
"b nlr_push_tail \n" // do the rest in C
9392
#endif
9493
#endif
94+
// CIRCUITPY-CHANGE: add input and clobbers to prevent smashing registers.
95+
: // output operands
96+
: "r" (nlr) // input operands
97+
: "r1", "r2", "r3" // clobbers
9598
);
9699

97100
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8))
@@ -141,7 +144,8 @@ NORETURN void nlr_jump(void *val) {
141144
"bx lr \n" // return
142145
: // output operands
143146
: "r" (top) // input operands
144-
: "memory" // clobbered registers
147+
// CIRCUITPY-CHANGE: better comment
148+
: "memory" // clobbers
145149
);
146150

147151
MP_UNREACHABLE

0 commit comments

Comments
 (0)