2015-05-22 88 views
0

這裏是我做過什麼不使用MIPS打印整數任何僞指令

num1:.word 1 
num2:.word 2 
.globl main 
.text 
main: 
lui $t0,0x1001 
addi $v0,$0,1 #set commend to print 
addi $s2,$0,5 # add 5 to $s2 
sw $s2,4($t0) # store the val in word 2 
addi $a0,$t0,4 # add 4 to t0 to start the second word 
syscall # print int 

我想S2的值是打印但是我268500996.另外,如果我想打印字1和字2如何按照自己的路線製作每個輸出。

回答

0

,沒有要打印的值的地址。因此,而不是:

sw $s2,4($t0) # store the val in word 2 
addi $a0,$t0,4 # add 4 to t0 to start the second word 

你應該只是做:

or $a0, $s2, $0 # $a0 = $s2 

要打印一個換行符,你將打印字符13(回車)和10(換行)。您可以使用syscall 4(print_string)或兩次致電syscall 11(print_character)。