我试图从一个缓冲区为255字节的文件中读取。
URLConnection
然而,它只是打印前255个字节,而不是文件的整个内容。如果没有自动完成,我不确定如何在读取文件时移动位置。
textBuffer和filename是
li $v0, 13 # open a file
li $a1, 0 # file flag (read)
la $a0, filename # load file name
add $a2, $zero, $zero # file mode (unused)
syscall
loop: # loop through the bytes until the # of bytes read is zero or an error
move $a0, $v0 # load file descriptor
li $v0, 14 # read from file
la $a1, textBuffer # allocate space for the bytes loaded
li $a2, 255 # number of bytes to be read
syscall
blez $v0, loop_done # is # of bytes read zero or an error?
la $a0, textBuffer # address of string to be printed
li $v0, 4 # print string
syscall
j loop
loop_done:
li $v0, 16
syscall # close file
在数据部分