MIPS:如何在此循环的每个打印语句前添加数字?

我现在要花2周的时间来教自己MIPS,到目前为止还不错,但是我一生都无法弄清楚如何在每个输出旁边添加一个数字。例如,如果我在提示符下输入5,则“我爱计算机科学”将打印5次。我希望它输出如下:

1我爱计算机科学

2我爱计算机科学

3我爱计算机科学

4我爱计算机科学

5我爱计算机科学

如果有人可以帮助菜鸟,我将不胜感激,谢谢。

.include "mips2.asm" 

.data

.text 

do: System_out_print("Enter Limit:")
nextInt($t0)

li $t3,0 
li $t4,0
bgt $t0,$t3 message

message: 
System_out_println("I love Computer Science!!")
add $t3,$t3,1 
add $t4,$t4,$t3 
blt $t3 $t0,message

System_out_println(" ")
System_out_print("This message printed: ")

li $v0,1
la $a0,($t0)
syscall

System_out_println (" times ")

endif:
System_out_print ("Continue? (Y/N)")
nextChar($t2)
beq $t2,'Y',do

System_exit()

##########MACROS MIPS2.ASM###############
.macro System_out_print(%st)
  .data
     str1: .asciiz %st

  .text
     li $v0,4
     la $a0,str1 #put the address of str1 in $a0
     syscall
.end_macro
##############################################
.macro System_out_println(%s)
  .data
     str1: .ascii %s
     newline: .asciiz "\n"

  .text
     li $v0,str1 #put the address of str1 in $a0
     syscall
.end_macro

##############################################
.macro nextInt(%r)
#This reads an integer from the keyboard and puts the value in register %r
 li $v0,5     #OS function 5 is read an integer 
 syscall       #Do it...the integer ends up in $v0
 move %r,$v0  #copy the number from $v0 to to register %r

.end_macro  

##############################################
.macro System_exit()
  li $v0,10        #Exit to OS
  syscall          

.end_macro  
##############################################
.macro nextChar(%r)
   #Reads in a character and stores it in register %r

   li $v0,12          #Function 12 is read a character
   syscall             #The character read is also store in $v0
   move %r,$v0         #move the character to our parameter register %r
.end_macro
###############################################
linshi0 回答:MIPS:如何在此循环的每个打印语句前添加数字?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3155429.html

大家都在问