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

6. Using SID/Student ID: 104085021, solve the following. For this tutorial, plea

ID: 3877781 • Letter: 6

Question

6. Using SID/Student ID: 104085021, solve the following.

For this tutorial, please download the MARS (MIPS Assembler and Runtime Simulator) at nvo It is a Java application so it should run on any platform. There are a number of ways to launch the program; the simplest should be to “double click" on the “jar" file; see the website for more information. Once MARS has successfully started, you will see 3 window areas. The center one is the editing/assembling view, the right, the current register view, and on the bottom, the results view. To create a file, go to "File", "New" and start entering assembly code. Each of the questions below will detail what is necessary to move on in the assignment. Please create "SID_Assign2.doc" (where "SID is your student number), a document file which includes all your responses for questions which don't require a "SID_Assign2_X.s". Once the assignment is complete, ZIP all the files into "SID_Assign2.zip" and email them to the GA. Remember, comments help us evaluate your work. 1. Copy the following code into the editor in MARS. Save it as "SID_Assign2_1.s" # comment liberally! A: word 10 word 8 word o asciiz "The solutions is intext lw $t1,B add St2, $to, $tl 11 SvO,4 La Sao.massage 11 SvO,1 iw Sao,c 11 SvO, 10 Notice that there are two “directives" in the code. “.data" and ".text". The “.data" directive indicates that anything following it is pertaining to the data section in the software module where as anything following “.text" is pertaining to the code segment. This is done so that the “object" file will be partitioned correctly for proper run-time linking. Now, press F3 or “Run", “Assembler" and assuming you've entered the code correctly, the tab at the top of the editor will switch to “Execute" and you will see a listing of the assemblers results which shows all the opcodes generated. Now, press F5 or “Run", "Go" and the code will simulate. Since this code uses some specialized syscalls" (calls to the kernel, or in this case the simulator) we can produce some useful outputs with minimal work; this is shown at the bottom view (Run I/O).

Explanation / Answer

Code:

# comment liberally!

.data

A: .word 10

B: .word 8

C: .word 0

message:

.asciiz "The solutions is "

.text

main:

jal addition #using jal instruction for leaf branching

#print output

li $v0, 4

la $a0, message

syscall

li $v0, 1

lw $a0, C

syscall

#finish execution

li $v0, 10

syscall

#addition branch

addition:

#perform add operation

lw $t0, A

lw $t1, B

add $t2, $t0, $t1

sw $t2, C

#return to main loop using $ra register

jr $ra

Output:

The solutions is 18
-- program is finished running --

Hope this helps. Do Upvote! :)