【发布时间】:2017-01-02 16:40:26
【问题描述】:
我有一张 PGM 照片,我正试图在 MIPS 中打开和阅读它。 当 PGM 文件中的值是 ASCII 时,一切都按预期工作。当它们是 HEX 格式时,系统调用 14(读取)只读取几个值然后停止,我最终只得到 缓冲区中文件的一部分。
左边的十六进制 - 不工作,右边的 ASCII - 工作。同一个文件。
这就是我的代码(缓冲区在数据部分中声明并且有足够的空间来分配文件)
#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
【问题讨论】:
-
你有什么发现吗?如果你这样做了,你也可以回答你自己的问题。