Answer Key
University
California State UniversityCourse
COMP 122 | Computer Architecture and Assembly Language and LabPages
2
Academic year
2022
NyiH
Views
24
COMP 122-16396-FA2022 > Assignments > MARS 1 Immersive Rea 2 MARS 1 A+ Submission Submitted! ncements Due Sep 17, 2022 by 11:59pm Points 10 Submitting a file upload Sep 15, 2022 at 3:52pm Submission Details ments Download MARS_1.pdf Using the example below taken from powerpoint slides (Book_chap1to3) - This program sions can run on MARS simulator Grade: 10 (10 pts possible) Graded Anonymously: no ; Label Op-Code Dest. S1, S2 Comments Comments: move $a0, $0 # $a0 = 0 extra credit Afshin Amini, Sep 15, 2022 a li $t0, 99 # $t0 = 99 IS loop: is add $a0, $a0, $t0 # $a0 = $a0 + $t0 es addi $t0, $t0, -1 # $t0 = $t0 - 1 orations bnez $t0, loop # if ($t0 != zero) branch loop Discover li $v0, 1 # Print the value in $a0 I Name syscall ? Recording li $v0, 10 # Terminate Program Run S Insights syscall Write a program to add all the ODD numbers from 1 to 20 using MARS simulator. take a proper snapshot of your output-use tools on Windows and macOS (Command-Shift-4) to create an image.
.text li $t1, 20 loop: andi $t2, $t1, 1 beqz $t2, skip add $t3, $t3, $t1 skip: sub $t1, $t1, 1 bnez $t1, loop move $a0, $t3 li $v0, 1 syscall 100 program is finished running (dropped off bottom) --
COMP 122: MARS 1 Assignment - Adding Odd Numbers
Please or to post comments