the code at the beginning here the file_name does not get created and so the code cant write to it how do i use two file variables here i cant figure out why ???
as well it wont compile with gcc it does compile with the ld tho
msg db 'Welcome to Assembly programming', 0xa ;
len equ $ - msg ;
msg_done db 'Written to file ', 0xa ;
len_done equ $ - msg_done ;
;make the write to file here last or there is a overflow and data gets added onnamly the next line
file_name db 'myfile.txt',
Nile_2 db '/home/mark/Desktop/mynewfile.txt',
section .bss
fd_out resb 1
fd_in resb 1
info resb 26
section .text
global _start ;must be declared for using gcc
_start: ;tell linker entry point _start:
;create the file
mov eax, 8
mov ebx, file_name
mov ecx, 0777 ;read, write and execute by all
int 0x80 ;call kernel
mov [fd_out], eax
; write into the file
mov edx,len ;number of bytes
mov ecx, msg ;message to write
mov ebx, [fd_out] ;file descriptor
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel
; close the file
mov eax, 6
mov ebx, [fd_out]
; write the message indicating end of file write
mov eax, 4
mov ebx, 1
mov ecx, msg_done
mov edx, len_done
int 0x80
;open the file for reading
mov eax, 5
mov ebx, Nile_2 ; was file_name
mov ecx, 0 ;for read only access
; mov edx, 0777 ;read, write and execute by all
int 0x80
mov [fd_in], eax
;read from file
mov eax, 3
mov ebx, [fd_in]
mov ecx, info
mov edx, 26
int 0x80
; close the file
mov eax, 6
mov ebx, [fd_in]
int 0x80
; print the info
mov eax, 4
mov ebx, 1
mov ecx, info
mov edx, 26
int 0x80
mov eax,1 ;system call number (sys_exit)
int 0x80 ;call kernel
the data in the Nile_2 file prints to the screen but the file_name file is not created i tryed using two section .data one on top and one on the bottom nothing has worked how can i use to variables for two different files !!!