From 64321f1b4b50c46ae57f8c083bc110a75849dd9d Mon Sep 17 00:00:00 2001 From: Hunter Kvalevog Date: Wed, 28 Oct 2026 16:05:43 -0500 Subject: --- rust/asm/build.sh | 2 +- rust/asm/main_aarch64.S | 35 ----------------------------------- rust/asm/main_arm64.S | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 36 deletions(-) delete mode 100644 rust/asm/main_aarch64.S create mode 100644 rust/asm/main_arm64.S (limited to 'rust/asm') diff --git a/rust/asm/build.sh b/rust/asm/build.sh index 0d51849..569985f 100755 --- a/rust/asm/build.sh +++ b/rust/asm/build.sh @@ -1,5 +1,5 @@ #!/bin/sh mkdir -p bin -cc -c main_aarch64.S -o bin/asm.o +cc -c main_arm64.S -o bin/asm.o ar rcs bin/libasm.a bin/asm.o rustc --edition 2024 main.rs -L bin -l static=asm --out-dir bin diff --git a/rust/asm/main_aarch64.S b/rust/asm/main_aarch64.S deleted file mode 100644 index 191df8c..0000000 --- a/rust/asm/main_aarch64.S +++ /dev/null @@ -1,35 +0,0 @@ -// ================================================================================================ -// Rust->assembly interop demo -// -// 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 "../../_common/aarch64/common.S" - -TEXT_SEGMENT - -.global SYM(add_u32) -.global SYM(dot_f32v3) - -SYM(add_u32): - add w0, w0, w1 - ret - -SYM(dot_f32v3): - ldp s1, s2, [x0] // a.x, a.y - ldp s3, s4, [x1] // b.x, b.y - ldr s5, [x0, #8] // a.z - ldr s6, [x1, #8] // b.z - - fmul s0, s1, s3 // a.x * b.x - fmadd s0, s2, s4, s0 // + a.y * b.y - fmadd s0, s5, s6, s0 // + a.z * b.z - - ret diff --git a/rust/asm/main_arm64.S b/rust/asm/main_arm64.S new file mode 100644 index 0000000..03c2e12 --- /dev/null +++ b/rust/asm/main_arm64.S @@ -0,0 +1,35 @@ +// ================================================================================================ +// Rust->assembly interop demo +// +// 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 "../../_/arm64/common.S" + +TEXT_SEGMENT + +.global SYM(add_u32) +.global SYM(dot_f32v3) + +SYM(add_u32): + add w0, w0, w1 + ret + +SYM(dot_f32v3): + ldp s1, s2, [x0] // a.x, a.y + ldp s3, s4, [x1] // b.x, b.y + ldr s5, [x0, #8] // a.z + ldr s6, [x1, #8] // b.z + + fmul s0, s1, s3 // a.x * b.x + fmadd s0, s2, s4, s0 // + a.y * b.y + fmadd s0, s5, s6, s0 // + a.z * b.z + + ret -- cgit v1.2.3