Мне нужно написать программу на языке ассемблера MIPS для чтения шестнадцатеричных значений (по одному в строке) из файла. Имя файла должно быть запрошено и считано с консоли. Как только число будет прочитано, преобразуйте его во внутреннее хранилище. Входной формат может быть фиксированным, 32-битным, с двумя дополнительными значениями или знаковой величиной переменной длины. После преобразования значение должно быть выведено на консоль.
Что у меня пока есть:
.data
fileName: .space 100
prompt1: .asciiz "Enter the file name: "
buffer: .space 40966
.text
main:
# prompt user for file name
li $v0, 4 #system call for printing string
la $a0, prompt1 #load prompt1
syscall #print string
# when entering name of the file, add its entire directory path with double backslashes
li $v0, 8 #system call for reading string
la $a0, fileName #load user input into the address of fileName
li $a1, 50 # max number of characters the fileName can hold
syscall #store user input into fileName
# converting the string into a null-terminated string
# replacing last character of fileName with 0 instead of \n
la $s0, fileName # $s0 contains fileName
add $s2, $0, $0 # $s2 = 0 (null terminator)
addi $s3, $0, '\n' # $s3 = '\n' (newline escape sequence)
removeNL:
lb $s1, 0($s0) # load character into $s0
beq $s1, $s3, replaceNL # Break if byte is equal to newline *
addi $s2, $s2, 1 # increment counter otherwise
addi $s0, $s0, 1 # increment string address
j removeNL
replaceNL:
sb $0, 0($s0) #replace newline with null terminator
# Open file for reading now that input file name is converted to null-terminated string
li $v0, 13 # system call for open file
la $a0, fileName # address of null-terminated string containing filename
li $a1, 0 # flags
li $a2, 0 # mode
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 input buffer
li $a2, 40966 # maximum number of char