009
07.10.2004, 19:43 Uhr
~Fox
Gast
|
Hier nochmal für alle Assembler Freaks der Assembler Code zum austoben:
Multiplikation:
Code: |
.file "k.c" .text .globl m .type m, @function m: pushl %ebp movl %esp, %ebp subl $8, %esp movl $0, -8(%ebp) movl $0, -4(%ebp) .L2: cmpl $0, 12(%ebp) je .L3 movl 12(%ebp), %eax andl $1, %eax testl %eax, %eax je .L4 movl 8(%ebp), %eax movzbl -4(%ebp), %ecx sall %cl, %eax addl %eax, -8(%ebp) .L4: sarl 12(%ebp) incl -4(%ebp) jmp .L2 .L3: movl -8(%ebp), %eax leave ret .size m, .-m .section .rodata .LC1: .string "%g" .align 8 .LC0: .long 0 .long 1093567616 .text .globl main .type main, @function main: pushl %ebp movl %esp, %ebp subl $40, %esp andl $-16, %esp movl $0, %eax addl $15, %eax addl $15, %eax shrl $4, %eax sall $4, %eax subl %eax, %esp movl $0, -4(%ebp) movl $0, -8(%ebp) movl $0, -12(%ebp) movl $1000000, -16(%ebp) call clock movl %eax, -20(%ebp) .L8: movl -16(%ebp), %eax cmpl %eax, -4(%ebp) jg .L9 movl -12(%ebp), %eax movl %eax, 4(%esp) movl -8(%ebp), %eax movl %eax, (%esp) call m incl -8(%ebp) incl -12(%ebp) incl -4(%ebp) jmp .L8 .L9: call clock subl -20(%ebp), %eax pushl %eax fildl (%esp) leal 4(%esp), %esp fldl .LC0 fdivrp %st, %st(1) fstpl 4(%esp) movl $.LC1, (%esp) call printf movl $0, %eax leave ret .size main, .-main .section .note.GNU-stack,"",@progbits .ident "GCC: (GNU) 3.4.2"
|
Addition:
Code: |
.file "k.c" .text .globl addiere .type addiere, @function addiere: pushl %ebp movl %esp, %ebp subl $20, %esp movl 8(%ebp), %edx movl 12(%ebp), %eax movl %edx, %ecx xorl %eax, %ecx movl %ecx, -8(%ebp) andl %eax, %edx movl %edx, -12(%ebp) cmpl $0, -12(%ebp) je .L2 movl -8(%ebp), %eax movl %eax, 4(%esp) movl -12(%ebp), %eax addl %eax, %eax movl %eax, (%esp) call addiere movl %eax, -4(%ebp) jmp .L1 .L2: movl -8(%ebp), %ecx movl %ecx, -4(%ebp) .L1: movl -4(%ebp), %eax leave ret .size addiere, .-addiere .section .rodata .LC1: .string "%g" .align 8 .LC0: .long 0 .long 1093567616 .text .globl main .type main, @function main: pushl %ebp movl %esp, %ebp subl $40, %esp andl $-16, %esp movl $0, %eax addl $15, %eax addl $15, %eax shrl $4, %eax sall $4, %eax subl %eax, %esp movl $0, -4(%ebp) movl $0, -8(%ebp) movl $0, -12(%ebp) movl $1000000, -16(%ebp) call clock movl %eax, -20(%ebp) .L5: movl -16(%ebp), %eax cmpl %eax, -4(%ebp) jg .L6 movl -12(%ebp), %eax movl %eax, 4(%esp) movl -8(%ebp), %eax movl %eax, (%esp) call addiere incl -8(%ebp) incl -12(%ebp) incl -4(%ebp) jmp .L5 .L6: call clock subl -20(%ebp), %eax pushl %eax fildl (%esp) leal 4(%esp), %esp fldl .LC0 fdivrp %st, %st(1) fstpl 4(%esp) movl $.LC1, (%esp) call printf movl $0, %eax leave ret .size main, .-main .section .note.GNU-stack,"",@progbits .ident "GCC: (GNU) 3.4.2"
|
|