Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. (10 points)Open file 2.1.s by Mars, translate the comments in the file from line 13 to line 17. Save it. Assemble it and Run

1. (10 points)Open file 2.1.s by Mars, translate the comments in the file from line 13 to line 17. Save it. Assemble it and Run it. Submit your modified 2.1.s file in iLearn. (Hint 1: use instruction syscall) (Hint 2, select show line numbers in the Mars as follows)

2. (30 points)Open file 2.2.s by Mars, translate the comments line 31 to line 32. (if-else statement) Save it. Assemble it and Run it. Submit your modified 2.2.file. and Answer the following question: Whats the output of your program?

3. (30 points)Open file 2.3.s by Mars, translate the comments from line 36 to line 44. (if-else statement) Save it. Assemble it and Run it. Submit your modified 2.3.file.

4. Read the slides Chapter_2_04_updatedFile page 51 and page 52 (if-and condition and if-or condition) and answer the following question. For the code: 1) (5 points) Please draw the original flow chart 2) (5 points) Please draw the reversed flow chart 3) (5 points) Please write down the MIPS code if we know x value is in $s0, y value is in $s1 and variable flag is in $s2. For the code: 4)(5 points) Please draw the original flow chart 5)(5 points) Please draw the reversed flow chart 6)(5 points) Please write down the MIPS code if we know x value is in $s0, y value is in $s1 and variable flag is in $s2. 5. (Bonus 10 point) Read the slides Chapter_2_04_updatedFile page 53 (for loop) and answer the following question. For the for loop: for (int i = 0; i

image text in transcribedimage text in transcribedimage text in transcribed

2.3.s) No Selection 1 # 2 # CSc 256 Example 2.3: If-else statement, variables in registers 3 # Name: Jingyi Wang 4 # Date: 9/9/2019 # Description: Demonstrates nested if-else statement 6 # 8 # int main(void) 9 # { # int num, max = 100, flag; 11 # 12 # cin >> num; 14 # 16 17 # # if (num == max) flag = 1; else if (num != 0) flag = -1; else flag = 0; cout > num; addi $s2, $0, 100 addi $v0, $0, 5 # syscall add $80, $v0, $0 # if (num == max) flag = 1; else if (num != 0) # flag = -1; # else flag = 0; cout 2.2.s) No Selection 1# 2 # CSc 256 Example 2.2: If statement, variables in registers 3 # Name: 4 # Date: 2/12/2020 5 # Description: Demonstrates if statement translation 6 # 7 # # #include 9 # int x=4, y=-1, sum=0; 10 # 11 # int main() 12 # { 13 # if (x != y) sum = sum + x; 15 # cout 2.1 (1).s) No Selection 1 .data 3 label1: .asciiz "please input the number: " label2: asciiz "the result is : " 7 .text main: li $s1, 4 # x = 4 li $s2, 5 # y = 5 li $s3, 10 # D = 10 # print string label1 #input an integer z to $50 through keyboard # D = x * x + y * Z # print string label2 # print integer D 2.3.s) No Selection 1 # 2 # CSc 256 Example 2.3: If-else statement, variables in registers 3 # Name: Jingyi Wang 4 # Date: 9/9/2019 # Description: Demonstrates nested if-else statement 6 # 8 # int main(void) 9 # { # int num, max = 100, flag; 11 # 12 # cin >> num; 14 # 16 17 # # if (num == max) flag = 1; else if (num != 0) flag = -1; else flag = 0; cout > num; addi $s2, $0, 100 addi $v0, $0, 5 # syscall add $80, $v0, $0 # if (num == max) flag = 1; else if (num != 0) # flag = -1; # else flag = 0; cout 2.2.s) No Selection 1# 2 # CSc 256 Example 2.2: If statement, variables in registers 3 # Name: 4 # Date: 2/12/2020 5 # Description: Demonstrates if statement translation 6 # 7 # # #include 9 # int x=4, y=-1, sum=0; 10 # 11 # int main() 12 # { 13 # if (x != y) sum = sum + x; 15 # cout 2.1 (1).s) No Selection 1 .data 3 label1: .asciiz "please input the number: " label2: asciiz "the result is : " 7 .text main: li $s1, 4 # x = 4 li $s2, 5 # y = 5 li $s3, 10 # D = 10 # print string label1 #input an integer z to $50 through keyboard # D = x * x + y * Z # print string label2 # print integer D

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 23rd European Conference Adbis 2019 Bled Slovenia September 8 11 2019 Proceedings Lncs 11695

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Aida Kamisalic Latific

1st Edition

3030287297, 978-3030287290

More Books

Students also viewed these Databases questions