Master ARM64 assembly programming on the Raspberry Pi 5 with comprehensive tutorials, practical examples, and real-world applications
Get Started • Documentation • Examples • Contributing • Support
This repository provides a complete learning resource for ARM64 (AArch64) assembly programming specifically tailored for the Raspberry Pi 5. Whether you’re a complete beginner or an experienced developer looking to optimize your code at the lowest level, you’ll find comprehensive tutorials, practical patterns, and real-world examples to master assembly programming on the Pi 5’s powerful BCM2712 processor.
- 📚 Complete Tutorial Series: Step-by-step guide from installation to advanced techniques
- 🔧 Practical Code Patterns: Common patterns and idioms for building assembly libraries
- 📝 Comprehensive Glossary: All ARM64 instructions, registers, and state changes explained
- 🎯 Pi 5 Specific: Optimized for BCM2712 Cortex-A76 cores and RP1 southbridge
- 🚀 Performance Focused: Learn to leverage the Pi 5’s full potential
- 🤝 MIT Licensed: Use freely in your own projects
- 🎓 Computer Science Students - Understanding how computers really work
- 🔧 Systems Programmers - Writing bare-metal code and drivers
- 🎮 Game Developers - Optimizing critical performance paths
- 🤖 Embedded Developers - Creating efficient IoT applications
- 🧠 Curious Minds - Anyone wanting to peek under the hood
- 🚀 Quick Start
- 📋 Prerequisites
- 💻 Installation
- 📂 Repository Structure
- 🎓 Learning Path
- 💡 Usage Examples
- 🔍 Glossary Overview
- 🤝 Contributing
- 📜 License
- 🌟 Acknowledgments
- 💬 Support
Get up and running with ARM64 assembly on your Raspberry Pi 5 in minutes:
# Clone the repository
git clone https://github.com/username/rpi5-arm64-assembly.git
cd rpi5-arm64-assembly
# Install the ARM64 toolchain
sudo apt update
sudo apt install gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu
# Build and run your first program
cd examples/01-hello-world
make
./hello- Raspberry Pi 5 (4GB or 8GB model)
- MicroSD card (minimum 16GB, Class 10 recommended)
- Power supply (5V/5A USB-C)
- Monitor, keyboard, and mouse (for initial setup)
- Raspberry Pi OS (64-bit) - Bookworm or later
- GNU Assembler (as) for AArch64
- GNU Debugger (gdb) with ARM64 support
- Make build system
- Text editor (VS Code, Vim, or Nano)
- Basic understanding of computer architecture
- Familiarity with command-line interfaces
- C programming experience (helpful but not required)
- Number systems (binary, hexadecimal)
# Update your system
sudo apt update && sudo apt upgrade -y
# Install essential development tools
sudo apt install -y build-essential gdb-multiarch# Install the complete ARM64 toolchain
sudo apt install -y gcc-aarch64-linux-gnu \
binutils-aarch64-linux-gnu \
qemu-user-static \
gdb-multiarch
# Verify installation
aarch64-linux-gnu-as --versiongit clone https://github.com/username/rpi5-arm64-assembly.git
cd rpi5-arm64-assemblycd examples/00-test-setup
make test
# You should see: "ARM64 assembly environment is working correctly!"rpi5-arm64-assembly/
│
├── 📚 tutorials/ # Step-by-step learning modules
│ ├── 01-getting-started/ # Environment setup and first program
│ ├── 02-registers-memory/ # Understanding ARM64 architecture
│ ├── 03-instructions/ # Essential instruction set
│ ├── 04-control-flow/ # Branches, loops, and conditions
│ ├── 05-functions/ # Procedure calls and stack management
│ ├── 06-system-calls/ # Linux system call interface
│ └── 07-optimization/ # Performance optimization techniques
│
├── 🔧 patterns/ # Common programming patterns
│ ├── string-operations/ # String manipulation routines
│ ├── math-libraries/ # Mathematical operations
│ ├── data-structures/ # Arrays, lists, and trees
│ └── io-handling/ # Input/output operations
│
├── 💡 examples/ # Practical code examples
│ ├── 00-test-setup/ # Environment verification
│ ├── 01-hello-world/ # Classic first program
│ ├── 02-gpio-control/ # Raspberry Pi GPIO manipulation
│ ├── 03-performance/ # Benchmarking examples
│ └── 04-graphics/ # Frame buffer manipulation
│
├── 📖 glossary/ # Comprehensive reference
│ ├── instructions.md # All ARM64 instructions
│ ├── registers.md # Register descriptions
│ ├── system-calls.md # Linux syscall reference
│ └── quick-reference.pdf # Printable cheat sheet
│
├── 🛠️ tools/ # Helper scripts and utilities
│ ├── setup.sh # One-click environment setup
│ ├── debug-helper.py # GDB automation scripts
│ └── performance-test.sh # Benchmarking tools
│
├── 📄 LICENSE # MIT License
├── 📋 CONTRIBUTING.md # Contribution guidelines
├── 🔒 SECURITY.md # Security policy
└── 📖 README.md # This file
- Environment Setup - Get your tools ready
- First Program - Write “Hello, World!” in assembly
- Registers & Memory - Understand ARM64 architecture
- Basic Instructions - Learn essential operations
- Simple I/O - Read and write data
- Control Flow - Master branches and loops
- Functions - Create reusable code blocks
- Stack Management - Handle local variables
- System Calls - Interface with Linux kernel
- Debugging - Use GDB effectively
- SIMD/NEON - Vector processing operations
- Performance - Optimization techniques
- Library Development - Create reusable modules
- Hardware Interfaces - GPIO and peripherals
- Real Projects - Build complete applications
// hello.s - Classic first program
.global _start
.text
_start:
// Write "Hello, ARM64!" to stdout
mov x0, #1 // file descriptor (stdout)
adr x1, message // address of message
mov x2, #13 // message length
mov x8, #64 // sys_write
svc #0 // system call
// Exit program
mov x0, #0 // exit status
mov x8, #93 // sys_exit
svc #0 // system call
.data
message:
.ascii "Hello, ARM64!\n"// led_blink.s - Blink an LED on GPIO pin 17
.global _start
.text
_start:
// Memory-mapped GPIO setup for Pi 5
ldr x0, =0x1f00040000 // GPIO base address
mov x1, #1 // Pin 17 as output
lsl x1, x1, #21 // Shift to position
str x1, [x0, #0x04] // Set function register
blink_loop:
// Turn LED on
mov x1, #1
lsl x1, x1, #17
str x1, [x0, #0x1c] // Set pin high
// Delay
bl delay_ms
// Turn LED off
str x1, [x0, #0x28] // Set pin low
// Delay and repeat
bl delay_ms
b blink_loop// fast_memcpy.s - Optimized memory copy using NEON
.global fast_memcpy
fast_memcpy:
// x0 = destination, x1 = source, x2 = size
cmp x2, #64
b.lt copy_small
copy_large:
// Load 64 bytes using NEON
ld1 {v0.16b-v3.16b}, [x1], #64
// Store 64 bytes
st1 {v0.16b-v3.16b}, [x0], #64
sub x2, x2, #64
cmp x2, #64
b.ge copy_large
copy_small:
// Handle remaining bytes
cbz x2, done
ldrb w3, [x1], #1
strb w3, [x0], #1
sub x2, x2, #1
b copy_small
done:
retOur comprehensive glossary includes:
- General Purpose: X0-X30, W0-W30
- Special Purpose: SP, PC, CPSR
- SIMD/FP: V0-V31, Q0-Q31, D0-D31
- Data Processing: ADD, SUB, MUL, AND, ORR
- Memory Access: LDR, STR, LDP, STP
- Control Flow: B, BL, CBZ, CBNZ
- System: SVC, MSR, MRS
Each instruction entry includes:
- Affected flags (N, Z, C, V)
- Register modifications
- Memory side effects
- Performance considerations
We welcome contributions from the community! Whether you’re fixing bugs, adding new examples, or improving documentation, your help makes this resource better for everyone.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-addition) - Commit your changes (
git commit -m 'Add amazing feature') - Push to your branch (
git push origin feature/amazing-addition) - Open a Pull Request
Please read our <CONTRIBUTING.md> for detailed guidelines on:
- Code style and formatting
- Testing requirements
- Documentation standards
- Commit message conventions
This project adheres to the Contributor Covenant Code of Conduct. By participating, you’re expected to uphold this code.
This project is licensed under the MIT License - the most permissive open-source license. This means you can:
- ✅ Use commercially
- ✅ Modify freely
- ✅ Distribute
- ✅ Use privately
See the file for full details.
MIT License
Copyright (c) 2024 [Your Name]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction...
- ARM Limited - For excellent documentation and architecture guides
- Raspberry Pi Foundation - For creating amazing hardware
- Linux Kernel Developers - For the system call interface
- Community Contributors - Everyone who has helped improve this resource
Special thanks to:
- Low-level programming communities
- Beta testers and early adopters
- Tutorial reviewers and editors
- 📧 Email: spicy@meatball.ai
Q: Can I use this on other ARM64 devices?
A: While optimized for Pi 5, most examples work on any ARM64 Linux system.
Q: Do I need to know C to learn assembly?
A: No, but C knowledge helps understand calling conventions and system interfaces.
Q: How do I debug assembly code?
A: Use GDB with our debugging guide in tutorials/debugging/.
- ⭐ Star this repository for updates
- 👁️ Watch for new tutorials and examples
Happy coding! 🚀
Made with ❤️ by the ARM64 Assembly Community