aboutsummaryrefslogtreecommitdiffstats
path: root/aarch64
diff options
context:
space:
mode:
authorHunter Kvalevog <hunter@kvog.sh>2026-10-28 16:05:43 -0500
committerHunter Kvalevog <hunter@kvog.sh>2026-10-28 16:06:50 -0500
commit5a0619780e4ae647307136f533d666be15bb9843 (patch)
tree017225eba0fe70a0e0c24eef35d3cfb73d7e9812 /aarch64
parent20b5138d377f81aa642c2537c64ff711ff954157 (diff)
downloaddemos-5a0619780e4ae647307136f533d666be15bb9843.tar.gz
demos-5a0619780e4ae647307136f533d666be15bb9843.zip
aarch64 -> arm64
Diffstat (limited to 'aarch64')
-rw-r--r--aarch64/kusswurm_ch11.S145
-rw-r--r--aarch64/kusswurm_ch11.c87
-rw-r--r--aarch64/kusswurm_ch12.S97
-rw-r--r--aarch64/kusswurm_ch12.c42
-rw-r--r--aarch64/mariokartwii_ch07.S46
-rw-r--r--aarch64/mariokartwii_ch08.S38
-rw-r--r--aarch64/meson.build6
7 files changed, 0 insertions, 461 deletions
diff --git a/aarch64/kusswurm_ch11.S b/aarch64/kusswurm_ch11.S
deleted file mode 100644
index 16cc840..0000000
--- a/aarch64/kusswurm_ch11.S
+++ /dev/null
@@ -1,145 +0,0 @@
-// ================================================================================================
-// Code written while reading chapter 11 of Modern Arm Assembly Language Programming
-//
-// License:
-// Copyright (c) 2026 Hunter Kvalevog
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE.
-// ================================================================================================
-
-#include "../_/aarch64/common.S"
-
-TEXT_SEGMENT
-
-// example 1
-
-.global SYM(i32_add_sub)
-.global SYM(i64_add_sub)
-
-SYM(i32_add_sub):
- // w0: a
- // w1: b
- // w2: c
-#if 0
- add w3, w0, w1
- sub w0, w3, w2
-#else
- add w0, w0, w1
- sub w0, w0, w2
-#endif
- // w0: return
- ret
-
-SYM(i64_add_sub):
- // x0: a
- // x1: b
- // x2: c
- add x3, x0, x1
- sub x0, x3, x2
- // x0: return
- ret
-
-// example 2
-
-.global SYM(i32_mul)
-.global SYM(i32_mul_safe)
-
-SYM(i32_mul):
- // w0: a
- // w1: b
- mul w0, w0, w1
- // w0: return
- ret
-
-SYM(i32_mul_safe):
- // w0: a
- // w1: b
- smull x0, w0, w1
- // x0: ret
- ret
-
-// example 3
-
-.global SYM(i32_quo_rem)
-
-SYM(i32_quo_rem):
- // w0: num
- // w1: den
- // x2: *quo
- // x3: *den
-
- // calculate quotient
- sdiv w4, w0, w1
- str w4, [x2]
-
- // calculate remainder
- mul w5, w1, w4
- sub w6, w0, w5
- str w6, [x3]
-
- ret
-
-// example 4
-
-.global SYM(test_ldr1)
-
-SYM(test_ldr1):
- // w0: i
- // x1: j
- // x2: tab
-
- ldr w3, [x2, w0, uxtw #2] // tab[i] (32-bit index)
- ldr w4, [x2, x1, lsl #2] // tab[j] (64-bit index)
-
- add w0, w3, w4
-
- ret
-
-// example 5
-
-.global SYM(test_mov1)
-
-SYM(test_mov1):
- // x0: *out
-
- .equ BIGNUM,0xABCD1234
- .equ BIGNUM_LO16,((BIGNUM & 0x0000FFFF) >> 0)
- .equ BIGNUM_HI16,((BIGNUM & 0xFFFF0000) >> 16)
-
- mov w2, #BIGNUM_LO16
- movk w2, #BIGNUM_HI16, lsl 16
- str w2, [x0] // out[0] = w2
-
- movz w3, #BIGNUM_LO16, lsl 16
- str w3, [x0, #4] // out[1] = w3
-
- movz w4, 0x1234
- str w4, [x0, #8] // out[2] = w4
-
- ret
-
-// example 6
-
-.global SYM(test_shift1)
-
-SYM(test_shift1):
- // x0: *out
-
- ldr x9, [x0] // x9 = out[0]
- ldr x10, [x0, #4] // x10 = out[1]
- ldr x11, [x0, #8] // x11 = out[2]
-
- lsl x10, x9, x10
- lsr x11, x10, x11
-
- str x10, [x0, #4]
- str x11, [x0, #8]
-
- ret
-
-// skipping example 7 because it's very obvious
-
diff --git a/aarch64/kusswurm_ch11.c b/aarch64/kusswurm_ch11.c
deleted file mode 100644
index ec832f4..0000000
--- a/aarch64/kusswurm_ch11.c
+++ /dev/null
@@ -1,87 +0,0 @@
-// ================================================================================================
-// Code written while reading chapter 11 of Modern Arm Assembly Language Programming
-//
-// License:
-// Copyright (c) 2026 Hunter Kvalevog
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE.
-// ================================================================================================
-
-#include <inttypes.h>
-#include <stdint.h>
-#include <stdio.h>
-
-// example 1
-int32_t i32_add_sub(int32_t a, int32_t b, int32_t c);
-int64_t i64_add_sub(int64_t a, int64_t b, int64_t c);
-
-// example 2
-int32_t i32_mul(int32_t a, int32_t b);
-int64_t i32_mul_safe(int32_t a, int32_t b);
-
-// example 3
-void i32_quo_rem(int32_t num, int32_t den, int32_t *quo, int32_t *rem);
-
-// example 4
-int32_t test_ldr1(int32_t i, int64_t j, int32_t *tab);
-
-// example 5
-void test_mov1(uint32_t *tab);
-
-// example 6
-void test_shift1(uint32_t *tab);
-
-int main(int argc, const char* argv[])
-{
- (void)argc; (void)argv;
-#define X(FMT, CODE) printf(#CODE ": " FMT "\n", CODE)
-
- // example 1
- X("%d", i32_add_sub(5, 3, 1));
- X("%" PRId64, i64_add_sub(5, 3, 1));
-
- // example 2
- X("%d", i32_mul(5, 6));
- X("%d", i32_mul(2000000000, 4));
- X("%" PRId64, i32_mul_safe(5, 6));
- X("%" PRId64, i32_mul_safe(2000000000, 4));
-
-#undef X
-#define X(CODE) CODE; printf(#CODE ": quo=%d rem=%d\n", quo, rem)
-
- // example 3
- int32_t quo = 0;
- int32_t rem = 0;
- X(i32_quo_rem(6, 3, &quo, &rem));
- X(i32_quo_rem(7, 3, &quo, &rem));
-
-#undef X
-#define X(FMT, CODE) printf(#CODE ": " FMT "\n", CODE)
-
- // example 4
- int32_t tab[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
- X("%d", test_ldr1(0, 0, tab));
-
- // example 5
- uint32_t out[3] = { 0, 0, 0 };
- test_mov1(out);
- printf("test_mov1(out):\n");
- printf(" out[0] = 0x%X\n", out[0]);
- printf(" out[1] = 0x%X\n", out[1]);
- printf(" out[2] = 0x%X\n", out[2]);
-
- // example 6
- out[0] = 1; // starting val
- out[1] = 8; // shift left by
- out[2] = 4; // shift right by
- test_shift1(out);
- printf("test_shift1(out):\n");
- printf(" out[0] = 0x%X\n", out[0]);
- printf(" out[1] = 0x%X\n", out[1]);
- printf(" out[2] = 0x%X\n", out[2]);
-}
-
diff --git a/aarch64/kusswurm_ch12.S b/aarch64/kusswurm_ch12.S
deleted file mode 100644
index 0e321d3..0000000
--- a/aarch64/kusswurm_ch12.S
+++ /dev/null
@@ -1,97 +0,0 @@
-// ================================================================================================
-// Code written while reading chapter 12 of Modern Arm Assembly Language Programming
-//
-// License:
-// Copyright (c) 2026 Hunter Kvalevog
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE.
-// ================================================================================================
-
-#include "../_/aarch64/common.S"
-
-TEXT_SEGMENT
-
-// example 1
-
-.global SYM(test_sum10i32)
-
-SYM(test_sum10i32):
- // [w0, w7] = [a, h]
-
-#ifdef __APPLE__
- .equ STK_i, 0
- .equ STK_j, 4
-#else
- .equ STK_i, 0
- .equ STK_j, 8
-#endif
-
- ldr w8, [sp, STK_i]
- ldr w9, [sp, STK_j]
-
-#if 0
- add w0, w0, w1
- add w0, w0, w2
- add w0, w0, w3
- add w0, w0, w4
- add w0, w0, w5
- add w0, w0, w6
- add w0, w0, w7
- add w0, w0, w8
- add w0, w0, w9
-#else
- // better dependency chain:
- add w0, w0, w1
- add w2, w2, w3
- add w4, w4, w5
- add w6, w6, w7
- add w8, w8, w9
-
- add w0, w0, w2
- add w4, w4, w6
-
- add w0, w0, w4
- add w0, w0, w8
-#endif
-
- ret
-
-// example 2
-
-.global SYM(test_sum4i32)
-
-SYM(test_sum4i32):
- // w0: i1
- // w1: i2
- // w2: i3
- // w3: i4
-
- sub sp, sp, #32 // begin stack frame
- stp x29, x30, [sp, #0] // save fp/lr
- mov x29, sp // set frame pointer
- stp x19, x20, [sp, #16] // save x19/x20
-
- mov w19, w2 // w19 = i3
- mov w20, w3 // w20 = i4
-
- bl SYM(c_sum2i32) // w0 = i1 + i2
-
- mov w3, w0 // w3 = w0=(i1 + i2)
- mov w0, w19 // w0 = i3
- mov w1, w20 // w1 = i4
- mov w19, w3
- bl SYM(c_sum2i32) // w0 = i3 + i4
-
- mov w1, w19 // w1 = i1 + i2
- bl SYM(c_sum2i32) // w0 = i3 + i4 + i1 + i2
-
- ldp x19, x20, [sp, #16] // restore x19/x20
- ldp x29, x30, [sp, #0] // restore fp/lr
- add sp, sp, #32 // end stack frame
-
- ret
-
diff --git a/aarch64/kusswurm_ch12.c b/aarch64/kusswurm_ch12.c
deleted file mode 100644
index 2626f6d..0000000
--- a/aarch64/kusswurm_ch12.c
+++ /dev/null
@@ -1,42 +0,0 @@
-// ================================================================================================
-// Code written while reading chapter 12 of Modern Arm Assembly Language Programming
-//
-// License:
-// Copyright (c) 2026 Hunter Kvalevog
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE.
-// ================================================================================================
-
-#include <stdint.h>
-#include <stdio.h>
-
-// example 1
-int32_t test_sum10i32(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, int32_t f, int32_t g,
- int32_t h, int32_t i, int32_t j);
-
-// example 2
-int32_t test_sum4i32(int32_t i1, int32_t i2, int32_t i3, int32_t i4);
-
-int32_t c_sum2i32(int32_t i1, int32_t i2)
-{
- // make this function complicated
- printf("c_sum2i32(i1=%d, i2=%d)\n", i1, i2);
- return i1 + i2;
-}
-
-int main(int argc, const char* argv[])
-{
- (void)argc; (void)argv;
-#define X(FMT, CODE) printf(#CODE ": " FMT "\n", CODE)
-
- // example 1
- X("%d", test_sum10i32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
-
- // example 2
- X("%d", test_sum4i32(1, 2, 3, 4));
-}
-
diff --git a/aarch64/mariokartwii_ch07.S b/aarch64/mariokartwii_ch07.S
deleted file mode 100644
index fa1c082..0000000
--- a/aarch64/mariokartwii_ch07.S
+++ /dev/null
@@ -1,46 +0,0 @@
-// ================================================================================================
-// Code written while following chapter 7 of the MarioKart Wii ARM64 assembly tutorial:
-// https://mariokartwii.com/arm64/ch7.html
-//
-// License:
-// Copyright (c) 2026 Hunter Kvalevog
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE.
-// ================================================================================================
-
-#include "../_/aarch64/common.S"
-
-TEXT_SEGMENT
-
-.global SYM(main)
-
-SYM(main):
- // 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
-
diff --git a/aarch64/mariokartwii_ch08.S b/aarch64/mariokartwii_ch08.S
deleted file mode 100644
index f4b4cab..0000000
--- a/aarch64/mariokartwii_ch08.S
+++ /dev/null
@@ -1,38 +0,0 @@
-// ================================================================================================
-// Code written while following chapter 8 of the MarioKart Wii ARM64 assembly tutorial:
-// https://mariokartwii.com/arm64/ch8.html
-//
-// License:
-// Copyright (c) 2026 Hunter Kvalevog
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE.
-// ================================================================================================
-
-#include "../_/aarch64/common.S"
-
-TEXT_SEGMENT
-
-.global SYM(main)
-
-SYM(main):
- // move shift
- mov x0, #0xFFFFFFFFFFFFFFFF
- lsl x0, x0, #32
-
- mov x1, #0xFFFFFFFFFFFFFFFF
- movk x1, #0x1234, lsl 32
-
- mov x2, #0xFFFFFFFFFFFFFFFF
- movz x2, #0x1234, lsl 32
-
- mov x3, #0xFFFFFFFFFFFFFFFF
- movk x3, #0x1111, lsl 48
- movk x3, #0x2222, lsl 32
- movk x3, #0x3333, lsl 16
- movk x3, #0x4444
-
- brk #0 // (lldb) register read
diff --git a/aarch64/meson.build b/aarch64/meson.build
deleted file mode 100644
index f33a462..0000000
--- a/aarch64/meson.build
+++ /dev/null
@@ -1,6 +0,0 @@
-project('aarch64', 'c', default_options: [ 'warning_level=3' ])
-
-executable('kusswurm_ch11', [ 'kusswurm_ch11.c', 'kusswurm_ch11.S' ])
-executable('kusswurm_ch12', [ 'kusswurm_ch12.c', 'kusswurm_ch12.S' ])
-executable('mariokartwii_ch07', 'mariokartwii_ch07.S')
-executable('mariokartwii_ch08', 'mariokartwii_ch08.S')