1 |
My code: |
2 |
.equ SYSCALL_EXIT, 1 |
3 |
.equ SYSCALL_WRITE, 4 |
4 |
|
5 |
.equ STDIN, 0 |
6 |
.equ STDOUT, 1 |
7 |
.equ STDERR, 2 |
8 |
|
9 |
.align 4 |
10 |
.global _start |
11 |
|
12 |
_start: |
13 |
mov STDOUT, %o0 |
14 |
set string, %o1 |
15 |
mov 14, %o2 |
16 |
mov SYSCALL_WRITE, %g1 |
17 |
ta 0x10 |
18 |
|
19 |
mov 0, %o0 |
20 |
mov SYSCALL_EXIT, %g1 |
21 |
ta 0x10 |
22 |
|
23 |
.align 4 |
24 |
|
25 |
string: |
26 |
.ascii "Hello world!\n" |
27 |
|
28 |
How I build it: |
29 |
as -64 -o hello.o hello.s |
30 |
ld -e _start --oformat=elf64-sparc -o hello hello.o |
31 |
ld: warning: sparc:v9 architecture of input file `hello.o' is |
32 |
incompatible with sparc output strip hello |
33 |
|
34 |
file hello |
35 |
hello: ELF 64-bit MSB executable, SPARC V9, version 1 (SYSV), |
36 |
statically linked, stripped |
37 |
|
38 |
ls -l |
39 |
total 24 |
40 |
-rwxr-xr-x 1 root root 66032 2006-12-26 14:39 hello |
41 |
-rw-r--r-- 1 root root 1056 2006-12-26 14:39 hello.o |
42 |
-rw-r--r-- 1 root root 296 2006-12-25 10:07 hello.s |
43 |
-rw-r--r-- 1 root root 187 2006-12-25 10:27 Makefile |
44 |
|
45 |
Why is the hello executable 66,032 bytes long? |
46 |
-- |
47 |
http://www.munted.org.uk |
48 |
|
49 |
Fearsome grindings. |
50 |
-- |
51 |
gentoo-sparc@g.o mailing list |