tutorial5

# tutorial5 - CS 230 Tutorial 5 February 7 2011 Jonathan...

This preview shows pages 1–12. Sign up to view the full content.

CS 230 Tutorial 5 February 7, 2011 Jonathan Rodriguez [email protected]

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
CS 230 Tutorial 5 • Assignment 2 Solutions • MIPS Arrays
Assignment 2 Question 3 Compute the square of the sum of \$1 and \$2

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Assignment 2 Question 3 \$3 = \$1 + \$2 \$3 = \$3 * \$3 return Compute the square of the sum of \$1 and \$2
Assignment 2 Question 3 \$3 = \$1 + \$2 \$3 = \$3 * \$3 return Compute the square of the sum of \$1 and \$2 add \$3, \$1, \$2 mult \$3, \$3 mflo \$3 jr \$31

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Assignment 2 Question 4 Compute \$1 to the power of \$2
Assignment 2 Question 4 if \$2 < 0: \$3 = 0 else: \$3 = 1 while \$2 > 0: \$3 = \$3 * \$1 \$2 = \$2 - 1 return Compute \$1 to the power of \$2

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Assignment 2 Question 4 Compute \$1 to the power of \$2 slt \$5, \$2, \$0 beq \$5, \$0, pos beq \$0, \$0, done pos: done: jr \$31 if \$2 < 0: \$3 = 0 else: \$3 = 1 while \$2 > 0: \$3 = \$3 * \$1 \$2 = \$2 - 1 return
Assignment 2 Question 4 Compute \$1 to the power of \$2 slt \$5, \$2, \$0 beq \$5, \$0, pos add \$3, \$0, \$0 beq \$0, \$0, done pos: done: jr \$31 if \$2 < 0: \$3 = 0 else: \$3 = 1 while \$2 > 0: \$3 = \$3 * \$1 \$2 = \$2 - 1 return

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Assignment 2 Question 4 Compute \$1 to the power of \$2 slt \$5, \$2, \$0 beq \$5, \$0, pos add \$3, \$0, \$0 beq \$0, \$0, done pos: addi \$3, \$0, 1 loop: slt \$7, \$0, \$2 beq \$7, \$0, done beq \$0, \$0, loop done: jr \$31 if \$2 < 0: \$3 = 0 else: \$3 = 1 while \$2 > 0: \$3 = \$3 * \$1 \$2 = \$2 - 1 return
Compute \$1 to the power of \$2 slt \$5, \$2, \$0 beq \$5, \$0, pos add \$3, \$0, \$0 beq \$0, \$0, done pos: addi \$3, \$0, 1 loop: slt \$7, \$0, \$2 beq \$7, \$0, done mult \$3, \$1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

### Page1 / 30

tutorial5 - CS 230 Tutorial 5 February 7 2011 Jonathan...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online