Raspberry Pi ARM ASM syscall notes

A few notes on useful syscalls:

SWI 0 : executes instruction based on value in R7

Write to screen: R7 = 4

MOV R7, #4 @ Syscall 4 = write to screen
MOV R0, #1 @ stdout: move 1 to R0
MOV R2, #4 @ length of string to R2
LDR R1, =string
SWI 0
string:
    .ascii "testn"

Read from keyboard: R7 = 3

MOV R7, #3 @ Syscall 3 = read from keyboard
MOV R0, #0 @ stdin?: move 0 to R0
MOV R2, #4 @ length of string to ready to R2
LDR R1, =string @ load R1 value to string location 
SWI 0
string:
    .ascii ""

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.