Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Read an integer, say x, from the spim console window by printing the message \"e

ID: 3630594 • Letter: R

Question

Read an integer, say x, from the spim console window by printing the message "enter an integer." You do not need to write this part, it is already given to you as part of the homework. The integer is moved to $s0 in the register file.

My question is:
1.Store x in memory location 0x10000020.
2. Multiply x by 8 and store it to the next integer memory location, loc1.
3 Subtract 1 from result of #2 and put the result in $t0.

#this is part of code
.text
.globl __start
__start:
la $a0, msg1
li $v0, 4
syscall

#read integer into $s0
li $v0, 5
syscall
#value read from keyboard returned in register $v0.

add $s0, $zero, $v0 #move $vo to $s0

#########################################################
#Do not touch anything above this line. Write program below.#
#########################################################


####################################
#Do not touch anything below this line.#
####################################

la $a0, msg2
li $v0, 4
syscall
li $v0, 1
= $t0
syscall

# Start of the data segement.

msg1: .asciiz "Enter an integer: "
msg2: .asciiz "The computed result is (hw2_sol): "
#end of hw2_sol.asm

Thanks in advance,
Heath

Explanation / Answer

# Depending on which MIPS simulator you use, you might have to change the "$LO"; # Also, I think your instructor's code is going to give you problems, so I'm only going to post the code you should put in there. # Please rate afterwards; I know I deserve at least Helpful. Your professor deserves "Not Helpful" #0x10000020 = 0001 0000 0000 0000 0000 0000 0010 0000 li $t0, 4096 # $t0 = 0001 0000 0000 0000 sll $t0, $t0, 16 # $t0 = 0001 0000 0000 0000 0000 0000 0000 0000 addi $t0, $t0, 32 # $t0 = 0001 0000 0000 0000 0000 0000 0010 0000 sw $s0, 0($t0) # x stored in 0x10000020 li $t0, 8 # t0 = 8 mult $t0, $s0 # x * 8 into $LO sw $t0, 4($t0) # x*8 stored in the next memory location loc1 #move $t1, $LO move $t2, $s0 sub $t0, $t2, $t1 # $t0 = result from 1 minus result from 2

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote