Lecture_4 - CSE 331 Computer Organization and Design Spring...

Info icon This preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE331 W04.1 KB 2008Fall PSU CSE 331 Computer Organization and Design Spring 2010 Week 4 Section 1 & Section 2: K. Bhat. Course material on ANGEL: cms.psu.edu [Many thanks to Mary Jane Irwin’s Slides adapted from D. Patterson slides ]
Image of page 1

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

View Full Document Right Arrow Icon
CSE331 W04.2 KB 2008Fall PSU Head’s Up Last week’s material MIPS control flow and logic operations This week’s material Supporting procedure calls and returns; addressing modes - Reading assignment - PH: 2.7-2.9, A.6, D.2 Next week’s material Assemblers, linkers and loaders - Reading assignment - PH: 2.10, A.1-A.5 Reminders CMPEN331,1&2 Exam 1 on 2/15/2010. 6:30-7:45 pm. - 26 Hosler CMPEN 331,1&2) EXAM 2 - 3/31/2010 - 6:30-7:45 pm - 26 Hosler
Image of page 2
CSE331 W04.3 KB 2008Fall PSU The reality is that most code is not heavily performance-bound by the lack of one instruction. … So the belief that the microprocessor is but one or two instructions away from blindingly higher speed is almost always wrong. Bob Colwell, The Pentium Chronicles
Image of page 3

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

View Full Document Right Arrow Icon
CSE331 W04.4 KB 2008Fall PSU Review: MIPS Organization Processor Memory 32 bits 2 30 words read/write addr read data write data word address (binary) 0…0000 0…0100 0…1000 0…1100 1…1100 Register File src1 addr src2 addr dst addr write data 32 bits src1 data src2 data 32 registers ($zero - $ra) 32 32 32 32 32 32 5 5 5 PC ALU 32 32 32 32 32 0 1 2 3 7 6 5 4 byte address (big Endian) Fetch PC = PC+4 Decode Exec Add 32 32 4 Add 32 32 br offset
Image of page 4
CSE331 W04.5 KB 2008Fall PSU Programming Styles Procedures (or subroutines, functions) perform specific tasks based on the parameters provided. Reusable. Clever use of procedures in programs helps and debug the program Procedures allow the programmer to concentrate on one portion of the code at a time parameters act as barriers between the procedure and the rest of the program and data, allowing the procedure to be passed values ( arguments ) and to return values ( results )
Image of page 5

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

View Full Document Right Arrow Icon
CSE331 W04.6 KB 2008Fall PSU Six Steps in Execution of a Procedure Main routine ( caller ) places parameters in a place where the procedure ( callee ) can access them $a0 - $a3 : four argument registers Caller transfers control to the callee Proc. Callee acquires the storage resources needed Callee performs the desired task Callee places the result value in a place where the caller can access it $v0 - $v1 : two value registers for result values Callee returns control to the caller $ra : one return address register to return to the point of origin
Image of page 6
CSE331 W04.7 KB 2008Fall PSU MIPS procedure call instruction: jal ProcAddress #jump and link Saves PC+4 in register $ra as the link to the following instruction to set up the procedure return Machine format: Then can do procedure return with just jr $ra #return Instruction for Calling a Procedure op 26 bit address J format 3 ????
Image of page 7

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

View Full Document Right Arrow Icon
CSE331 W04.8 KB 2008Fall PSU Basic Procedure Flow For a procedure that computes the GCD of two values i (in $t0 ) and j (in $t1 ) gcd(i,j); The caller puts the i and j (the parameters values) in $a0 and $a1 and issues a jal gcd #jump to routine gcd The callee computes the GCD, puts the result in $v0 , and returns control to the caller using gcd: . . . #code to compute gcd jr $ra #return
Image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern