Statistics
| Branch: | Revision:

root / tests / tcg / hello-i386.c @ 49cdaea1

History | View | Annotate | Download (582 Bytes)

1 4d1135e4 bellard
#include <asm/unistd.h>
2 4d1135e4 bellard
3 49cdaea1 Catalin Patulea
static inline 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 4a6648f4 Blue Swirl
static 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 49cdaea1 Catalin Patulea
  return status;
21 4d1135e4 bellard
}
22 4d1135e4 bellard
23 bb326a37 bellard
void _start(void)
24 4d1135e4 bellard
{
25 4d1135e4 bellard
    write(1, "Hello World\n", 12);
26 4d1135e4 bellard
    exit(0);
27 4d1135e4 bellard
}