Posted to tcl by gps at Mon Mar 30 01:42:25 GMT 2009view raw
- structure string
- integer length
- pointer array
- end-structure
- structure main-args
- integer count
- pointer array
- end-structure
- extern puti
- extern putn
- : main
- declare-structure main-args args
- declare-structure string s
- 1 *s.length ->
- s.length puti putn
- args.count if args.count puti then
- 1 *args.count ->
- putn
- ;;
- ----
- Here's the code.S generated and the runtime.S:
- .globl main
- main:
- pushl %ebp
- movl %esp,%ebp
- /*declare-structure begin*/
- subl $8,%esp
- /*declare-structure end*/
- /*declare-structure begin*/
- subl $16,%esp
- /*declare-structure end*/
- /*push-value begin*/
- movl creatc_stack_ptr,%eax
- subl $4,%eax
- movl $1,(%eax)
- movl %eax,creatc_stack_ptr
- /*push-value end*/
- /*push-local begin*/
- movl creatc_stack_ptr,%eax
- subl $4,%eax
- leal -12(%ebp),%ecx
- movl %ecx,(%eax)
- movl %eax,creatc_stack_ptr
- /*push-local end*/
- /*op-> begin*/
- movl creatc_stack_ptr,%eax
- movl (%eax),%ecx
- addl $4,%eax
- movl (%eax),%edx
- movl %edx,(%ecx)
- addl $4,%eax
- movl %eax,creatc_stack_ptr
- /*op-> end*/
- /*push-local begin*/
- movl creatc_stack_ptr,%eax
- subl $4,%eax
- movl -12(%ebp),%ecx
- movl %ecx,(%eax)
- movl %eax,creatc_stack_ptr
- /*push-local end*/
- /*op-extern-call begin*/
- call puti
- /*op-extern-call end*/
- /*op-extern-call begin*/
- call putn
- /*op-extern-call end*/
- /*push-local begin*/
- movl creatc_stack_ptr,%eax
- subl $4,%eax
- movl -4(%ebp),%ecx
- movl %ecx,(%eax)
- movl %eax,creatc_stack_ptr
- /*push-local end*/
- /*op-if begin*/
- movl creatc_stack_ptr,%eax
- movl (%eax),%ecx
- addl $4,%eax
- movl %eax,creatc_stack_ptr
- cmpl $0,%ecx
- je ___then_1
- /*op-if end*/
- /*push-local begin*/
- movl creatc_stack_ptr,%eax
- subl $4,%eax
- movl -4(%ebp),%ecx
- movl %ecx,(%eax)
- movl %eax,creatc_stack_ptr
- /*push-local end*/
- /*op-extern-call begin*/
- call puti
- /*op-extern-call end*/
- /*op-then begin*/
- ___then_1:
- /*op-then end*/
- /*push-value begin*/
- movl creatc_stack_ptr,%eax
- subl $4,%eax
- movl $1,(%eax)
- movl %eax,creatc_stack_ptr
- /*push-value end*/
- /*push-local begin*/
- movl creatc_stack_ptr,%eax
- subl $4,%eax
- leal -4(%ebp),%ecx
- movl %ecx,(%eax)
- movl %eax,creatc_stack_ptr
- /*push-local end*/
- /*op-> begin*/
- movl creatc_stack_ptr,%eax
- movl (%eax),%ecx
- addl $4,%eax
- movl (%eax),%edx
- movl %edx,(%ecx)
- addl $4,%eax
- movl %eax,creatc_stack_ptr
- /*op-> end*/
- /*op-extern-call begin*/
- call putn
- /*op-extern-call end*/
- leave
- ret
- /************** runtime.S **********************/
- .section .rodata
- int_fmt: .string "%d"
- newline_fmt: .string "\n"
- .data
- .comm creatc_stack, 8192
- .globl creatc_stack_ptr
- .data
- creatc_stack_ptr: .long creatc_stack + 8192
- .text
- .globl puti
- puti:
- movl creatc_stack_ptr,%eax
- movl (%eax),%ecx
- addl $4,%eax
- movl %eax,creatc_stack_ptr
- pushl %ecx
- pushl $int_fmt
- call printf
- addl $8,%esp
- ret
- .globl putn
- putn:
- pushl $newline_fmt
- call printf
- addl $4,%esp
- ret