fork download
  1. global _start
  2.  
  3. section .data
  4. prompt: db "Enter your digit: "
  5. output: db 0ah,"You digit is "
  6. exc: db "!",0ah
  7. end:
  8.  
  9. section .bss
  10. digit: resb 1
  11.  
  12. section .text
  13.  
  14. _start:
  15. ; your code goes here
  16. ; print prompt
  17. mov eax,prompt
  18. mov ebx,output
  19. call print
  20.  
  21. ; read user input
  22. mov eax,3
  23. mov ebx,0 ; i know i know you should use xor
  24. mov ecx,digit
  25. mov edx,1
  26. int 80h ; lmao i forgot to add this at first
  27.  
  28. ; print output prompt and user input
  29. mov eax,output
  30. mov ebx,exc
  31. call print
  32.  
  33. mov eax,digit
  34. mov ebx,eax
  35. inc ebx
  36. call print
  37.  
  38. mov eax,exc
  39. mov ebx,end
  40. call print
  41.  
  42. jmp exit
  43.  
  44. exit:
  45. mov eax, 01h ; exit()
  46. xor ebx, ebx ; errno
  47. int 80h
  48.  
  49. print:
  50. mov ecx,eax
  51. sub ebx,eax
  52. mov edx,ebx
  53. mov eax,4
  54. mov ebx,1
  55. int 80h
  56. ret
  57.  
Success #stdin #stdout 0s 5320KB
stdin
9
stdout
Enter your digit: 
You digit is 9!