1 / 5

Solution to Problem 2.19.4

Solution to Problem 2.19.4. Recitation #1 (Week 2) ECEN350 Prof. Choi. 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

samson
Download Presentation

Solution to Problem 2.19.4

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Solution to Problem2.19.4 Recitation #1 (Week 2) ECEN350 Prof. Choi

  2. 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 jalfunc #v0=func($a0,$a1)=func(a,b) move $a0,$v0 # $a0= func(a,b) move $a1,$s0 # $a1=c jalfunc # 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

  3. 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 jalfunc # $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) jalfunc; #$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 jrra

More Related