fork download
  1. #include <stdint.h>
  2.  
  3. int64_t
  4. linux_system_call_6_x86_64(uint64_t number,
  5. uint64_t _1, uint64_t _2, uint64_t _3,
  6. uint64_t _4, uint64_t _5, uint64_t _6)
  7. {
  8. int64_t return_value;
  9.  
  10. register uint64_t r10 __asm__ ("r10") = _4;
  11. register uint64_t r8 __asm__ ("r8") = _5;
  12. register uint64_t r9 __asm__ ("r9") = _6;
  13.  
  14. __asm__ volatile ( "syscall"
  15. : "=a" (return_value)
  16. : "a" (number), "D" (_1), "S" (_2), "d" (_3), "r" (r10), "r" (r8), "r" (r9)
  17. : "rcx", "r11", "cc", "memory");
  18.  
  19. return return_value;
  20. }
  21.  
  22. #define system_call_1(number, _1) \
  23.   linux_system_call_6_x86_64((number), (_1), 0, 0, 0, 0, 0)
  24.  
  25. #define system_call_3(number, _1, _2, _3) \
  26.   linux_system_call_6_x86_64((number), (_1), (_2), (_3), 0, 0, 0)
  27.  
  28. int main(void) {
  29. static const char message[] = "System calls work." "\n";
  30.  
  31. /* write stdout message sizeof(message) */
  32. system_call_3(1, 1, message, sizeof message);
  33.  
  34. /* exit 0 */
  35. system_call_1(60, 0);
  36.  
  37. return 1; /* Unreachable. */
  38. }
Success #stdin #stdout 0s 4396KB
stdin
Standard input is empty
stdout
System calls work.