hi
i write this code to read from keyboard & write in a file
but it says "segmentation fault":((
plz answer i am failing:(((((((

comments are in farsi!!


section .data
fileName db '/home/fateme/Desktop/text.txt/',0
handler dd 10 ;baraye negah dashtane filedescriptor

section .bss
inputStr resb 100000

section .text
global _start:
_start:

;createfile
mov eax,8 ; The syscall number for creat() (we already have the filename in eb
mov ebx,fileName
mov ecx,00644Q ; Read/write permissions in octal (rw_rw_rw_)
int 80h ; Call the kernel
; Now we have a file descriptor in eax
mov [handler],eax ;azin b bad filedescriptor dar handler ast


;read from keyboard
mov eax,3
mov ebx,0
mov ecx,inputStr
mov edx,100000
int 80h

;alan eax shamele tedade bytehaEye k khunde shode

;write to file
mov edx,eax
mov ebx,[handler]
mov ecx,inputStr
mov eax,4
int 80h

what memory offset does your code start at? Maybe you reached a boundary limit and it wrapped around going to another area thus causing that error

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.