I am writing a program that writes the contents from one file into another. What I am doing now (for testing) is to open the two files and write an string in one of them. The program doesn't show up any error, however nothing is writing in the file.
Here is my code
BITS 32 section .data msg db "Hola" section .bss src_file resb 1 ; Source file descriptor dest_file resb 1 ; Destination file descriptor section .text global _start _start: pop ebx ; argc pop ebx ; argv[0] nombre del ejecutable pop ebx ; src file name ;; Open src file mov ecx,1 ; Write mode mov eax,5 ; sys_open() int 0x80 ; Interruption 80. kernel call mov [src_file],eax pop ebx ; dest file name ;; Open dest file mov ecx,1 ; Write mode mov eax,5 ; sys_open() int 0x80 ; Interruption 80. kernel call mov [dest_file],eax ;; Writes in src file mov edx,4 ; Long mov ecx,msg ; text mov ebx,[src_file] ; File descriptor of dest file mov eax,4 int 0x80 ;; Closes src file mov ebx,[src_file] ; File descriptor of src file mov eax,6 ; sys_close() int 0x80 ; Kernel call ;; Closes dest file mov ebx,[dest_file] ; File descriptor of src file mov eax,6 ; sys_close() int 0x80 ; Kernel call ;; Exits the program mov ebx,0 ; OS exit code mov eax,1 ; sys_exit int 0x80 ; Kernel call I think maybe there is something wrong in storing the file descriptor after opening a file because if I move the block of code which writes into the file right after opening the source file it works just fine.
Thanks for the help!