PLEASE DO NOT USE PSEUDO CODE! This assignment is designed to introduce you to t
ID: 3742990 • Letter: P
Question
PLEASE DO NOT USE PSEUDO CODE! This assignment is designed to introduce you to the standard instructions in the MIPS assembly language, using registers and memory, input/output syscalls and the MIPS simulator VERY IMPORTANT: Be sure to read all instructions Part 1 25 points (21 points if late) a. Open the text editor and type in the following. Then save your work as assign1.asm.. Note that the labels val1, val2, and val3 represent addresses or locations in memory in the data segment. data val1: .word 0 val2: word O val3: word 0 val4: word 0 class: .asciiz "CSE/EEE2301n" globl main main: la $a0, class # get address of string v0.4 # set command to print string syscall li St1 1 # set constant 1 li $10, 0x100 10000 # get address of first word sw St1 (SO) # store value in first word add St 1, $11, 1 # increment value sw St 1, val2 # store value in second word sub St 1, St1, 3 # subtract 3 from second word Sw St 1, val2 +4 # store value in third word # print string # end of program li SvO 10 syscall # set command to stop program # stop b. Be sure that that option to use extended or pseudo instruction is turned off (under Settings). Assemble the program, You will get 10 assembly errors. c. Rewrite the code so that no there are no assembly errors but it does the same work. There must be output with the name of the class and the memory must hold the values of 1, 2 and-1 at the end Part 2 25 points (21 points if late) a. Add the following zero terminated ascii strings to the data segment. 1. Your name 2. "Enter a number " 3. 3. A new line (In) Add the MIPS assembly language instructions before the comment #end of program to do the following. Note that some steps may take more than one instruction b. Steps 1. Initialize the register $s0 to 10Explanation / Answer
ScreenShot
Part 1
.data
val1: .word 0
val2: .word 0
val3: .word 0
val4: .word 0
class: .asciiz "CSE/EEE230 "
.text
main:
#Convert the pseudocode "la $a0, class" to below
# get address of string
lui $1,0x00001001
ori $4, $1,0x00000010
#Convert the pseudocode "li $v0,4" to below
addi $v0,$zero,4 # set command to print string
syscall # print string
#Convert the pseudocode "li $t1,1" to below
addi $t1,$zero,1# set constant 1
#Convert the pseudocode "li $t0, 0x10010000" to below
# get address of first word
lui $1,0x00001001
ori $8, $1,0x00000000
# store value in first word
sw $t1 ($t0)
# increment value
add $t1, $t1, 1
# store value in second word
sw $t1, 0x10010004
# subtract 3 from second word
sub $t1, $t1, 3
# store value in third word
sw $t1,0x10010008
# end of program
addi $v0,$zero,10 # set command to stop program
syscall # stop
-------------------------------------------------------------------
Output
CSE/EEE230
-- program is finished running --
------------------------------------------------------------
part 2
.data
val1: .word 0
val2: .word 0
val3: .word 0
val4: .word 0
class: .asciiz "CSE/EEE230 "
Yourname: .asciiz "Ima Student"
num: .asciiz "Enter a number "
newLine: .asciiz " "
.text
main:
#address of class
lui $1,0x00001001
ori $4, $1,0x00000010
addi $v0,$zero,4 # set command to print string
syscall # print string
addi $t1,$zero,1 # set constant 1
addi $t0, $zero,0x10010000 # get address of first word
# store value in first word
sw $t1 ($t0)
# increment value
add $t1, $t1, 1
# store value in second word
sw $t1, val2
# subtract 3 from second word
sub $t1, $t1, 3
# store value in third word
sw $t1, val2+4
#Initialize the register $s0 to 10
addi $s0,$zero,10
#Prompt the user to enter an integer and then read the integer into register $s1
lui $1,0x00001001
ori $4, $1,0x00000028
addi $v0,$zero,4#command to print string
syscall#print string
#Read the integer
addi $v0,$zero,5#command to read integer
syscall#read
#store in s1
add $s1,$zero,$v0
#Prompt the user to enter an integer and then read the integer into register $s2
lui $1,0x00001001
ori $4, $1,0x00000028
addi $v0,$zero,4#command to print string
syscall#print string
#Read the integer
addi $v0,$zero,5#command to read integer
syscall#read
#store in s1
add $s2,$zero,$v0
#Calculate the value of $s0 - $s1 + $s2 and store the result in the memory address labeled “val4”
sub $s0,$s0,$s1 #$s0=$s0 - $s1
add $s0,$s0,$s2 #$s0=$s0 - $s1 + $s2
#store the result in the memory address labeled “val4”
sw $s0,val4
#Print name
lui $1,0x00001001
ori $4, $1,0x0000001c
addi $v0,$zero,4#command to print string
syscall#print string
#Print newline
lui $1,0x00001001
ori $4, $1,0x00000038
addi $v0,$zero,4#command to print string
syscall#print string
#Print val4
lw $a0,val4
addi $v0,$0,1#print integer
syscall
#Print newline
lui $1,0x00001001
ori $4, $1,0x00000038
addi $v0,$zero,4#command to print string
syscall#print string
#Exchange or swap the values in $s1 and $s2
addi $t0,$0,0 #set t0=1
add $t0,$t0,$s1#move s1 into t0
addi $s1,$0,0 #set s1=0
add $s1,$s1,$s2 #move s2 into s1
addi $s2,$0,0#set s2=0
add $s2,$s2,$t0#move s1 into s2
#Set the value in $s0 to –$s0
addi $s0,$0,-10 #set s0=-10
#display result
add $a0,$0,$s0#set a0=s0
addi $v0,$0,1#command to print integer
syscall#print integer
#Next line
la $a0,newLine#get address of newline
addi $v0,$zero,4 #command for string print
syscall #print string
add $a0,$0,$s1#set a0=s0
addi $v0,$zero,1#command to print integer
syscall
#Print newline
lui $1,0x00001001
ori $4, $1,0x00000038
addi $v0,$zero,4#command to print string
syscall#print string
add $a0,$zero,$s2#set a0=s0
addi $v0,$zero,1#command to print integer
syscall#print integer
# end of program
addi $v0,$zero,10# set command to stop program
syscall # stop
--------------------------------------------
Output
CSE/EEE230
Enter a number 5
Enter a number 11
Ima Student
16
-10
11
5
-- program is finished running --
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.