Lecture 33

Lecture 33 - 1 ECE52 Spring 13 Lecture 33 4/6/11...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 ECE52 Spring 13 Lecture 33 4/6/11 Protocomputer: Subroutines Midterm 2: Friday 4/8/11 2 Subroutine behavior • What if we just had “GOTO”: Given SQRT subroutine called from multiple places 000 <Program begins> … 109 READ X ; AC ← X 110 GOTO SQRT ; Always operates on AC by design 111 … ; Expect SQRT(X) in AC now … 149 READ Y ; AC ← Y 150 GOTO SQRT 151 … ; Again expect SQRT(Y) in AC now 1000 SQRT: … … 1097 GOTO 111 ; Return to where first called 3 Desired features for JSR/RET • Call a given function from many places (and return to where called from each time!) • Nest subroutine calls – to different functions – to the same function (recursion) • Each call matched by exactly one RETurn 4 Code Fragment 1 MAIN:… … 10 JSR SUB1 11 … … 20 HLT 21 SUB1: … … 25 JSR SUB2 26 … … 30 JSR SUB2 31 … … 40 RET 41 SUB2:… … 45 RET 5 Code Fragment 1 MAIN:… … 10 JSR SUB1 11 … … 20 HLT 21 SUB1: … … 25 JSR SUB2 26 … … 30 JSR SUB2 31 … … 40 RET 41 SUB2:… … 45 RET 6...
View Full Document

This note was uploaded on 07/05/2011 for the course ECE 52 taught by Professor Dr.jonathanboard during the Spring '11 term at Duke.

Page1 / 15

Lecture 33 - 1 ECE52 Spring 13 Lecture 33 4/6/11...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online