6b13f685e
김민수
BSP 최초 추가
|
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
|
.set noreorder
.set noat
.align 3
.globl strchr
.ent strchr
strchr:
.frame sp, 0, ra
.prologue 0
zapnot a1, 1, a1
ldq_u t0, 0(a0)
sll a1, 8, t5
andnot a0, 7, v0
or t5, a1, a1
lda t4, -1
sll a1, 16, t5
cmpbge zero, t0, t2
mskqh t4, a0, t4
or t5, a1, a1
sll a1, 32, t5
cmpbge zero, t4, t4
or t5, a1, a1
xor t0, a1, t1
cmpbge zero, t1, t3
or t2, t3, t0
andnot t0, t4, t0
bne t0, $found
$loop: ldq t0, 8(v0)
addq v0, 8, v0
nop
xor t0, a1, t1
cmpbge zero, t0, t2
cmpbge zero, t1, t3
or t2, t3, t0
beq t0, $loop
$found: negq t0, t1
and t0, t1, t0
and t0, t3, t1
beq t1, $retnull
and t0, 0xf0, t2
and t0, 0xcc, t3
and t0, 0xaa, t4
cmovne t2, 4, t2
cmovne t3, 2, t3
cmovne t4, 1, t4
addq t2, t3, t2
addq v0, t4, v0
addq v0, t2, v0
ret
$retnull:
mov zero, v0
ret
.end strchr
|