因此,正如我上次在我刚才的问题说:打印以相反的顺序阵列,装配
我有一个锻炼我的univercity,我想有一些帮助!首先我是mips语言的新手!所以,我的练习是要求在qtSpim中创建一个程序,它将从控制台读取8个整数,然后将它保存在一个数组中,并保存到内存中,最后它将按保留顺序打印这些整数的六个元素!你能帮我一点点编码吗?
所以,我想一点点孤单,这是我做了什么至今:
# $18=c
.data
myArray: .space 32
.align 2
str_s: .asciiz "give me 8 numbers in 8 lines:"
str_nl: .asciiz "\n"
.text
.globl main #label "main" must be global
.globl loop
main:
la $17, myArray
#BUILD THE PROMPT
addi $2, $0, 4 # system call code for print_string
la $4, str_s # pseudo-istruction: address of string
syscall # print the string from str_s
add $18, $0, $0 # c=0
loop:
addi $2, $0, 5 #system call for read_string
syscall
add $16, $2, $0 #copy return int from $2 to $16
sw $16, 0($17) #save int from $16 to the array
addi $18, $18, 1 # c=c+1
bne $18, 8, loop #repeat while (c!=n)
loop:
j main
所以你可以SE在第二循环中我要打印以相反的顺序排列的整数。 ..在谷歌所有我能找到的是打印整数,但现在有不同,现在我有一个字符串?我应该使用从开始的整数吗?
`
_“现在我有一个字符串有什么不同吗?”_什么字符串?你的评论'#系统调用read_string'是误导性的,因为系统调用5是'read_int',而不是'read_string'。 – Michael