Six one hour lessons on the basics of ARM Assembly on the Raspberry Pi (appropriate for high-school students).
int main()
{
return 42;
}To see the result...
$ echo $?
42.section .text // Text section for code
.global _start // Define the entry point
_start:
mov x0, #42 // Set x0 to 42
mov x8, #93 // Set x8 to 93 (sys_exit syscall number)
svc 0 // Make the syscallTo see the result...
$ echo $?
42After we get the programming environment set up and discuss some theory, that's it for the first hour.
Topics Covered Entry Points, Registers, Syscalls, Assembly Syntax, File Sections, Directives, Return values, Data Types
In
Hour 1we write Hello, World! in ARM Assembly and introduce loops and function calls. (Note: we print "Hello, World!" one character at at time.)
Topics Covered Loops, Functions, Strings, Registers, Branching, Conditionals, Stack, Pointers, Memory, Data Types
In
Hour 2we write an ARM Assembly program that prints the alphabet. In this lesson we introduce ASCII encoding and the concepts of branching and conditionals.
Topics Covered Branching, Conditionals, Loops, Strings, ASCII, Data Types
In
Hour 3we write a program that prints the numbers 0 to 99 in ARM Assembly. Here we discuss the difference between the integer value of a number and the printed representation of a number as an ASCII string.
In
Hour 4we write a program that implements the famous FizzBuzz algorithm for values from 1 to 100. This lesson is a bit more challenging than the previous lessons, but it is a great way to learn about branching and conditionals.
In
Hour 5we write a program that sorts and prints an array of integers in ARM Assembly. This one is challenging!
In
Hour 6we write an ARM assembler program that takes a year as text input from stdin and responds whether or not that year is a leap year.