2 * linux/arch/m32r/strlen.S -- strlen code.
4 * Copyright (C) 2001 Hirokazu Takata
6 * size_t strlen(const char *s);
12 #include <linux/config.h>
13 #include <linux/linkage.h>
14 #include <asm/assembler.h>
16 #ifdef CONFIG_ISA_DUAL_ISSUE
20 mv r6, r0 || ldi r2, #0
27 seth r5, #high(0x01010101)
28 or3 r5, r5, #low(0x01010101)
31 ld r1, @r6+ || not r4, r0
32 sub r0, r5 || and r4, r7
34 bnez r4, strlen_last_bytes
35 ld r0, @r6+ || not r4, r1
36 sub r1, r5 || and r4, r7
37 and r4, r1 || addi r2, #4
38 bnez r4, strlen_last_bytes
39 addi r2, #4 || bra.s strlen_word_loop
41 ; NOTE: If a null char. exists, return 0.
42 ; if ((x - 0x01010101) & ~x & 0x80808080)
46 ldb r1, @r6 || addi r6, #1
48 addi r2, #1 || bra.s strlen_byte
51 ldi r0, #4 || addi r6, #-8
54 ldb r1, @r6 || addi r6, #1
55 addi r0, #-1 || cmpz r1
56 bc.s strlen_exit || cmpz r0
57 addi r2, #1 || bnc.s strlen_byte_loop
62 #else /* not CONFIG_ISA_DUAL_ISSUE */
74 seth r5, #high(0x01010101)
75 or3 r5, r5, #low(0x01010101)
79 not r4, r0 ; NOTE: If a null char. exists, return 0.
80 sub r0, r5 ; if ((x - 0x01010101) & ~x & 0x80808080)
81 and r4, r7 ; return 0;
83 bnez r4, strlen_last_bytes
87 not r4, r1 ; NOTE: If a null char. exists, return 0.
88 sub r1, r5 ; if ((x - 0x01010101) & ~x & 0x80808080)
89 and r4, r7 ; return 0;
91 bnez r4, strlen_last_bytes
112 bnez r0, strlen_byte_loop
118 #endif /* not CONFIG_ISA_DUAL_ISSUE */