这是用汇编语言构筑forth编译器的开源代码。
用汇编语言写大型程序,不可避免要用汇编语言。
我对编程语言没有偏见,即使用c语言,也要用点汇编。主要cpu里面由特殊指令集,能用好效率很高。
- defcode "EMIT",4,,EMIT
- pop %eax
- call _EMIT
- NEXT
- _EMIT:
- mov $1,%ebx // 1st param: stdout
- // write needs the address of the byte to write
- mov %al,emit_scratch
- mov $emit_scratch,%ecx // 2nd param: address
- mov $1,%edx // 3rd param: nbytes = 1
- mov $__NR_write,%eax // write syscall
- int $0x80
- ret
|