zoidberg@devbox:~/Code/ARM$ cat read.s
.global _start
_start:
// open(filename, 0)
MOV R7, #5
LDR R0, =filename
MOV R1, #0
SWI #0
// store returned file descriptor
MOV R5, R0
// Read from file descriptor read(fd, data, 10)
MOV R7, #3
MOV R0, R5
MOV R2, #10
LDR R1, =passwd
SWI 0
// close file descriptor close(fd)
MOV R7, #6
MOV R0, R5
SWI 0
// write data from file to screen write(1, data, 10)
MOV R7, #4
MOV R0, #1
MOV R2, #10
LDR R1, =passwd
SWI 0
// exit exit()
MOV R7, #1
SWI 0
.data
filename:
.ascii "/home/zoidberg/Code/ARM/test.txt"
passwd:
.ascii "ZZZZZZZZZZZZZZZZZZ"
zoidberg@devbox:~/Code/ARM$
zoidberg@devbox:~/Code/ARM$ arm-linux-gnueabi-as read.s -o read.o
zoidberg@devbox:~/Code/ARM$ arm-linux-gnueabi-ld read.o -o read
zoidberg@devbox:~/Code/ARM$ qemu-arm ./read
ZZZZZZZZZZzoidberg@devbox:~/Code/ARM$ cat test.txt
testing
zoidberg@devbox:~/Code/ARM$