Presentation is loading. Please wait.

Presentation is loading. Please wait.

Solution to Problem 2.19.4 Recitation #1 (Week 2) ECEN350 Prof. Choi.

Similar presentations


Presentation on theme: "Solution to Problem 2.19.4 Recitation #1 (Week 2) ECEN350 Prof. Choi."— Presentation transcript:

1 Solution to Problem 2.19.4 Recitation #1 (Week 2) ECEN350 Prof. Choi

2

3

4 a)f(a,b,c)=func(func(a,b),c) f: addi $sp,$sp,–8 sw $ra,4($sp) sw $s0,0($sp) move $s0,$a2 jal func #v0=func($a0,$a1)=func(a,b) move $a0,$v0# $a0= func(a,b) move $a1,$s0# $a1=c jal func# v0=func($a0,$a1)=func($v0,c)=func(func(a,b),c) lw $ra,4($sp) lw $s0,0($sp) addi $sp,$sp,8 jr $ra

5 b) f(a,b,c)=func(a,b)+func(b,c) f: addi $sp,$sp,–12 sw $ra,8($sp) sw $s1,4($sp) sw $s0,0($sp) move $s0,$a1 move $s1,$a2 jal func# $v0=func($a0,$a1)=func(a,b) move $a0,$s0# $a0=b move $a1,$s1#$a1=c move $s0,$v0# $s0=$v0=func(a,b) jal func;#$v0=func($a0,$a1)=func(b,c) add $v0,$v0,$s0#$v0=func(a,b)+func(b,c) lw $ra,8($sp) lw $s1,4($sp) lw $s0,0($sp) addi $sp,$sp,12 jr ra


Download ppt "Solution to Problem 2.19.4 Recitation #1 (Week 2) ECEN350 Prof. Choi."

Similar presentations


Ads by Google