The asm function strlen receives the link to an string as a char - Array. To to so, the functions may use SIMD on general purpose register, but without using xmm register or SSE instructions.
The functions checks with bit manipulation in 8 Byte steps, if the string contains the zero which marks the end. If it does, it checks byte per byte if it is zero. It works but I get page fault exceptions, which I don't know how to solve since the functions iterates in single steps in the last loop at the end.
; rdi <- const *char
; rax <- counter + return value
; rbx <- current array
; rcx <- Bitmask
; rsi <- Arr for calculation
strlen:
PUSH rbx
PUSH rbp
MOV rbp,rsp
SUB rsp,8 ; calling convention
XOR rax,rax
MOV rcx,0x7F7F7F7F7F7F7F7F
while_parallel: ;checks if next 8 byte contains end - zero
MOV rbx,[rdi+rax]
MOV rsi,rbx
AND rsi,rcx
ADD rsi,rcx
OR rsi,rbx
OR rsi,rcx
NOT rsi
CMP rsi, qword 0
JNE while_single
ADD rax,8
JMP while_parallel
while_single: ;check if next byte is zero
CMP [rdi+rax],byte 0
JE end
INC rax
JMP while_single
end:
ADD rsp,8
POP rbp
POP rbx
RET
Note that I must not use any SSE instructions nor xmm register.