- 论坛徽章:
- 0
|
原帖由 i802 于 2007-4-10 08:07 发表
可不可以只include cstdio中的printf ,哈哈哈,
这样说不定能更小,
自己写汇编,可以更小:
- ;; hello.asm
- section .data
- msg: db "Hello World"
- len: equ $-msg
- section .text
- global _start
- _start:
- mov edx,len
- mov ecx,msg
- mov ebx,1 ; write to stdout
- mov eax,4 ; write system call
- int 0x80
- mov ebx,0
- mov eax,1 ; exit system call
- int 0x80
复制代码
- nasm -felf -o hello.o hello.asm
- cc -nostdlib -o hello hello.o
- ./hello
- Hello World
复制代码
- ls -l hello
- -rwx------ 1 emacsnw csgrads 870 Apr 10 12:32 hello*
复制代码
当然,裸写elf文件还能更小,不过这个应该可以了。 |
|