Welcome to your Raspberry Pi linux terminal. If you're here, you've successfully connected via SSH using ssh pi@127.0.0.1 -p 5022. If you're unsure about the setup process, please refer to the previous notes on setting up QEMU for ARM here.
Open the helloworld.s file in the nano editor:
nano helloworld.sHere's the helloworld.s ARM assembly code:
.global _start
_start:
MOV R0,#1
LDR R1,=message
LDR R2,=len
MOV R7,#4
SWI 0
MOV R7,#1
SWI 0
.data
message:
.asciz "radhe radhe \n"
len = .-message.global _start: Marks the_startlabel as global, making it visible to the linker._start:: The entry point of our program.MOV R0,#1: Moves the value1into registerR0, which is used for file descriptor (stdout).LDR R1,=message: Loads the address of themessagelabel into registerR1.LDR R2,=len: Loads the address of thelenlabel into registerR2.MOV R7,#4: Moves the value4into registerR7, which is the system call number for 'write'.SWI 0: Triggers an interrupt to invoke a system call..data: Indicates that what follows is data (not code).message:: A label marking where our message starts..asciz "radhe radhe \n": Defines a null-terminated string.len = .-message: Defines the length of our message.
Compile the assembly code into an object file:
as helloworld.s -o helloworld.oLink the object file to create an executable:
ld helloworld.o -o helloworldVerify that all files are present:
lsRun your executable:
./helloworldYou should see the output:
radhe radhe