MIPS: Как я могу добавить число перед каждым напечатанным оператором этого цикла? - PullRequest
0 голосов
/ 06 ноября 2019

У меня 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, 4
     la $a0, 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
###############################################
...