Skip to content

Commit ceeba52

Browse files
niaowdeadprogram
authored andcommitted
runtime: copy stack scan assembly for GBA
The GC stack scanning code was implemented in the Cortex-M assembly, which meant that it was not available on the GBA which is pre-cortex. This change adds a copy of the relevant code into a new asembly file which is used on the GBA.
1 parent 16c2d84 commit ceeba52

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/runtime/scheduler_gba.S

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.section .text.tinygo_scanCurrentStack
2+
.global tinygo_scanCurrentStack
3+
.type tinygo_scanCurrentStack, %function
4+
tinygo_scanCurrentStack:
5+
// Save callee-saved registers onto the stack.
6+
mov r0, r8
7+
mov r1, r9
8+
mov r2, r10
9+
mov r3, r11
10+
push {r0-r3, lr}
11+
push {r4-r7}
12+
13+
// Scan the stack.
14+
mov r0, sp
15+
bl tinygo_scanstack
16+
17+
// Restore stack state and return.
18+
add sp, #32
19+
pop {pc}

targets/gameboy-advance.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
],
2626
"linkerscript": "targets/gameboy-advance.ld",
2727
"extra-files": [
28-
"targets/gameboy-advance.s"
28+
"targets/gameboy-advance.s",
29+
"src/runtime/scheduler_gba.S"
2930
],
3031
"gdb": "gdb-multiarch",
3132
"emulator": ["mgba", "-3"]

0 commit comments

Comments
 (0)