I have a PGM photo which I'm trying to open and read in MIPS. When the values inside the PGM file are ASCII, everything works as expected. When they are in HEX format, the syscall 14 (read) reads just couple of values and than stops and I end up with only part of the file in the buffer.
To the left HEX - not working, to the right ASCII - working. Same file.
Thats my code (the buffer is declared in data section and has enough space to allocate the file)
#open a file
li $v0, 13 #Syscall for loading files
la $a0, image_file #Saving the address to $a0
li $a1, 0 # flag for reading
li $a2, 0 # mode is ignored
syscall
move $s6, $v0 #Placing the descriptor in $s6 for later-use
#read from file
li $v0, 14 #Syscall to read from files
move $a0, $s6 #Moving descriptor to $a0
la $a1, buffer # address of buffer to which to read
li $a2, 65555 # hardcoded buffer length
syscall