Question

I'm trying to write a piece of code that will display the contents of a txt file. I only have numbers stored in the new file, one number per line (%d \n). Currently the code looks like this:

movl $0 , 320(%ebp)
#a pre reserved location on the stack for the first number that needs to be cleared first  
leal 320(%ebp), %eax    #a pre-chosen location for the memory 
push %eax 
push $dataformat        # . asciz "%d \n"
push %ebx               #the result from the fopen is stored in ebx 
call _fscanf
push 320(%ebp)
push %dataformat
call _printf 

However the result remains 0 unless I change the movl $0 to something else.

Was it helpful?

Solution

Problem solved turned out the file in %ebx was in append mode not in write mode

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top