Simple puts() function in x64 assembly I'm trying to write as simple I/O library in x64 using linux syscalls

section .text
strlen:
  xor rdx, rdx
  .loop:
  cmp [rsi + rdx], 0
  je .exit
  inc rdx
  jmp .loop
  .exit:
  ret ; value in rdx

puts:
  ; string passed through rsi
  mov rax, 1
  call strlen
  syscall
Your loop uses 2 jumps (je/jmp) on every iteration!  Jumping is expensive, so a solution that needs only 1 jump (jne) will be more effective.

strlen:
  xor rdx, rdx
  dec rdx          ; This compensates for the INC that is happening first.
.next:
  inc rdx
  cmp byte [rsi + rdx], 0
  jne .next
  ret




Do keep things logically together. There's no point in setting RAX before the call to strlen.

puts:
  ; string passed through rsi
  call strlen      ; Result is in RDX

  mov rax, 1
  syscall