2 * MIPS o32 Linux syscall example
4 * http://www.linux-mips.org/wiki/RISC/os
5 * http://www.linux-mips.org/wiki/MIPSABIHistory
6 * http://www.linux.com/howtos/Assembly-HOWTO/mips.shtml
8 * mipsel-linux-gcc -nostdlib -mno-abicalls -fno-PIC -mabi=32 \
9 * -O2 -static -o hello-mips hello-mips.c
12 #define __NR_SYSCALL_BASE 4000
13 #define __NR_exit (__NR_SYSCALL_BASE+ 1)
14 #define __NR_write (__NR_SYSCALL_BASE+ 4)
16 static inline void exit1(int status
)
18 register unsigned long __a0
asm("$4") = (unsigned long) status
;
20 __asm__
__volatile__ (
27 : "i" (__NR_exit
), "r" (__a0
)
28 : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24",
32 static inline int write(int fd
, const char *buf
, int len
)
34 register unsigned long __a0
asm("$4") = (unsigned long) fd
;
35 register unsigned long __a1
asm("$5") = (unsigned long) buf
;
36 register unsigned long __a2
asm("$6") = (unsigned long) len
;
37 register unsigned long __a3
asm("$7");
40 __asm__
__volatile__ (
47 : "=r" (__v0
), "=r" (__a3
)
48 : "i" (__NR_write
), "r" (__a0
), "r" (__a1
), "r" (__a2
)
49 : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24",
62 write (1, "Hello, World!\n", 14);