3

Hello I am brand new to using MIPS and I was just confused on this wording, it is probably very simple but I cannot find anything in my notes or online specifically for this question.

Here is my code:

.data
val1: .word 1
val2: .word 2
val3: .word 3

.asciiz "Daniel"
.asciiz "Enter a number "
.asciiz "\n"

.globl main
.text

main:

addi $s0, $0, 23 # initializes the register $s0 to 23

lui $a0, 0x1001
ori $a0, $a0, 19
ori $v0, $0, 4
syscall
addi $v0, $0, 5
syscall
addi $s1, $v0, 0

My Question is: how do I a. Store the value in $s1 into the data segment labeled “val1” ?? I know how to store it into another register but not a value please and thank you!

1
  • MIPS doesn't have terribly many instructions, it's easy to spot which one you need. Hint: look at sw. There are also tons of examples. Commenting your code would help understanding it ;) If you are not forbidden, you might also want to use la. Commented May 25, 2016 at 0:45

1 Answer 1

2
la $t0, val1
sw $s1, 0($t0)

$t0 was chosen arbitrarily, it doesn't matter which register you choose to use to hold the base address of the val1 array. Also la (load address) is a pseudo operation so make sure you are able to use it first.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.