doc: paulchen beispiele {code{a,b},gesamt} entpackt (jedes mal entpacken nervt langsa...
[uebersetzerbau-ss10.git] / aus_sammelwut / paulchen / ublu / ss08 / abgabe / gesamt / optfib.s
diff --git a/aus_sammelwut/paulchen/ublu/ss08/abgabe/gesamt/optfib.s b/aus_sammelwut/paulchen/ublu/ss08/abgabe/gesamt/optfib.s
new file mode 100644 (file)
index 0000000..712bb1a
--- /dev/null
@@ -0,0 +1,351 @@
+       .text
+# setting call to 1
+       .globl optfib
+       .type optfib, @function
+optfib:
+# 2 1 1 1
+       pushq %rbp
+       movq %rsp, %rbp
+       subq $24, %rsp
+       movq %rdi, 16(%rsp)
+       movq $5000000, %rdi
+       pushq %rax
+       pushq %r10
+       pushq %r11
+       pushq %r9
+       pushq %r8
+       pushq %rcx
+       pushq %rdx
+       pushq %rsi
+       pushq %rdi
+       call sqr
+       popq %rdi
+       popq %rsi
+       popq %rdx
+       popq %rcx
+       popq %r8
+       popq %r9
+       popq %r11
+       popq %r10
+       addq $8, %rsp
+       movq %rax, 0(%rsp) /* z */
+       movq 0(%rsp), %rdi
+       addq $1000000, %rdi
+       movq $2, %rsi
+       pushq %rax
+       pushq %r10
+       pushq %r11
+       pushq %r9
+       pushq %r8
+       pushq %rcx
+       pushq %rdx
+       pushq %rsi
+       pushq %rdi
+       call div
+       movq %rax, %rdi
+       addq $8, %rsp
+       popq %rsi
+       popq %rdx
+       popq %rcx
+       popq %r8
+       popq %r9
+       popq %r11
+       popq %r10
+       popq %rax
+       mov 16(%rsp), %rsi
+       pushq %rax
+       pushq %r10
+       pushq %r11
+       pushq %r9
+       pushq %r8
+       pushq %rcx
+       pushq %rdx
+       pushq %rsi
+       pushq %rdi
+       call power
+       movq %rax, %rdi
+       addq $8, %rsp
+       popq %rsi
+       popq %rdx
+       popq %rcx
+       popq %r8
+       popq %r9
+       popq %r11
+       popq %r10
+       popq %rax
+       imulq $1000000, %rdi
+       movq 0(%rsp), %rsi
+       pushq %rax
+       pushq %r10
+       pushq %r11
+       pushq %r9
+       pushq %r8
+       pushq %rcx
+       pushq %rdx
+       pushq %rsi
+       pushq %rdi
+       call div
+       popq %rdi
+       popq %rsi
+       popq %rdx
+       popq %rcx
+       popq %r8
+       popq %r9
+       popq %r11
+       popq %r10
+       addq $8, %rsp
+       addq $500000, %rax
+       movq %rax, 8(%rsp) /* z */
+       movq 8(%rsp), %rdi
+       movq $1000000, %rsi
+       pushq %rax
+       pushq %r10
+       pushq %r11
+       pushq %r9
+       pushq %r8
+       pushq %rcx
+       pushq %rdx
+       pushq %rsi
+       pushq %rdi
+       call div
+       popq %rdi
+       popq %rsi
+       popq %rdx
+       popq %rcx
+       popq %r8
+       popq %r9
+       popq %r11
+       popq %r10
+       addq $8, %rsp
+       leave
+       ret
+# setting call to 0
+       .globl divslow
+       .type divslow, @function
+divslow:
+# 1 0 2 0
+       pushq %rbp
+       movq %rsp, %rbp
+       subq $24, %rsp
+       movq $1, %rax
+       movq %rax, 0(%rsp) /* z */
+do_start1:
+       movq %rdi, %rax
+       movq %rsi, %r10
+       movq 0(%rsp), %r11
+       imulq %r11, %r10
+       cmp %r10, %rax
+       jns do_enter1 # do_enter1 do_end1 0 0
+       jmp do_end1 # foo1
+do_enter1:
+       movq 0(%rsp), %r10
+       addq $1, %r10
+       movq %r10, 0(%rsp) /* z */
+       jmp do_start1
+do_end1:
+       movq 0(%rsp), %rax
+       addq $-1, %rax
+       leave
+       ret
+# setting call to 1
+       .globl div
+       .type div, @function
+div:
+# 2 1 2 2
+       pushq %rbp
+       movq %rsp, %rbp
+       subq $32, %rsp
+       movq %rdi, 24(%rsp)
+       movq %rsi, 16(%rsp)
+       movq $1, %rax
+       movq %rax, 0(%rsp) /* z */
+       movq $1000000, %rax
+       movq %rax, 8(%rsp) /* z */
+do_start2:
+       movq 8(%rsp), %rax
+       movq $1, %r10
+       cmp %r10, %rax
+       jns do_enter2 # do_enter2 do_end2 0 0
+       jmp do_end2 # foo1
+do_enter2:
+do_start3:
+       mov 24(%rsp), %rax
+       mov 16(%rsp), %r10
+       movq 0(%rsp), %r11
+       imulq %r11, %r10
+       cmp %r10, %rax
+       jns do_enter3 # do_enter3 do_end3 0 0
+       jmp do_end3 # foo1
+do_enter3:
+       movq 8(%rsp), %r10
+       movq 0(%rsp), %r11
+       addq %r11, %r10
+       movq %r10, 0(%rsp) /* z */
+       jmp do_start3
+do_end3:
+       movq 8(%rsp), %r10
+       negq %r10
+       movq 0(%rsp), %r11
+       addq %r11, %r10
+       movq %r10, 0(%rsp) /* z */
+       movq 8(%rsp), %rdi
+       movq $2, %rsi
+       pushq %rax
+       pushq %r10
+       pushq %r11
+       pushq %r9
+       pushq %r8
+       pushq %rcx
+       pushq %rdx
+       pushq %rsi
+       pushq %rdi
+       call divslow
+       movq %rax, %r10
+       popq %rdi
+       popq %rsi
+       popq %rdx
+       popq %rcx
+       popq %r8
+       popq %r9
+       popq %r11
+       addq $8, %rsp
+       popq %rax
+       movq %r10, 8(%rsp) /* z */
+       jmp do_start2
+do_end2:
+       movq 0(%rsp), %rax
+       leave
+       ret
+# setting call to 1
+       .globl power
+       .type power, @function
+power:
+# 1 1 2 2
+       pushq %rbp
+       movq %rsp, %rbp
+       subq $24, %rsp
+       movq %rdi, 16(%rsp)
+       movq %rsi, 8(%rsp)
+       mov 8(%rsp), %rax
+       movq $0, %r10
+       cmp %rax, %r10
+       jz if_then4 # if_then4 if_end4 0 0
+       jmp if_end4 # foo1
+if_then4:
+       movq $1000000, %rax
+       leave
+       ret
+if_end4:
+       mov 16(%rsp), %rax
+       movq %rax, 0(%rsp) /* z */
+do_start5:
+       mov 8(%rsp), %rax
+       movq $2, %r10
+       cmp %r10, %rax
+       jns do_enter5 # do_enter5 do_end5 0 0
+       jmp do_end5 # foo1
+do_enter5:
+       mov 16(%rsp), %rdi
+       movq 0(%rsp), %(null)
+       imulq %(null), %rdi
+       movq $1000000, %rsi
+       pushq %rax
+       pushq %r10
+       pushq %r11
+       pushq %r9
+       pushq %r8
+       pushq %rcx
+       pushq %rdx
+       pushq %rsi
+       pushq %rdi
+       call div
+       movq %rax, %r10
+       popq %rdi
+       popq %rsi
+       popq %rdx
+       popq %rcx
+       popq %r8
+       popq %r9
+       popq %r11
+       addq $8, %rsp
+       popq %rax
+       movq %r10, 0(%rsp) /* z */
+       mov 8(%rsp), %r10
+       addq $-1, %r10
+       movq %r10, 8(%rsp) /* y */
+       jmp do_start5
+do_end5:
+       movq 0(%rsp), %rax
+       leave
+       ret
+# setting call to 1
+       .globl sqr
+       .type sqr, @function
+sqr:
+# 2 1 1 1
+       pushq %rbp
+       movq %rsp, %rbp
+       subq $24, %rsp
+       movq %rdi, 16(%rsp)
+       movq $1, %rax
+       movq %rax, 0(%rsp) /* z */
+       movq $1000000, %rax
+       movq %rax, 8(%rsp) /* z */
+       mov 16(%rsp), %r10
+       imulq $1000000, %r10
+       movq %r10, 16(%rsp) /* y */
+do_start6:
+       movq 8(%rsp), %rax
+       movq $1, %r10
+       cmp %r10, %rax
+       jns do_enter6 # do_enter6 do_end6 0 0
+       jmp do_end6 # foo1
+do_enter6:
+do_start7:
+       mov 16(%rsp), %rax
+       movq 0(%rsp), %r10
+       movq 0(%rsp), %r11
+       imulq %r11, %r10
+       cmp %r10, %rax
+       jns do_enter7 # do_enter7 do_end7 0 0
+       jmp do_end7 # foo1
+do_enter7:
+       movq 8(%rsp), %r10
+       movq 0(%rsp), %r11
+       addq %r11, %r10
+       movq %r10, 0(%rsp) /* z */
+       jmp do_start7
+do_end7:
+       movq 8(%rsp), %r10
+       negq %r10
+       movq 0(%rsp), %r11
+       addq %r11, %r10
+       movq %r10, 0(%rsp) /* z */
+       movq 8(%rsp), %rdi
+       movq $2, %rsi
+       pushq %rax
+       pushq %r10
+       pushq %r11
+       pushq %r9
+       pushq %r8
+       pushq %rcx
+       pushq %rdx
+       pushq %rsi
+       pushq %rdi
+       call div
+       movq %rax, %r10
+       popq %rdi
+       popq %rsi
+       popq %rdx
+       popq %rcx
+       popq %r8
+       popq %r9
+       popq %r11
+       addq $8, %rsp
+       popq %rax
+       movq %r10, 8(%rsp) /* z */
+       jmp do_start6
+do_end6:
+       movq 0(%rsp), %rax
+       leave
+       ret