2 * linux/arch/m32r/strlen.S -- strlen code.
4 * Copyright (C) 2001 Hirokazu Takata
6 * size_t strlen(const char *s);
10 #include <linux/linkage.h>
11 #include <asm/assembler.h>
13 #ifdef CONFIG_ISA_DUAL_ISSUE
17 mv r6, r0 || ldi r2, #0
24 seth r5, #high(0x01010101)
25 or3 r5, r5, #low(0x01010101)
28 ld r1, @r6+ || not r4, r0
29 sub r0, r5 || and r4, r7
31 bnez r4, strlen_last_bytes
32 ld r0, @r6+ || not r4, r1
33 sub r1, r5 || and r4, r7
34 and r4, r1 || addi r2, #4
35 bnez r4, strlen_last_bytes
36 addi r2, #4 || bra.s strlen_word_loop
38 ; NOTE: If a null char. exists, return 0.
39 ; if ((x - 0x01010101) & ~x & 0x80808080)
43 ldb r1, @r6 || addi r6, #1
45 addi r2, #1 || bra.s strlen_byte
48 ldi r0, #4 || addi r6, #-8
51 ldb r1, @r6 || addi r6, #1
52 addi r0, #-1 || cmpz r1
53 bc.s strlen_exit || cmpz r0
54 addi r2, #1 || bnc.s strlen_byte_loop
59 #else /* not CONFIG_ISA_DUAL_ISSUE */
71 seth r5, #high(0x01010101)
72 or3 r5, r5, #low(0x01010101)
76 not r4, r0 ; NOTE: If a null char. exists, return 0.
77 sub r0, r5 ; if ((x - 0x01010101) & ~x & 0x80808080)
78 and r4, r7 ; return 0;
80 bnez r4, strlen_last_bytes
84 not r4, r1 ; NOTE: If a null char. exists, return 0.
85 sub r1, r5 ; if ((x - 0x01010101) & ~x & 0x80808080)
86 and r4, r7 ; return 0;
88 bnez r4, strlen_last_bytes
109 bnez r0, strlen_byte_loop
115 #endif /* not CONFIG_ISA_DUAL_ISSUE */