ARM Assembly on Raspberry Pi 3 • 8 Apr 2016

Prepare a source file hello.s containing:

.data greeting: .ascii "Hi there\n" .text .globl _start _start: mov r7, #4 @ sys_write mov r0, #1 @ stdout ldr r1,=greeting @ address of string mov r2, #9 @ length of string svc #0 @ linux syscall mov r7, #1 @ sys_exit mov r0, #0 @ return result svc #0 @ linux syscall

Assemble, link and run the program using:

as -o hello.o -alh -g hello.s ld -o hello hello.o ./hello

Debugging tips

gdb hello b _start run display/i $pc si ...repeatedly press Enter to step through the program

Alternatively, you can use the graphical 'ddd' debugger to step through the program.

sudo apt-get install ddd ddd hello


Leave a comment

name (required)

content last edited on December 13, 2016, 13:18 - rendered in 4.54 msec