DerekChiou_EE306_Spring2009_Lecture16

DerekChiou_EE306_Spring2009_Lecture16 -...

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

View Full Document Right Arrow Icon
© Derek Chiou Lecture 16: Subroutines/TRAPs  continued Prof. Derek Chiou University of Texas at Austin
Background image of page 1

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

View Full DocumentRight Arrow Icon
Announcements My office hours next Monday (March 31 st ) are 5:30PM-6:30PM Don’t forget about Lab 2! 3/25/2009 © Derek Chiou : EE306: Lecture 16 2
Background image of page 2
3/25/2009 © Derek Chiou : EE306: Lecture 16 Recap I/O revisited Stacks Started subroutines/TRAPs Outline Finish subroutines Discuss TRAPs 3
Background image of page 3

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

View Full DocumentRight Arrow Icon
Reusing Code / TRAPs and  Subroutines Jump to subroutine (shared code) Return to instruction after jump afterwards, as if nothing had happened other than the correct value being available where it should be (e.g., R0 in case of read input device) Need to protect registers that contain “live” values 3/25/2009 © Derek Chiou : EE306: Lecture 16 4
Background image of page 4
Example: Input a character subroutine INPUT LDI R3, KBSR BRzp INPUT LDI R0, KBDR RET KBSR .FILL xFE00 KBDR .FILL xFE02 3/25/2009 © Derek Chiou : EE306: Lecture 16 5 Issues?
Background image of page 5

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

View Full DocumentRight Arrow Icon
Example: Input a character subroutine  (2) ST R3, SAVE_R3 ST R0, SAVE_R0 INPUT LDI R3, KBSR BRzp INPUT LDI R0, KBDR LD R0, SAVE_R0 LD R3, SAVE_R3 RET KBSR .FILL xFE00 KBDR .FILL xFE02 SAVE_R3 .BLKW 1 .SAVE_R0.BLKW 1 3/25/2009 © Derek Chiou : EE306: Lecture 16 6 What if we want to echo keystroke?
Background image of page 6
Registers on TRAP/Subroutine Call Must be saved and restored to provide registers to the TRAP/subroutine code Caller-saved The code before the TRAP/JSR/JSRR performs the save The code after the TRAP/JSR/JSRR performs the restore Pros? Cons? Callee-saved
Background image of page 7

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

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

Page1 / 21

DerekChiou_EE306_Spring2009_Lecture16 -...

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

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