aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHunter Kvalevog <hunter@kvog.sh>2026-10-12 17:51:31 -0500
committerHunter Kvalevog <hunter@kvog.sh>2026-10-16 18:56:17 -0500
commitb3b3aa1adeae48b2dc78db54fc740bbabf65a172 (patch)
treec19014c651b097a9ef93c5afb18ae3c4b60704ce
parent30bd024c5d8b9e194abee5ada95897c22eb54018 (diff)
downloaddemos-b3b3aa1adeae48b2dc78db54fc740bbabf65a172.tar.gz
demos-b3b3aa1adeae48b2dc78db54fc740bbabf65a172.zip
-rw-r--r--_common/aarch64/common.S5
-rw-r--r--aarch64/kusswurm_ch11.S21
-rw-r--r--aarch64/kusswurm_ch11.c13
3 files changed, 35 insertions, 4 deletions
diff --git a/_common/aarch64/common.S b/_common/aarch64/common.S
index ca263bc..616af28 100644
--- a/_common/aarch64/common.S
+++ b/_common/aarch64/common.S
@@ -11,11 +11,8 @@
// WITH REGARD TO THIS SOFTWARE.
// ================================================================================================
-#define CONCAT_(A, B) A ## B
-#define CONCAT(A, B) CONCAT_(A, B)
-
#ifdef __APPLE__
-# define SYM(LABEL) CONCAT(_, LABEL)
+# define SYM(LABEL) _##LABEL
# define TEXT_SEGMENT .section __TEXT,__text
#else
# define SYM(LABEL) LABEL
diff --git a/aarch64/kusswurm_ch11.S b/aarch64/kusswurm_ch11.S
index 9c10ae6..926decc 100644
--- a/aarch64/kusswurm_ch11.S
+++ b/aarch64/kusswurm_ch11.S
@@ -122,3 +122,24 @@ SYM(test_mov1):
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
index e9778f4..a5bb5d0 100644
--- a/aarch64/kusswurm_ch11.c
+++ b/aarch64/kusswurm_ch11.c
@@ -31,6 +31,9 @@ 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;
@@ -69,5 +72,15 @@ int main(int argc, const char* argv[])
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]);
}