summary refs log tree commit diff
path: root/test/strspn.ssa
blob: a64ea19cd613fb67b69785467e6881dc11f4f8d7 (plain) (blame)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# the C strspn function generated by scc

export function w $strspn_(l %s1.81.val,l %s2.82.val)
{
@.64
	%s1.81 =l	alloc8	8
	%s2.82 =l	alloc8	8
	%n.83 =l	alloc4	4
	%c.84 =l	alloc4	4
	%p.85 =l	alloc8	8
		storel	%s1.81.val,%s1.81
		storel	%s2.82.val,%s2.82
		storew	0,%n.83
		jmp	@.27
@.28
	%.39 =l	loadl	%s2.82
		storel	%.39,%p.85
		jmp	@.29
@.30
@.31
	%.40 =l	loadl	%p.85
	%.41 =l	add	%.40,1
		storel	%.41,%p.85
@.29
	%.43 =l	loadl	%p.85
	%.44 =w	loadsb	%.43
	%.45 =w	extsb	%.44
	%.46 =w	cnew	%.45,0
		jnz	%.46,@.42,@.36
@.42
	%.47 =l	loadl	%p.85
	%.48 =w	loadsb	%.47
	%.49 =w	extsb	%.48
	%.50 =w	loadsw	%c.84
	%.51 =w	cnew	%.49,%.50
		jnz	%.51,@.30,@.36
@.36
@.32
	%.52 =l	loadl	%p.85
	%.53 =w	loadsb	%.52
	%.54 =w	extsb	%.53
	%.55 =w	cnew	%.54,0
		jnz	%.55,@.33,@.37
@.37
		jmp	@.34
@.33
@.35
	%.56 =w	loaduw	%n.83
	%.57 =w	add	%.56,1
		storew	%.57,%n.83
@.27
	%.58 =l	loadl	%s1.81
	%.59 =l	add	%.58,1
		storel	%.59,%s1.81
	%.60 =w	loadsb	%.58
	%.61 =w	extsb	%.60
		storew	%.61,%c.84
	%.62 =w	cnew	%.61,0
		jnz	%.62,@.28,@.38
@.38
@.34
	%.63 =w	loaduw	%n.83
		ret	%.63
}

# >>> driver
# extern unsigned strspn_(const char *, const char *);
# int main() {
# 	return !(
# 		strspn_("", "abc") == 0 &&
# 		strspn_("abc", "") == 0 &&
# 		strspn_("abc", "bac") == 3 &&
# 		strspn_("xabc", "bac") == 0 &&
# 		strspn_("axbc", "bca") == 1
# 	);
# }
# <<<