If you want to learn assembly programming for Windows O.S. or Linux with the Intel C.P.U. then you need the FASM tool and this manual.
Today I will show you how to create a file using my Fedora 31 Linux distro and FASM tool.
The name of this file will be new_file.txt.
The assembly program will use INT 0x08 to create the file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | entry _start filename db "new_file.txt", 0 _start: ; create a new file mov rax, 8 mov rbx, filename mov rcx, 0011 int 0x80 ; use descriptor push rax ; close the new file mov rax, 6 pop rbx int 0x80 call exit exit: mov rax, 1 mov rbx, 0 int 0x80 |
The program also set the file permissions in the rcx register.
Let’s see some octall permissions:
1 2 3 4 5 6 7 8 9 | mov rcx, 000 ----------. 1 mythcat mythcat 0 Nov 10 17:40 new_file.txt mov rcx, 0001 ---------x. 1 mythcat mythcat 0 Nov 10 17:41 new_file.txt mov rcx, 0011 ------x--x. 1 mythcat mythcat 0 Nov 10 17:43 new_file.txt |
The file type is …
1 2 | [mythcat@desk fasm]$ file new_file new_file: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, no section header |