aboutsummaryrefslogtreecommitdiffhomepage
path: root/targets/nintendoswitch.s
diff options
context:
space:
mode:
authorLucas Teske <[email protected]>2020-05-09 15:39:19 -0300
committerAyke <[email protected]>2020-07-31 00:58:09 +0200
commit3650c2c7397b5f21f61c1a4362b28596968c912f (patch)
tree7c331676822cb4109fb11967cea73e826f2bd138 /targets/nintendoswitch.s
parentd4e04e4e493aa4a99659361e28b22ecd51cceee3 (diff)
downloadtinygo-3650c2c7397b5f21f61c1a4362b28596968c912f.tar.gz
tinygo-3650c2c7397b5f21f61c1a4362b28596968c912f.zip
nintendoswitch: Add experimental Nintendo Switch support without CRT
Bare minimal nintendo switch support using LLD
Diffstat (limited to 'targets/nintendoswitch.s')
-rw-r--r--targets/nintendoswitch.s51
1 files changed, 51 insertions, 0 deletions
diff --git a/targets/nintendoswitch.s b/targets/nintendoswitch.s
new file mode 100644
index 000000000..8e36fe7a6
--- /dev/null
+++ b/targets/nintendoswitch.s
@@ -0,0 +1,51 @@
+.section .text.jmp, "x"
+.global _start
+_start:
+ b start
+ .word _mod_header - _start
+
+.section .data.mod0
+ .word 0, 8
+
+.global _mod_header
+_mod_header:
+ .ascii "MOD0"
+ .word __dynamic_start - _mod_header
+ .word __bss_start - _mod_header
+ .word __bss_end - _mod_header
+ .word 0, 0 // eh_frame_hdr start/end
+ .word 0 // runtime-generated module object offset
+
+.section .text, "x"
+.global start
+start:
+
+ // save lr
+ mov x7, x30
+
+ // get aslr base
+ bl +4
+ sub x6, x30, #0x88
+
+ // context ptr and main thread handle
+ mov x5, x0
+ mov x4, x1
+
+ // clear .bss
+ adrp x5, __bss_start
+ add x5, x5, #:lo12:__bss_start
+ adrp x6, __bss_end
+ add x6, x6, #:lo12:__bss_end
+
+bssloop:
+ cmp x5, x6
+ b.eq run
+ str xzr, [x5]
+ add x5, x5, 8
+ b bssloop
+
+run:
+ // call entrypoint
+ adrp x30, exit
+ add x30, x30, #:lo12:exit
+ b main