$ show below/HelloSilicon
This repository is an educational companion to the book 'Programming with 64-Bit ARM Assembly Language', adapted for Apple Silicon (ARM64 macOS, iOS, watchOS, tvOS). It contains 16 chapters of progressively complex assembly examples, covering system calls, memory addressing, functions, floating-point, NEON, and optimization. The code demonstrates key differences between Linux and Darwin (Apple) ABIs, such as syscall numbers, addressing modes (ADRP/ADD vs LDR =symbol), and variadic function calling conventions. It includes reusable debug macros (printReg, printStr) for register inspection, file I/O macros, and a toupper function callable from C, Python, and Swift. The project also features an Xcode SwiftUI app that integrates assembly code across multiple Apple platforms. The repository is well-maintained and actively used as a reference for Apple Silicon assembly development.
The LLM identified 4 files worth highlighting for reuse:
Provides two macros: printReg (prints a general-purpose register with format 'X%-2u = %32ld, 0x%016lx') and printStr (prints a literal string). Both macros save and restore all caller-saved registers using paired stack operations, preserving the register state while allowing debugging output through printf. This pattern is directly reusable in any ARM64 assembly project for runtime debugging without disrupting the calling context.
Defines macros for file operations using Darwin syscalls: openFile (uses openat with AT_FDCWD), readFile, writeFile, and flushClose (fsync+close). These macros abstract the Darwin ABI specifics (X16 for syscall number, svc #0x80, error handling via carry flag) and are parameterized by filename string and buffer. They can be extracted and reused for any assembly program requiring file I/O on macOS, with proper handling of error codes.
Implements a toupper function that converts an input ASCII string to uppercase. The function follows the ARM64 procedure call standard on Darwin: uses X0 for input pointer, X1 for output pointer, returns length in X0. It is self-contained (no global state), uses only callee-saved registers (X4, W5) after saving, and is linked with a .global directive. This component can be extracted and reused in any project needing a lowercase-to-uppercase string conversion, and serves as a model for calling assembly functions from C.
Identical to Chapter 06/upper.s but used in the file I/O example. Demonstrates a clean, minimal ARM64 function for character-by-character conversion with conditional logic via CMP/B.GT/B.LT/SUB. The function is idempotent and stateless, making it a reliable building block for string transformation pipelines.