I am trying to create a file in x86 Assembly and write to it. However, no file is being created. I have tried numerous tutorials, asking chatgpt, looking at the documentation but could not find where I went wrong. I would gladly appreciate any help. The program exits without any errors. The code is being assembled without any errors as well.
.att_syntax
.section .text
.global main
main:
# print out debug message
movl $4, %eax # write (syscall)
movl $1, %ebx # stdout
movl $debug_msg, %ecx #
movl $15, %edx #
int $0x80 #
# create file
movl $2, %eax # open (syscall)
movl $filename, %ebx # set filename to 'out.asm'
movl $0x202, %ecx # flags - write + create
movl $0x644, %edx # usermode - set permissions to read and write (owner) and read(all)
int $0x80 #
# push file descriptor onto stack
pushl %eax
# write basic setup to file
movl $1, %eax # write
popl %ebx
pushl %ebx
movl $debug_msg, %ecx
movl $18, %edx
# open src code
# compile src code
# close file
movl $3, %eax # close (syscall)
popl %ebx # file descriptor
pushl %ebx
int $0x80 #
.section .data
debug_msg:
.string "Debug String :)"
filename:
.string "out.txt"
Any help would be very appreciated! :)