我正在尝试读取并打印 .txt 文件中的内容。
稍后我还想从 mips 读取转储的文件。
我看到代码,看起来没问题,但没有输出任何内容......
.data
myFile: .asciiz "teste.txt" # filename for input
buffer: .space 1024
.text
# Open file for reading
li $v0, 13 # system call for open file
la $a0, myFile # input file name
li $a1, 0 # flag for reading
li $a2, 0 # mode is ignored
syscall # open a file
move $s0, $v0 # save the file descriptor
# reading from file just opened
li $v0, 14 # system call for reading from file
move $a0, $s0 # file descriptor
la $a1, buffer # address of buffer from which to read
li $a2, 11 # hardcoded buffer length
syscall # read from file
# Printing File Content
li $v0, 4 # system Call for PRINT STRING
la $a0, buffer # buffer contains the values
syscall # print int
li $v0, 10 # Finish the Program
syscall
问题是关于path
我的文件。
我以为路径会从源代码开始,但它是从.jar
file.
我所要做的就是提供一个带有 double 的 fullPath\\
.data
myFile: .asciiz "c:\\Users\\johnDoe\\Documents\\Assembly\\test.txt" # filename for input
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)