1 / 24

Announcements

Announcements. Assignment #1 due today. Tutorials. Course web page? Assignment #2: 2.13, 2.18, 2.23, due 26 Oct. at beginning of class. Lecture 5. Chapter 2 ( Cont .) Machine Instructions and Programs. Basic Input/Output Operations.

ray-ramsey
Télécharger la présentation

Announcements

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. Announcements Assignment #1 due today. Tutorials. Course web page? Assignment #2: 2.13, 2.18, 2.23, due 26 Oct. at beginning of class.

  2. Lecture 5 Chapter 2 (Cont.) Machine Instructions and Programs

  3. Basic Input/Output Operations • Speed mismatch bet. CPU and I/O devices  synchronization problem. • Input: CPU waits for a signal from keyboard that a character is ready. • Output: CPU sends character to the display and waits for a signal that it was displayed, then sends the next character. Device Interface

  4. I/O Transfers

  5. I/O Example Program Why MoveByte?

  6. Stacks • Pushdown stack = Last-In-First-Out (LIFO) stack. • Operations: push and pop Push operation Pop operation Other addressing modes?

  7. Stacks

  8. Stacks Routine for a safe push operation Routine for a safe pop operation Full stack  SP=? Empty stack  SP=?

  9. Queues • First-In-First-Out (FIFO). • Two pointers at the two ends. • Circular buffer (queue).

  10. Subroutines • Similar to C functions. Used to save space. • Any program that requires the use of the subroutine simply branches to its starting location. • A program branches to a subroutine = it calls the subroutine  CALL instruction. • Main program = calling program. • Subroutine = called program. • The subroutine returns to the program that called it by executing a RETURN instruction. • The main program resumes execution continuing immediately after the instruction that called the subroutine (PC).

  11. Subroutine Linkage

  12. Subroutine Nesting and the Processor Stack • Subroutine nesting: one subroutine calls another • Link register method cannot be used. Why? • Return addresses are generated and used in a last-in–first-out order  stack. • Call instruction: pushes [PC] onto top of processor stack and loads PC with the address of subroutine’s start location. • Return instruction: pops top of stack into PC.

  13. SubroutinesParameter passing through registers

  14. SP SP SP SP SP SubroutinesParameter passing through processor stack Processor stack n is passed by value Numbers: by reference

  15. SubroutinesStack frame Subroutine Move R0,–(SP) Move R1, –(SP) …… Move (SP)+,R1 Move (SP)+,R0 Add #12,SP Move (SP)+,FP Return

  16. Nested SubroutinesStack frame

  17. Logic Instructions • Not R0 • Not R0 Add #1, R0 • Negate R0

  18. Logical Shift Instructions

  19. Arithmetic Shift Instructions

  20. Example Program

  21. Rotate Left Instructions

  22. Rotate Right Instructions

  23. Multiplication and Division Instructions • Multiply Ri, Rj • Rj  [Ri] x [Rj] • R(j+1):Rj  [Ri] x [Rj] • Divide Ri,Rj • Rj  [Rj] / [Ri] • Rj  quotient, R(j+1)  remainder

  24. Reading Material • Textbook, Chapter 2, pages 64 - 98

More Related