DOC PREVIEW
UW-Madison CS/ECE 252 - Chapter 8 and 9 I or O and Traps

This preview shows page 1-2-17-18-19-35-36 out of 36 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Introduction to Computer EngineeringChapter 8 & 9.1 I/O and TrapsI/O: Connecting to Outside WorldI/O: Connecting to the Outside WorldI/O ControllerProgramming InterfaceMemory-Mapped vs. I/O InstructionsTransfer TimingTransfer ControlLC-3Input from KeyboardBasic Input RoutineSimple Implementation: Memory-Mapped InputOutput to MonitorBasic Output RoutineSimple Implementation: Memory-Mapped OutputKeyboard Echo RoutineInterrupt-Driven I/OSlide 19PriorityTesting for Interrupt SignalFull Implementation of LC-3 Memory-Mapped I/OSystem CallsSystem CallLC-3 TRAP MechanismTRAP InstructionTRAPRET (JMP R7)TRAP Mechanism OperationExample: Using the TRAP InstructionExample: Output Service RoutineTRAP Routines and their Assembler NamesSaving and Restoring RegistersExampleSlide 35SummaryIntroduction to Computer EngineeringCS/ECE 252, Fall 2007Prof. Mark D. HillComputer Sciences DepartmentUniversity of Wisconsin – MadisonChapter 8 & 9.1I/O and Traps8-3Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.I/O: Connecting to Outside WorldSo far, we’ve learned how to:•compute with values in registers•load data from memory to registers•store data from registers to memoryBut where does data in memory come from?And how does data get out of the system so thathumans can use it?8-4Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.I/O: Connecting to the Outside WorldTypes of I/O devices characterized by:•behavior: input, output, storageinput: keyboard, motion detector, network interfaceoutput: monitor, printer, network interfacestorage: disk, CD-ROM•data rate: how fast can data be transferred?keyboard: 100 bytes/secdisk: 30 MB/snetwork: 1 Mb/s - 1 Gb/s8-5Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.I/O ControllerControl/Status Registers•CPU tells device what to do -- write to control register•CPU checks whether task is done -- read status registerData Registers•CPU transfers data to/from deviceDevice electronics•performs actual operationpixels to screen, bits to/from disk, characters from keyboardGraphics ControllerControl/StatusOutput DataElectronicsCPUdisplay8-6Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Programming InterfaceHow are device registers identified?•Memory-mapped vs. special instructionsHow is timing of transfer managed?•Asynchronous vs. synchronousWho controls transfer?•CPU (polling) vs. device (interrupts)8-7Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Memory-Mapped vs. I/O InstructionsInstructions•designate opcode(s) for I/O•register and operation encoded in instructionMemory-mapped•assign a memory address to each device register•use data movement instructions (LD/ST)for control and data transfer8-8Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Transfer TimingI/O events generally happen much slowerthan CPU cycles.Synchronous•data supplied at a fixed, predictable rate•CPU reads/writes every X cyclesAsynchronous•data rate less predictable•CPU must synchronize with device,so that it doesn’t miss data or write too quickly8-9Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Transfer ControlWho determines when the next data transfer occurs?Polling•CPU keeps checking status register until new data arrives OR device ready for next data• “Are we there yet? Are we there yet? Are we there yet?”Interrupts•Device sends a special signal to CPU whennew data arrives OR device ready for next data•CPU can be performing other tasks instead of polling device.• “Wake me when we get there.”8-10Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.LC-3 Memory-mapped I/O (Table A.3)Asynchronous devices•synchronized through status registersPolling and Interrupts•the details of interrupts will be discussed in Chapter 10Location I/O Register FunctionxFE00Keyboard Status Reg (KBSR)Bit [15] is one when keyboard has received a new character.xFE02Keyboard Data Reg (KBDR)Bits [7:0] contain the last character typed on keyboard.xFE04Display Status Register (DSR)Bit [15] is one when device ready to display another char on screen.xFE06Display Data Register (DDR)Character written to bits [7:0] will be displayed on screen.8-11Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Input from KeyboardWhen a character is typed:•its ASCII code is placed in bits [7:0] of KBDR(bits [15:8] are always zero)•the “ready bit” (KBSR[15]) is set to one•keyboard is disabled -- any typed characters will be ignoredWhen KBDR is read:•KBSR[15] is set to zero•keyboard is enabledKBSRKBDR15 8 7 01514 0keyboard dataready bit8-12Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Basic Input Routinenewchar?readcharacterYESNOPollingPOLL LDI R0, KBSRPtr BRzp POLL LDI R0, KBDRPtr ...KBSRPtr .FILL xFE00KBDRPtr .FILL xFE028-13Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Simple Implementation: Memory-Mapped InputAddress Control Logicdetermines whether MDR is loaded from Memory or from KBSR/KBDR.8-14Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Output to MonitorWhen Monitor is ready to display another character:•the “ready bit” (DSR[15]) is set to oneWhen data is written to Display Data Register:•DSR[15] is set to zero•character in DDR[7:0] is displayed•any other character data written to DDR is ignored(while DSR[15] is zero)DSRDDR15 8 7 01514 0output dataready bit8-15Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Basic Output Routinescreenready?writecharacterYESNOPollingPOLL LDI R1, DSRPtrBRzp POLLSTI R0, DDRPtr...DSRPtr .FILL xFE04DDRPtr .FILL xFE068-16Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Simple Implementation: Memory-Mapped OutputSets LD.DDRor selects DSR as input.8-17Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Keyboard Echo RoutineUsually, input character is also printed to screen.•User gets feedback on character typedand knows its ok to type the


View Full Document
Download Chapter 8 and 9 I or O and Traps
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Chapter 8 and 9 I or O and Traps and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Chapter 8 and 9 I or O and Traps 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?