In this task, the job is to create a new empty file called "output.txt" of size 0 bytes
and an empty directory called "docs". This should be done twice: once "here", i.e. in the current working directory and once in the filesystem root.

 
; syscall numbers for readability. :]
 
%define sys_mkdir 39
%define sys_creat 8
 
section .data
	fName       db 'doc/output.txt',0
	rfName      db '/output.txt',0
	dName       db 'doc',0
 
	err_msg     db "Something went wrong! :[",0xa
	err_len     equ $-err_msg
 
section .text
global _start
 
_start:
 
nop
	mov ebx, dName              ; Directory name
	mov eax, sys_mkdir          ; Specify sys_mkdir call
	mov ecx, 0750o              ; permission (rwxr-x---)
	int 0x80                    ; Make kernel call
 
	mov ebx, fName              ; File name
	mov eax, sys_creat          ; Specify sys_creat call
	mov ecx, 0640o              ; permission (rw-r-----)
	int 0x80                    ; Make kernel call
	test eax, eax               ; eax AND eax
	js _ragequit                ; If EAX is less than zero
                                    ; THEN Display Message Error
 
	mov ebx, rfName             ; File name Root
	mov eax, sys_creat          ; Specify sys_creat call
	mov ecx, 0777o              ; permission (rwxrwxrwx)
	int 0x80                    ; Make kernel call
	cmp eax, 0
	jle _exit                   ; IF EAX is less or equal than zero
                                    ; THEN jump to EXIT
                                    ; ELSE Display Message Error
 
	_ragequit:
		mov edx, err_len        ; Pass offset of the message error
		mov ecx, err_msg        ; Pass the length of the message error
		mov eax, 4              ; Specify sys_write call
		mov ebx, 2              ; Specify File Descriptor 2: Error Output
		int 0x80                ; Make kernel call
 
	_exit:
		push 0x1
		mov eax, 1              ; Code for Exit Syscall
		push eax
		int 0x80                ; Make kernel call
		ret
 