From 15239ba6cfe2279b5afebfd4f954bb5469c605f1 Mon Sep 17 00:00:00 2001 From: Hunter Kvalevog Date: Tue, 9 Jun 2026 17:45:45 -0500 Subject: --- aarch64/.gitignore | 1 + aarch64/common.S | 25 ++++++++++++++++++++++++ aarch64/mariokartwii_ch07.S | 47 +++++++++++++++++++++++++++++++++++++++++++++ aarch64/mariokartwii_ch08.S | 39 +++++++++++++++++++++++++++++++++++++ aarch64/run.sh | 4 ++++ arm64/.gitignore | 1 - arm64/common.S | 25 ------------------------ arm64/mariokartwii_ch07.S | 47 --------------------------------------------- arm64/mariokartwii_ch08.S | 39 ------------------------------------- arm64/run.sh | 4 ---- 10 files changed, 116 insertions(+), 116 deletions(-) create mode 100644 aarch64/.gitignore create mode 100644 aarch64/common.S create mode 100644 aarch64/mariokartwii_ch07.S create mode 100644 aarch64/mariokartwii_ch08.S create mode 100755 aarch64/run.sh delete mode 100644 arm64/.gitignore delete mode 100644 arm64/common.S delete mode 100644 arm64/mariokartwii_ch07.S delete mode 100644 arm64/mariokartwii_ch08.S delete mode 100755 arm64/run.sh diff --git a/aarch64/.gitignore b/aarch64/.gitignore new file mode 100644 index 0000000..1fcb152 --- /dev/null +++ b/aarch64/.gitignore @@ -0,0 +1 @@ +out diff --git a/aarch64/common.S b/aarch64/common.S new file mode 100644 index 0000000..34bb529 --- /dev/null +++ b/aarch64/common.S @@ -0,0 +1,25 @@ +// ================================================================================================ +// Shared macros +// +// License: +// SPDX-License-Identifier: 0BSD +// 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. +// ================================================================================================ + +#define CONCAT_(A, B) A ## B +#define CONCAT(A, B) CONCAT_(A, B) + +#ifdef __APPLE__ +# define SYM(LABEL) CONCAT(_, LABEL) +# define TEXT_SEGMENT .section __TEXT,__text +#else +# define SYM(LABEL) LABEL +# define TEXT_SEGMENT .section .text +#endif + diff --git a/aarch64/mariokartwii_ch07.S b/aarch64/mariokartwii_ch07.S new file mode 100644 index 0000000..69794eb --- /dev/null +++ b/aarch64/mariokartwii_ch07.S @@ -0,0 +1,47 @@ +// ================================================================================================ +// Code written while following chapter 7 of the MarioKart Wii ARM64 assembly tutorial: +// https://mariokartwii.com/arm64/ch7.html +// +// License: +// SPDX-License-Identifier: 0BSD +// 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 "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 new file mode 100644 index 0000000..7713fe8 --- /dev/null +++ b/aarch64/mariokartwii_ch08.S @@ -0,0 +1,39 @@ +// ================================================================================================ +// Code written while following chapter 8 of the MarioKart Wii ARM64 assembly tutorial: +// https://mariokartwii.com/arm64/ch8.html +// +// License: +// SPDX-License-Identifier: 0BSD +// 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 "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/run.sh b/aarch64/run.sh new file mode 100755 index 0000000..7e44d86 --- /dev/null +++ b/aarch64/run.sh @@ -0,0 +1,4 @@ +#!/bin/sh +D="$(dirname "$0")" +clang -o "$D/out" "$1" || exit 1 +lldb --no-lldbinit -o "target create out" -o "process launch" diff --git a/arm64/.gitignore b/arm64/.gitignore deleted file mode 100644 index 1fcb152..0000000 --- a/arm64/.gitignore +++ /dev/null @@ -1 +0,0 @@ -out diff --git a/arm64/common.S b/arm64/common.S deleted file mode 100644 index 34bb529..0000000 --- a/arm64/common.S +++ /dev/null @@ -1,25 +0,0 @@ -// ================================================================================================ -// Shared macros -// -// License: -// SPDX-License-Identifier: 0BSD -// 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. -// ================================================================================================ - -#define CONCAT_(A, B) A ## B -#define CONCAT(A, B) CONCAT_(A, B) - -#ifdef __APPLE__ -# define SYM(LABEL) CONCAT(_, LABEL) -# define TEXT_SEGMENT .section __TEXT,__text -#else -# define SYM(LABEL) LABEL -# define TEXT_SEGMENT .section .text -#endif - diff --git a/arm64/mariokartwii_ch07.S b/arm64/mariokartwii_ch07.S deleted file mode 100644 index 69794eb..0000000 --- a/arm64/mariokartwii_ch07.S +++ /dev/null @@ -1,47 +0,0 @@ -// ================================================================================================ -// Code written while following chapter 7 of the MarioKart Wii ARM64 assembly tutorial: -// https://mariokartwii.com/arm64/ch7.html -// -// License: -// SPDX-License-Identifier: 0BSD -// 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 "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/arm64/mariokartwii_ch08.S b/arm64/mariokartwii_ch08.S deleted file mode 100644 index 7713fe8..0000000 --- a/arm64/mariokartwii_ch08.S +++ /dev/null @@ -1,39 +0,0 @@ -// ================================================================================================ -// Code written while following chapter 8 of the MarioKart Wii ARM64 assembly tutorial: -// https://mariokartwii.com/arm64/ch8.html -// -// License: -// SPDX-License-Identifier: 0BSD -// 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 "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/arm64/run.sh b/arm64/run.sh deleted file mode 100755 index 7e44d86..0000000 --- a/arm64/run.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -D="$(dirname "$0")" -clang -o "$D/out" "$1" || exit 1 -lldb --no-lldbinit -o "target create out" -o "process launch" -- cgit v1.2.3