0

What does the following QtSPIM/MIPS code do. Describe by referring to the functions of various blocks of the code (Block1, Block2, …).

Answer the questions in front of certain instructions.

Block1:

.text

main:

li $s4, 0

la $a0, input

li $v0, 4

syscall

li $v0, 5

syscall

move $t0, $v0 #Why do we need this?

Block2:

la $a0, output

li $v0, 4

syscall

move $a0, $t0

li $v0, 1

syscall

la $a0, newline # How will the output change if newline is replaced by newspace defined as “ “?

li $v0, 4

syscall

Block3:

Do:

move $a0, $s4

li $v0, 1

syscall

la $a0, newline

li $v0, 4

syscall

slt $s1, $s4, $t0

addi $s4, $s4, 1

bgt $s1, $zero, Do # Why can’t we use “beq $s1, 1, Do “?

Block4:

Exit:

li $v0, 10

syscall



.data

input: .asciiz "Input a number: "

output: .asciiz "Let me count till "

newline: .asciiz "\n "

So I need help with identifying what the code does... I have the concept I just want o make sure Im properly figuring this out... So I have this so far:

move $t0, $v0 #Why do we need this?  --- to store number in t0

la $a0, newline # How will the output change if newline is replaced by newspace defined as “ “?
---  load address of string to be printed into $a0 and adds the space if replaced by newspace

the last one I cant quite figure out...

Michael
  • 57,169
  • 9
  • 80
  • 125
  • _" --- to store number in t0"_ I seriously doubt that that would be accepted as an answer. When it comes to the third question; it should become apparent if you look up the encoding for `BEQ` in a MIPS instruction set reference. – Michael Apr 28 '14 at 17:53
  • Your second "guess" isn't quite right, either. You should be able to figure it out by actually reading the variable names: What is the difference between a new **line** and a new **space**? – Ken White Apr 28 '14 at 18:15

0 Answers0