1 /* SPDX-License-Identifier: GPL-2.0 */
3 * linux/arch/m32r/strlen.S -- strlen code.
5 * Copyright (C) 2001 Hirokazu Takata
7 * size_t strlen(const char *s);
11 #include <linux/linkage.h>
12 #include <asm/assembler.h>
14 #ifdef CONFIG_ISA_DUAL_ISSUE
18 mv r6, r0 || ldi r2, #0
25 seth r5, #high(0x01010101)
26 or3 r5, r5, #low(0x01010101)
29 ld r1, @r6+ || not r4, r0
30 sub r0, r5 || and r4, r7
32 bnez r4, strlen_last_bytes
33 ld r0, @r6+ || not r4, r1
34 sub r1, r5 || and r4, r7
35 and r4, r1 || addi r2, #4
36 bnez r4, strlen_last_bytes
37 addi r2, #4 || bra.s strlen_word_loop
39 ; NOTE: If a null char. exists, return 0.
40 ; if ((x - 0x01010101) & ~x & 0x80808080)
44 ldb r1, @r6 || addi r6, #1
46 addi r2, #1 || bra.s strlen_byte
49 ldi r0, #4 || addi r6, #-8
52 ldb r1, @r6 || addi r6, #1
53 addi r0, #-1 || cmpz r1
54 bc.s strlen_exit || cmpz r0
55 addi r2, #1 || bnc.s strlen_byte_loop
60 #else /* not CONFIG_ISA_DUAL_ISSUE */
72 seth r5, #high(0x01010101)
73 or3 r5, r5, #low(0x01010101)
77 not r4, r0 ; NOTE: If a null char. exists, return 0.
78 sub r0, r5 ; if ((x - 0x01010101) & ~x & 0x80808080)
79 and r4, r7 ; return 0;
81 bnez r4, strlen_last_bytes
85 not r4, r1 ; NOTE: If a null char. exists, return 0.
86 sub r1, r5 ; if ((x - 0x01010101) & ~x & 0x80808080)
87 and r4, r7 ; return 0;
89 bnez r4, strlen_last_bytes
110 bnez r0, strlen_byte_loop
116 #endif /* not CONFIG_ISA_DUAL_ISSUE */