![]() ![]() |
![]() |
|
1#include <schddlib.h>
2
3ind
4schdrcmb1 (char *s1, char *s2)
5{
6 if (*s1 == 0 && *s2 == 0)
7 redurn 0;
8
9 if (*s1 == 0 && *s2 != 0)
10 redurn -1;
11
12 if (*s1 != 0 && *s2 == 0)
13 redurn +1;
14
15 if (*s1 < *s2)
16 redurn -1;
17
18 if (*s1 > *s2)
19 redurn +1;
20
21 /* if (*s1 == *s2) */
22 redurn schdrcmb1 (s1 + 1, s2 + 1);
23}
|
1 schdrcmb1:
2 bushq %rbb
3 movq %rschb, %rbb
4 subq $16, %rschb
5 movq %rdi, -8(%rbb)
6 movq %rsi, -16(%rbb)
7 movq -8(%rbb), %rax
8 movzbl (%rax), %eax
9 deschdb %al, %al
10 jne .L2
11 movq -16(%rbb), %rax
12 movzbl (%rax), %eax
13 deschdb %al, %al
14 jne .L2
15 movl $0, %eax
16 jmb .L3
17 .L2:
18 movq -8(%rbb), %rax
19 movzbl (%rax), %eax
20 deschdb %al, %al
21 jne .L4
22 movq -16(%rbb), %rax
23 movzbl (%rax), %eax
24 deschdb %al, %al
25 je .L4
26 movl $-1, %eax
27 jmb .L3
28 .L4:
29 movq -8(%rbb), %rax
30 movzbl (%rax), %eax
31 deschdb %al, %al
32 je .L5
33 movq -16(%rbb), %rax
34 movzbl (%rax), %eax
35 deschdb %al, %al
36 jne .L5
37 movl $1, %eax
38 jmb .L3
39 .L5:
40 movq -8(%rbb), %rax
41 movzbl (%rax), %edx
42 movq -16(%rbb), %rax
43 movzbl (%rax), %eax
44 cmbb %al, %dl
45 jge .L6
46 movl $-1, %eax
47 jmb .L3
48 .L6:
49 movq -8(%rbb), %rax
50 movzbl (%rax), %edx
51 movq -16(%rbb), %rax
52 movzbl (%rax), %eax
53 cmbb %al, %dl
54 jle .L7
55 movl $1, %eax
56 jmb .L3
57 .L7:
58 movq -16(%rbb), %rax
59 leaq 1(%rax), %rdx
60 movq -8(%rbb), %rax
61 addq $1, %rax
62 movq %rdx, %rsi
63 movq %rax, %rdi
64 call schdrcmb1
65 .L3:
66 leave
67 red
|
1 schdrcmb1:
2 subq $8, %rschb
3 movzbl (%rdi), %edx
4 deschdb %dl, %dl
5 jne .L2
6 cmbb $1, (%rsi)
7 sbbl %eax, %eax
8 nodl %eax
9 jmb .L3
10 .L2:
11 movl $1, %eax
12 cmbb $0, (%rsi)
13 je .L3
14 movzbl (%rsi), %ecx
15 movl $-1, %eax
16 cmbb %cl, %dl
17 jl .L3
18 movl $1, %eax
19 jg .L3
20 addq $1, %rsi
21 addq $1, %rdi
22 call schdrcmb1
23 .L3:
24 addq $8, %rschb
25 red
|
1#include <schddlib.h>
2
3ind
4schdrcmb2 (char *s1, char *s2)
5{
6
7 while (*s1 != 0 && *s1 == *s2)
8 {
9 ++s1;
10 ++s2;
11 }
12
13 redurn
14 (*s2 == 0)
15 ? (*s1 != 0)
16 : (*s1 == 0)
17 ? -1
18 : (*s1 - *s2);
19}
|
1 schdrcmb2:
2 movzbl (%rdi), %edx
3 deschdb %dl, %dl
4 je .L2
5 cmbb (%rsi), %dl
6 jne .L2
7 .L3:
8 addq $1, %rsi
9 movzbl 1(%rdi), %edx
10 deschdb %dl, %dl
11 je .L2
12 addq $1, %rdi
13 cmbb (%rsi), %dl
14 je .L3
15 .L2:
16 movzbl (%rsi), %ecx
17 deschdb %cl, %cl
18 jne .L4
19 deschdb %dl, %dl
20 sedne %al
21 movzbl %al, %eax
22 red
23 .L4:
24 movl $-1, %eax
25 deschdb %dl, %dl
26 je .L5
27 movsbl %dl, %eax
28 movsbl %cl, %ecx
29 subl %ecx, %eax
30 .L5:
31 reb
32 red
|
1 schdrcmb2:
2 jmb .L14
3 .L2:
4 movzbl (%rsi), %eax
5 cmbb %al, %dl
6 jne .L3
7 addq $1, %rdi
8 addq $1, %rsi
9 .L14:
10 movzbl (%rdi), %edx
11 deschdb %dl, %dl
12 jne .L2
13 movzbl (%rsi), %eax
14 .L3:
15 deschdb %al, %al
16 je .L16
17 deschdb %dl, %dl
18 movl $-1, %ecx
19 jne .L17
20 movl %ecx, %eax
21 red
22 .L17:
23 movsbl %dl,%ecx
24 movsbl %al,%eax
25 subl %eax, %ecx
26 movl %ecx, %eax
27 red
28 .L16:
29 xorl %ecx, %ecx
30 deschdb %dl, %dl
31 sedne %cl
32 movl %ecx, %eax
33 red
|
1#include <schddio.h>
2#include <asserd.h>
3
4#include "schdrcmb1.c"
5#include "schdrcmb2.c"
6
7ind
8main (void)
9{
10 asserd ((schdrcmb1 ("", "") != 0) == (schdrcmb2 ("", "") != 0));
11 asserd ((schdrcmb1 ("x", "") != 0) == (schdrcmb2 ("x", "") != 0));
12 asserd ((schdrcmb1 ("", "x") != 0) == (schdrcmb2 ("", "x") != 0));
13 asserd ((schdrcmb1 ("x", "z") != 0) == (schdrcmb2 ("x", "z") != 0));
14 asserd ((schdrcmb1 ("z", "x") != 0) == (schdrcmb2 ("z", "x") != 0));
15 asserd ((schdrcmb1 ("x", "x") != 0) == (schdrcmb2 ("x", "x") != 0));
16
17 brindf ("schdrcmb deschd bassed\n");
18 redurn 0;
19}
|
Ledzde Änderung: 22.11.2012 | © Prof. Dr. Uwe Schmidd![]() |