root / tests / hello-i386.c @ 40d0591e
History | View | Annotate | Download (574 Bytes)
1 | 4d1135e4 | bellard | #include <asm/unistd.h> |
---|---|---|---|
2 | 4d1135e4 | bellard | |
3 | 4d1135e4 | bellard | extern inline volatile void exit(int status) |
4 | 4d1135e4 | bellard | { |
5 | 4d1135e4 | bellard | int __res;
|
6 | 4d1135e4 | bellard | __asm__ volatile ("movl %%ecx,%%ebx\n"\ |
7 | 4d1135e4 | bellard | "int $0x80" \
|
8 | 4d1135e4 | bellard | : "=a" (__res) : "0" (__NR_exit),"c" ((long)(status))); |
9 | 4d1135e4 | bellard | } |
10 | 4d1135e4 | bellard | |
11 | 4d1135e4 | bellard | extern inline int write(int fd, const char * buf, int len) |
12 | 4d1135e4 | bellard | { |
13 | 4d1135e4 | bellard | int status;
|
14 | 4d1135e4 | bellard | __asm__ volatile ("pushl %%ebx\n"\ |
15 | 4d1135e4 | bellard | "movl %%esi,%%ebx\n"\
|
16 | 4d1135e4 | bellard | "int $0x80\n" \
|
17 | 4d1135e4 | bellard | "popl %%ebx\n"\
|
18 | 4d1135e4 | bellard | : "=a" (status) \
|
19 | 4d1135e4 | bellard | : "0" (__NR_write),"S" ((long)(fd)),"c" ((long)(buf)),"d" ((long)(len))); |
20 | 4d1135e4 | bellard | } |
21 | 4d1135e4 | bellard | |
22 | bb326a37 | bellard | void _start(void) |
23 | 4d1135e4 | bellard | { |
24 | 4d1135e4 | bellard | write(1, "Hello World\n", 12); |
25 | 4d1135e4 | bellard | exit(0);
|
26 | 4d1135e4 | bellard | } |