2 * linux/arch/m32r/strlen.S -- strlen code.
4 * Copyright (C) 2001 Hirokazu Takata
6 * size_t strlen(const char *s);
12 #include <linux/linkage.h>
13 #include <asm/assembler.h>
15 #ifdef CONFIG_ISA_DUAL_ISSUE
19 mv r6, r0 || ldi r2, #0
26 seth r5, #high(0x01010101)
27 or3 r5, r5, #low(0x01010101)
30 ld r1, @r6+ || not r4, r0
31 sub r0, r5 || and r4, r7
33 bnez r4, strlen_last_bytes
34 ld r0, @r6+ || not r4, r1
35 sub r1, r5 || and r4, r7
36 and r4, r1 || addi r2, #4
37 bnez r4, strlen_last_bytes
38 addi r2, #4 || bra.s strlen_word_loop
40 ; NOTE: If a null char. exists, return 0.
41 ; if ((x - 0x01010101) & ~x & 0x80808080)
45 ldb r1, @r6 || addi r6, #1
47 addi r2, #1 || bra.s strlen_byte
50 ldi r0, #4 || addi r6, #-8
53 ldb r1, @r6 || addi r6, #1
54 addi r0, #-1 || cmpz r1
55 bc.s strlen_exit || cmpz r0
56 addi r2, #1 || bnc.s strlen_byte_loop
61 #else /* not CONFIG_ISA_DUAL_ISSUE */
73 seth r5, #high(0x01010101)
74 or3 r5, r5, #low(0x01010101)
78 not r4, r0 ; NOTE: If a null char. exists, return 0.
79 sub r0, r5 ; if ((x - 0x01010101) & ~x & 0x80808080)
80 and r4, r7 ; return 0;
82 bnez r4, strlen_last_bytes
86 not r4, r1 ; NOTE: If a null char. exists, return 0.
87 sub r1, r5 ; if ((x - 0x01010101) & ~x & 0x80808080)
88 and r4, r7 ; return 0;
90 bnez r4, strlen_last_bytes
111 bnez r0, strlen_byte_loop
117 #endif /* not CONFIG_ISA_DUAL_ISSUE */