bits 64

section .text

global __euler_do_syscall
__euler_do_syscall:

  push rdi
  push rsi
  push rdx
  push rcx

  mov rax, qword [rdi]
  mov rdi, qword [rsi]
  mov rsi, qword [rdx]
  mov rdx, qword [rcx]

  syscall

  pop rcx
  mov qword [rcx], rdx

  pop rdx
  mov qword [rdx], rsi

  pop rsi
  mov qword [rsi], rdi

  pop rdi
  mov qword [rdi], rax

  ret
