aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/libc/memcmp.s
blob: ec1e72970834f722392d7f6f57a8f1ea9e8e81ef (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
# High speed ASM memcmp implementation by Lameguy64
#
# Part of PSn00bSDK

.set noreorder

.section .text

# Arguments:
#	a0 - buffer 1 address
#	a1 - buffer 2 address
#	a2 - bytes to compare
.global memcmp
.type memcmp, @function
memcmp:
	blez	$a2, .Lexit
	addi	$a2, -1
	lbu		$v0, 0($a0)
	lbu		$v1, 0($a1)
	addiu	$a0, 1
	bne		$v0, $v1, .Lmismatch
	addiu	$a1, 1
	b		memcmp
	nop
.Lmismatch:
	jr		$ra
	sub		$v0, $v1
.Lexit:
	jr		$ra
	move	$v0, $0