This is a "Hello World" program written in pure assembly language on Linux/SPARC V8 platform.
1 #
2 # Makefile for Hello World on Linux/SPARC V8 platform
3 #
4 all:
5 sparc-linux-as hello.s -o hello.o
6 sparc-linux-ld hello.o -o hello
7
8 clean:
9 rm -f hello.o hello
1 /* hello.s */
2 /* sparc-linux-as hello.s -o hello.o */
3 /* sparc-linuc-ld hello.o -o hello */
4
5 .text
6 .globl _start
7
8 _start:
9
10 mov 1, %o0
11 set msg, %o1
12 mov 14, %o2
13 mov 4, %g1
14 ta 0x10
15
16 mov 0, %o0
17 mov 1, %g1
18 ta 0x10
19
20 msg:
21 .string "Hello World\n"
Result...
$ uname -a
Linux SPARC V8 2.6.24.1 #37 Thu Jan 28 10:11:06 CST 2010 sparc unknown
$
$ ./hello
Hello World
$
Of Linux on SPARC V8 CPU...
The Linux kernel entry, from user mode application into kernel mode, is triggled by ta 0x10 (trap 0x90) instrusion.
The system call number is got from the CPU register g1.
The system call parameter is placed in the sequence of o0, o1, o2...
In the example of the WRITE() system call
ssize_t write (int __fd, __const void *__buf, size_t __n);
The system call index (g1) is 0x04
__fd is o0
__buf is o1
__n is o2
No comments:
Post a Comment