Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. ;
  2. ;
  3. ;
  4. section .bss
  5. ;
  6. section .data
  7. ;
  8. filename: db "buffer.txt"
  9. errMsg: db 'Can't open the file', 10; Error message if buffer.txt is not found, 10 is the ASCII code for new line
  10. len: equ $ - errMsg; Length of the message errmsg is put in variable len
  11. ;
  12. section :text
  13. global _start
  14. _start:
  15. ;
  16.  
  17. ;
  18. _openfile:
  19. mov eax, 5; "Open the file" function is called
  20. mov ebx, filename; Move file name in the register ebx
  21. mov ecx, 0; No option is given
  22. int 0x80; Services register 0x80 is called
  23. mov sf, 0; Check if the file was properly opened
  24. ;
  25. _cantopen:
  26. mov edx, len; The length of the message to show is given as third argument
  27. mov ecx, errMsg; The error message is given as second argument to be written in output
  28. mov ebx, 1; The output device is given as first argument, in this case the screen (code 1)
  29. int 0x80; Services register 0x80 is called
  30. jmp exit
  31. ;
  32. _exit:
  33. mov eax 1; "Close the program" function is called
  34. mov ebx 0; Move 1 to the register ebx to properly close the program
  35. int 0x80; Services register 0x80 is called
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement