section .data
filename: db 'testdir',0 ;name of the new dir
string: db 'Hello',0 ;string to write to file..
stringLen: equ $-string ;length of string
textfile: db 'hello.txt',0;textfile to write string to..
section .text
global _start
_start:
;Creating directory..
mov eax, 39 ;mkdir sys-call
mov ebx, filename ;copy filename into first arg of mkdir syscall
mov ecx, 00644Q ;rw_rw_rw in octal
int 80h ;call the kernel..
;cd to the created dir..
;ebx still contains the filename
mov eax, 12 ;chdir syscall
int 80h ;now inside the create dir
;Create a file
;ecx still contains the perms in octal
mov eax, 8
mov ebx, textfile;
int 80h
;Write 'string' to textfile
test eax,eax ;test if fd is valid
js skipWrite ;if not, exit the program..
mov ebx, eax ;eax returned a fd, copy it into ebx
mov eax, 4 ;syswrite
mov ecx, string
mov edx, stringLen
int 80h
;close file
mov eax, 6
int 80h
; Exit the prog..
mov eax, 1;
mov ebx, 0;
int 80h;
skipWrite:
mov eax,1
mov ebx, 0
int 80h