blob: 22e0b6ba4d8dba1607c4d01561c8c526f74653de [file] [log] [blame]
Paul Sokolovskye85c3892013-12-30 03:38:32 +02001#ifdef __thumb2__
2/* thumb callee save: bx, bp, sp, r12, r14, r14, r15 */
Damien152568b2013-10-16 00:46:39 +01003
4 .syntax unified
5 .cpu cortex-m4
6 .thumb
7 .text
8 .align 2
9
Paul Sokolovskye85c3892013-12-30 03:38:32 +020010/* uint nlr_push(r0=nlr_buf_t *nlr) */
Damien152568b2013-10-16 00:46:39 +010011 .global nlr_push
12 .thumb
13 .thumb_func
14 .type nlr_push, %function
15nlr_push:
16 str lr, [r0, #8] @ store lr into nlr_buf
17 str r4, [r0, #12] @ store r4 into nlr_buf
18 str r5, [r0, #16] @ store r5 into nlr_buf
19 str r6, [r0, #20] @ store r6 into nlr_buf
20 str r7, [r0, #24] @ store r7 into nlr_buf
21 str r8, [r0, #28] @ store r8 into nlr_buf
22 str r9, [r0, #32] @ store r9 into nlr_buf
23 str r10, [r0, #36] @ store r10 into nlr_buf
24 str r11, [r0, #40] @ store r11 into nlr_buf
25 str r13, [r0, #44] @ store r13=sp into nlr_buf
26
27 ldr r3, .L2 @ load addr of nlr_top
28 ldr r2, [r3] @ load nlr_top
29 str r2, [r0] @ store nlr_top into nlr_buf
30 str r0, [r3] @ store nlr_buf into nlr_top (to link list)
31
32 movs r0, #0 @ return 0, normal return
33 bx lr @ return
34 .align 2
35.L2:
36 .word .LANCHOR0
37 .size nlr_push, .-nlr_push
38
39@ void nlr_pop()
40 .global nlr_pop
41 .thumb
42 .thumb_func
43 .type nlr_pop, %function
44nlr_pop:
45 ldr r3, .L5 @ load addr of nlr_top
46 ldr r2, [r3] @ load nlr_top
47 ldr r2, [r2] @ load prev nlr_buf
48 str r2, [r3] @ store prev nlr_buf to nlr_top (to unlink list)
49 bx lr @ return
50 .align 2
51.L5:
52 .word .LANCHOR0
53 .size nlr_pop, .-nlr_pop
54
Paul Sokolovskye85c3892013-12-30 03:38:32 +020055/* void nlr_jump(r0=uint val) */
Damien152568b2013-10-16 00:46:39 +010056 .global nlr_jump
57 .thumb
58 .thumb_func
59 .type nlr_jump, %function
60nlr_jump:
61 ldr r3, .L2 @ load addr of nlr_top
62 ldr r2, [r3] @ load nlr_top
63 str r0, [r2, #4] @ store return value
64 ldr r0, [r2] @ load prev nlr_buf
65 str r0, [r3] @ store prev nol_buf into nlr_top (to unlink list)
66
67 ldr lr, [r2, #8] @ load lr from nlr_buf
68 ldr r4, [r2, #12] @ load r4 from nlr_buf
69 ldr r5, [r2, #16] @ load r5 from nlr_buf
70 ldr r6, [r2, #20] @ load r6 from nlr_buf
71 ldr r7, [r2, #24] @ load r7 from nlr_buf
72 ldr r8, [r2, #28] @ load r8 from nlr_buf
73 ldr r9, [r2, #32] @ load r9 from nlr_buf
74 ldr r10, [r2, #36] @ load r10 from nlr_buf
75 ldr r11, [r2, #40] @ load r11 from nlr_buf
76 ldr r13, [r2, #44] @ load r13=sp from nlr_buf
77
78 movs r0, #1 @ return 1, non-local return
79 bx lr @ return
80 .align 2
81.L6:
82 .word .LANCHOR0
83 .size nlr_jump, .-nlr_jump
84
Paul Sokolovskye85c3892013-12-30 03:38:32 +020085/* local variable nlr_top */
Damien152568b2013-10-16 00:46:39 +010086 .bss
87 .align 2
88 .set .LANCHOR0,. + 0
89 .type nlr_top, %object
90 .size nlr_top, 4
91nlr_top:
92 .space 4
Paul Sokolovskye85c3892013-12-30 03:38:32 +020093#endif