1 /* as helloworld.s -o helloworld.o; ld helloworld.o -o helloworld */
2 /* gcc helloworld.s -nostartfiles -nostdlib -static -o helloworld */
3
4 .text
5 .globl _start
6
7 _start:
8 mov $13, %edx
9 mov $msg, %ecx
10 mov $1, %ebx
11 mov $4, %eax
12 int $0x80
13
14 xorl %ebx, %ebx /* exit code */
15 movl $1, %eax /* exit function */
16 int $0x80
17
18 msg:
19 .string "Hello world\n"
20
The result is...
$ gcc helloworld.s -nostartfiles -nostdlib -static -o helloworld
$
$ uname -a
Linux lungswu-mobile 2.6.28-11-generic #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC 2009 i686 GNU/Linux
$
$ ./helloworld
Hello world
$
$
Of Linux on X86 CPU...
In the example of the WRITE() system call
ssize_t write (int __fd, __const void *__buf, size_t __n);
No comments:
Post a Comment