summaryrefslogtreecommitdiffstats
path: root/private/crt32/string/ppc/stricmpp.s
blob: a61d235735fc2fa282ba971a99a5ad01f572146a (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
78
79
80
81
82
83
84
85
86
87
88
89
//      TITLE("_stricmp _strcmpi")
//++
//
// Copyright (c) 1994  IBM Corporation
//
// Module Name:
//
//    _stricmp.s
//    _strcmpi.s
//
// Routine Description:
//
//	The functions are synomns.  The functions return an integer
//      indicating  case-insensitive string comparision, as the function
//      maps  characters from upper to lower case. Note that the
//      mapping from upper to lower affects outcome when comparison 
//      strings contain characters 91-96 as compared
//      to mapping lower to upper.
//
// Author:
//
//    Jeff Simon   (jhs) 02-Aug-1994
//
// Environment:
//
//    User or Kernel mode.
//
// Revision History:
//
// Includes

#include <kxppc.h>

// int _stricmp _strcmpi
//             (
//             char *str1, 
//             char *str2
//             )
//
// Arguments:
//
//    STR1 (r.3) - A pointer to the first string 
//
//    STR2 (r.4) - A pointer to the second string 
//
//
// Return Value:
//
//    < 0    if STR1 < STR2
//    = 0    if STR1 = STR2
//    > 0    if STR1 > STR2
//
//

        LEAF_ENTRY(_stricmp)
        ALTERNATE_ENTRY(_strcmpi)

	addi	r9,r3,-1			# copy ptr
	addi	r4,r4,-1
Loop1:

	lbzu	r6,1(r4)			# read char
	lbzu	r5,1(r9)			# read char
	cmpi	0x7,0x0,r6,0			# Is char null?
 	subf.	r3,r6,r5			# Calc result 

 	bc	0xc,0x1e,Loop20			# b if != 
	bc	0xc,0x2,Loop1			# b if r5 ?= r6	

Loop4:
 	cmpi	0x5,0x0,r6,0x41			# Is r5 > 60
 	cmpi	0x6,0x0,r6,0x5A			# Is r6 < 7B
 	blt	0x5,Loop2			# ? > 
  	bgt     0x6,Loop2     			# ? < 

 	ori 	r6,r6,0x20  			# cvrt to lower case
Loop2:
 	cmpi	0x0,0x0,r5,0x41			# Is r5 > 60
 	cmpi	0x1,0x0,r5,0x5A			# Is r6 < 7B
 	blt	0x0,Loop3			# ? 	
 	bgt     0x1,Loop3     			# ? 

 	ori 	r5,r5,0x20  			# cvrt to lower case
Loop3:
	subf.	r3,r6,r5			# Is r6 = r5
	beq	Loop1				# !=, done 

Loop20:
        LEAF_EXIT(_stricmp)