Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;
- ;
- ;
- section .bss
- ;
- section .data
- ;
- filename: db "buffer.txt"
- errMsg: db 'Can't open the file', 10; Error message if buffer.txt is not found, 10 is the ASCII code for new line
- len: equ $ - errMsg; Length of the message errmsg is put in variable len
- ;
- section :text
- global _start
- _start:
- ;
- ;
- _openfile:
- mov eax, 5; "Open the file" function is called
- mov ebx, filename; Move file name in the register ebx
- mov ecx, 0; No option is given
- int 0x80; Services register 0x80 is called
- mov sf, 0; Check if the file was properly opened
- ;
- _cantopen:
- mov edx, len; The length of the message to show is given as third argument
- mov ecx, errMsg; The error message is given as second argument to be written in output
- mov ebx, 1; The output device is given as first argument, in this case the screen (code 1)
- int 0x80; Services register 0x80 is called
- jmp exit
- ;
- _exit:
- mov eax 1; "Close the program" function is called
- mov ebx 0; Move 1 to the register ebx to properly close the program
- int 0x80; Services register 0x80 is called
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement