1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# the C strcmp function generated by scc
export function w $strcmp(l %s1.3.val,l %s2.5.val)
{
@.37
%s1.3 =l alloc8 8
%s2.5 =l alloc8 8
storel %s1.3.val,%s1.3
storel %s2.5.val,%s2.5
jmp @.5
@.6
%.9 =l loadl %s1.3
%.10 =l add %.9,1
storel %.10,%s1.3
%.11 =l loadl %s2.5
%.12 =l add %.11,1
storel %.12,%s2.5
@.5
%.15 =l loadl %s1.3
%.16 =w loadsb %.15
%.17 =w extsb %.16
%.18 =w cnew %.17,0
jnz %.18,@.14,@.8
@.14
%.19 =l loadl %s2.5
%.20 =w loadsb %.19
%.21 =w extsb %.20
%.22 =w cnew %.21,0
jnz %.22,@.13,@.8
@.13
%.23 =l loadl %s1.3
%.24 =w loadsb %.23
%.25 =w extsb %.24
%.26 =l loadl %s2.5
%.27 =w loadsb %.26
%.28 =w extsb %.27
%.29 =w ceqw %.25,%.28
jnz %.29,@.6,@.8
@.8
@.7
%.30 =l loadl %s1.3
%.31 =w loadub %.30
%.32 =w extub %.31
%.33 =l loadl %s2.5
%.34 =w loadub %.33
%.35 =w extub %.34
%.36 =w sub %.32,%.35
ret %.36
}
# >>> driver
# extern int strcmp(const char *, const char *);
# int main() {
# char a[] = "Hello world";
# return !(
# strcmp(a, a) == 0 &&
# strcmp("aaa", "aab") < 0 &&
# strcmp("..cnn", "..bbc") > 0 &&
# strcmp(a, "Hellp ...") < 0 &&
# strcmp(a, "Hello vorld") > 0
# );
# }
# <<<
|