bits 64

global strlen

section .text

strlen:
  xor rax, rax
.loop:
  mov rdx, qword [rdi]
  test edx, 0xff
  jz .plus0
  test edx, 0xff00
  jz .plus1
  test edx, 0xff0000
  jz .plus2
  test edx, 0xff000000
  jz .plus3
  shr rdx, 32
  test edx, 0xff
  jz .plus4
  test edx, 0xff00
  jz .plus5
  test edx, 0xff0000
  jz .plus6
  test edx, 0xff000000
  jz .plus7
  add rax, 8
  add rdi, 8
  jmp .loop
.plus0:
  ret
.plus1:
  add rax, 1
  ret
.plus2:
  add rax, 2
  ret
.plus3:
  add rax, 3
  ret
.plus4:
  add rax, 4
  ret
.plus5:
  add rax, 5
  ret
.plus6:
  add rax, 6
  ret
.plus7:
  add rax, 7
  ret
