Hello I am working on what seemed like a simple assignment. I have a file i need to open full of integers ex. 1,10,32. I need to read the integers from the file and add 1. Then output the numbers to a different file. I believe i have most of the code however I am running into the program writing garbage the the output file and not the numbers. Please take a look at what I have and help me fix my problem.
.data num: .int 10 filename: .asciz "indata.txt" out: .asciz "outdata.txt" .bss .lcomm filehandle, 4 .lcomm outfilehandle, 4 .text .globl _start _start: nop # Open input file movl $5, %eax #open file movl $filename, %ebx #filename movl $00, %ecx #rd movl $0444, %edx int $0x80 test %eax, %eax #Test js badfile movl %eax, filehandle # Open output file movl $5, %eax movl $out, %ebx movl $01101, %ecx movl $0644, %edx int $0x80 test %eax, %eax js badfile movl %eax, outfilehandle readloop: #Read and store input. movl $3, %eax #Read movl filehandle, %ebx movl $num, %ecx #memory adress movl $5, %edx #length int $0x80 test %eax, %eax #Test jz done js badfile addl $1, num # Write output to file movl $4, %eax #Write movl outfilehandle, %ebx # To out filehandle movl $num, %ecx movl $5, %edx int $0x80 test %eax,%eax js badfile jmp readloop badfile: movl %eax, %ebx movl $1, %eax int $0x80 done: #Close file. movl $6, %eax movl filehandle, %ebx int $0x80 #Close file. movl $6, %eax movl out, %ebx int $0x80 movl $1, %eax movl $0, %ebx int $0x80