Lecture_6 - ECE 445 Computer Organization Structured...

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

View Full Document Right Arrow Icon
ECE 445 – Computer Organization Structured Programming and The Stack (Lecture #6)
Background image of page 1

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

View Full DocumentRight Arrow Icon
ECE 445 - Computer Organization 2 Structured Programming
Background image of page 2
ECE 445 - Computer Organization 3 Structured Programming Structured programming is a subset of procedural programming that enforces a logical structure on the program being written to make it more efficient and easier to understand and modify. Structured programming frequently employs a top-down design model, in which developers map out the overall program structure into separate subsections. A structured program is composed of - Functions - Procedures - Subroutines
Background image of page 3

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

View Full DocumentRight Arrow Icon
ECE 445 - Computer Organization 4 Structured Programming To execute a subroutine, the program needs to: 1. Pass parameters to the procedure 2. Transfer control 3. Acquire storage needed 4. Perform the desired task 5. Return values to the calling procedure 6. Return control #1, #5 – parameter passing; #3 – storage - Requires memory and/or registers #2, #6 – jump
Background image of page 4
ECE 445 - Computer Organization 5 Registers and Procedure Calls Registers are faster than memory. - Therefore, use registers to implement parameter passing and jumps. Registers $a0 - $a3 - Parameter passing Registers $v0 - $v1 - Return values Register $ra - Return address - Set by jal instruction; used by jr instruction See MIPS Reference Card
Background image of page 5

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

View Full DocumentRight Arrow Icon
ECE 445 - Computer Organization 6 Registers and Procedure Calls Registers $s0 - $s7 - preserved across a procedure call.
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 23

Lecture_6 - ECE 445 Computer Organization Structured...

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

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