~ahs3/+junk/cq-qemu

« back to all changes in this revision

Viewing changes to tests/hello-i386.c

  • Committer: Al Stone
  • Date: 2012-02-09 01:17:20 UTC
  • Revision ID: albert.stone@canonical.com-20120209011720-tztl7ik3qayz80p4
first commit to bzr for qemu

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <asm/unistd.h>
 
2
 
 
3
static inline volatile void exit(int status)
 
4
{
 
5
  int __res;
 
6
  __asm__ volatile ("movl %%ecx,%%ebx\n"\
 
7
                    "int $0x80" \
 
8
                    :  "=a" (__res) : "0" (__NR_exit),"c" ((long)(status)));
 
9
}
 
10
 
 
11
static inline int write(int fd, const char * buf, int len)
 
12
{
 
13
  int status;
 
14
  __asm__ volatile ("pushl %%ebx\n"\
 
15
                    "movl %%esi,%%ebx\n"\
 
16
                    "int $0x80\n" \
 
17
                    "popl %%ebx\n"\
 
18
                    : "=a" (status) \
 
19
                    : "0" (__NR_write),"S" ((long)(fd)),"c" ((long)(buf)),"d" ((long)(len)));
 
20
}
 
21
 
 
22
void _start(void)
 
23
{
 
24
    write(1, "Hello World\n", 12);
 
25
    exit(0);
 
26
}