fork download
  1. section .data
  2. buffer db 99 ; Buffer to store input
  3. bufLen equ $ - buffer ; Length of the buffer
  4.  
  5. section .text
  6. global _start
  7.  
  8. _start:
  9. ; Display a prompt
  10. mov rdi, 1 ; File descriptor for stdout (1)
  11. mov rsi, prompt ; Pointer to the prompt message
  12. mov rdx, promptLen ; Length of the prompt message
  13. mov rax, 1 ; System call number for write
  14. syscall
  15.  
  16. ; Read input
  17. mov rdi, 0 ; File descriptor for stdin (0)
  18. mov rsi, buffer ; Pointer to the buffer
  19. mov rdx, bufLen ; Maximum number of bytes to read
  20. mov rax, 0 ; System call number for read
  21. syscall
  22.  
  23. ; Your code to handle the input goes here
  24.  
  25. ; Exit the program
  26. mov rax, 60 ; System call number for exit
  27. xor rdi, rdi ; Exit code 0
  28. syscall
  29.  
  30. section .data
  31. prompt db "Enter a number or character: ", 0
  32. promptLen equ $ - prompt
Success #stdin #stdout 0s 5276KB
stdin
hello
stdout
Enter a number or character: