因此,正如我上次在我剛纔的問題說:打印以相反的順序陣列,裝配
我有一個鍛鍊我的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