Advertisement
Guest User

Untitled

a guest
Feb 17th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. section .bss
  2. readBuf resb 1000
  3. readBuf2 resb 1000
  4. bufSize equ 1000
  5.  
  6. section .data
  7. prompt db "Hello, please type something in",0x0A
  8. promptLen equ $ - prompt
  9.  
  10.  
  11. section .text
  12. global _start
  13.  
  14. _start:
  15. mov edx, 33 ;
  16. mov ecx, prompt ;
  17. mov ebx, 1 ;
  18. mov eax, 0x04 ; sys_write (why am I using hex for this? I dunno, looks cool...
  19. int 0x80
  20.  
  21.  
  22. mov edx, bufSize ; max number of bytes to read
  23. mov ecx, readBuf ; address of buffer to store bytes from input
  24. mov ebx, 0 ; stdin file descriptor
  25. mov eax, 0x03 ; sys_call read
  26. int 0x80 ; generate interrupt to trigger kernal system call
  27.  
  28. ; maybe we should check for failure here (return value negative??)
  29.  
  30. ;now let's just echo the text back out...
  31. mov edx, eax ;
  32. mov ecx, readBuf ;
  33. mov ebx, 1 ;
  34. mov eax, 0x04 ; sys_write (why am I using hex for this? I dunno, looks cool...
  35. int 0x80
  36.  
  37.  
  38. ; now let's see if we can reverse the text...
  39.  
  40. ; exit cleanly
  41. _exit:
  42. mov ebx,0 ;first syscall argument: exit code
  43. mov eax,1 ;system call number (sys_exit)
  44. int 0x80 ;call kernel
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement