|
1#include <stddef.h>
2
3size_t
4strlen1 (char *s)
5{
6 char *s1 = s;
7
8 while (*s1++);
9
10 return s1 - s - 1;
11}
12
13size_t
14strlen2 (char *s)
15{
16 register char *s1 = s;
17
18 while (*s1++);
19
20 return s1 - s - 1;
21}
22
|
1 strlen1:
2 pushl %ebp
3 movl %esp, %ebp
4 subl $4, %esp
5 movl 8(%ebp), %eax
6 movl %eax, -4(%ebp)
7 .L2:
8 movl -4(%ebp), %eax
9 movl %eax, %edx
10 leal -4(%ebp), %eax
11 incl (%eax)
12 cmpb $0, (%edx)
13 jne .L2
14 movl 8(%ebp), %edx
15 movl -4(%ebp), %eax
16 subl %edx, %eax
17 decl %eax
18 leave
19 ret
20 strlen2:
21 pushl %ebp
22 movl %esp, %ebp
23 subl $4, %esp
24 movl 8(%ebp), %eax
25 movl %eax, -4(%ebp)
26 .L6:
27 movl -4(%ebp), %edx
28 movb (%edx), %al
29 incl -4(%ebp)
30 testb %al, %al
31 jne .L6
32 movl -4(%ebp), %eax
33 subl 8(%ebp), %eax
34 decl %eax
35 leave
36 ret
|
1 strlen1:
2 pushl %ebp
3 movl %esp, %ebp
4 movl 8(%ebp), %ecx
5 movl %ecx, %edx
6 .L2:
7 movb (%edx), %al
8 incl %edx
9 testb %al, %al
10 jne .L2
11 movl %edx, %eax
12 subl %ecx, %eax
13 decl %eax
14 popl %ebp
15 ret
16 strlen2:
17 pushl %ebp
18 movl %esp, %ebp
19 movl 8(%ebp), %ecx
20 movl %ecx, %edx
21 .L6:
22 movb (%edx), %al
23 incl %edx
24 testb %al, %al
25 jne .L6
26 movl %edx, %eax
27 subl %ecx, %eax
28 decl %eax
29 popl %ebp
30 ret
|
| Letzte Änderung: 11.01.2007 | © Prof. Dr. Uwe Schmidt |