summaryrefslogtreecommitdiff
path: root/aarch64/mariokartwii_ch07.S
diff options
context:
space:
mode:
Diffstat (limited to 'aarch64/mariokartwii_ch07.S')
-rw-r--r--aarch64/mariokartwii_ch07.S41
1 files changed, 41 insertions, 0 deletions
diff --git a/aarch64/mariokartwii_ch07.S b/aarch64/mariokartwii_ch07.S
new file mode 100644
index 0000000..ce3a3f5
--- /dev/null
+++ b/aarch64/mariokartwii_ch07.S
@@ -0,0 +1,41 @@
+// https://mariokartwii.com/arm64/ch7.html
+
+.section __TEXT,__text
+.global _main
+
+_main:
+ // Save stack frame
+ stp x29, x30, [sp, #-16]!
+ mov x29, sp
+
+ // Add
+ mov x0, #1
+ mov x1, #2
+ add x2, x0, x1
+
+ // Add immediate
+ add x3, x2, #0x100
+
+ // Subtract immediate
+ mov x4, x3
+ sub x4, x4, #0x100
+
+ // Multiply
+ mov x5, #5
+ mul x5, x4, x5
+
+ // Divide
+ udiv x6, x5, x4
+ mov x7, #-1
+ sdiv x7, x6, x7
+
+ neg x8, x7
+
+ brk #0 // (lldb) register read
+
+ // Restore stack frame
+ ldp x29, x30, [sp], #16
+
+ // Return 0
+ mov x0, #0
+ ret