









































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










































BME303 Intro. to Computing
-^ I/O Basics - Device registers– Memory-mapped I/O vs.Special I/O instructions – Asynchronous vs.Synchronous -^ Input from the KeyboardO t
t t
th
it
-^ Output to the monitor•^ Interrupt-Driven I/O
te^
upt^
e^
BME303 Intro. to Computing
-^ Input: Devices for transferring information to the computer, such as -^ keyboard, mouse, scanner, card reader, disk -^ Output: Devices for transferring information from the computer, suchas -^ console, printer, LED display, disk
BME303 Intro. to Computing
BME303 Intro. to Computing
I/O for the LC-3 (keyboard/console)I/O for the LC 3 (keyboard/console)•^ I/O for the LC-3 could be accomplished via the TRAP instruction•^ Different types of I/O service can be requested by choosing anappropriate trapvector (TV) for this instructionTrap Vector
Name
Description (Appendix A, page 543)
x^
GETC
Reads a single character from the keyboard and stores itsZEXT ASCII code in R0 (no echo on the console).
x^
OUT^
Writes a character in R0<7:0> to the console.
x^
PUTS
Writes the string beginning at M[R0] to the console.
x^
IN^
Prints prompt on console, reads a character from thekeyboard that is echoed on the console, then stores itsZEXT ASCII code in R0.
x^
PUTSP
see Appendix A, table A.2, page 543.
x^
HALT
Prints message to console; halts execution.
BME303 Intro. to Computing
Memory-Mapped vs I/O InstructionsMemory Mapped vs. I/O Instructions•Instructions– designate opcode(s) for I/O– register and operation encoded in instruction^ •Memory-mapped (LC-3)– assign a memory address
to each device registerto each device register– use existing data movementinstructions (LD/ST)for control and data transfer for control and data transfer
KDR
BME303 Intro. to Computing
d t^
t^ l^
di t bl
synchronize
with device,
so that it doesn’t miss data or write too quickly
BME303 Intro. to Computing
d^
i^
d^
i^
d^ f
d
new data
arrives OR
device ready
for next data
arrives OR
device ready
for next data
new
data
arrives
device
ready
for^
next data
h^
t th^
•Memory-mapped I/O
(Table A.3)
Location
I/O Register
Function
g
xFE
Keyboard Status Reg(KBSR)
Bit [15] is one when keyboardhas received a new character.Bits [7:0] contain the last
xFE
Keyboard Data Reg (KBDR)
Bits [7:0] contain the last character typed on keyboard.
xFE
Display Status Register(DSR)
Bit [15] is one when device readyto display another char on
(DSR)
p^ y screen.
xFE
Display Data Register (DDR)
Character written to bits [7:0] will be displayed on screen.
•Asynchronous devices– synchronized through status registersP lli
d I t
t
•Polling and Interrupts– the details of interrupts will be discussed in Chapter 10
BME303 Intro. to Computing
BME303 Intro. to Computing
new
R0, KBSRPtr BRzp POLLLDI
R0, KBDRPtr
new char? NO P^ lli
R0, KBDRPtr ...
KBSRPtr
FILL xFE
YES read
Polling
KBSRPtr
.FILL xFE KBDRPtr .FILL xFE
character
BME303 Intro. to Computing
1
5
1
2
5
Address Control Logicdetermines whetherMDR is loaded from
2
Memory or from KBSR/KBDR.
3
3
4
BME303 Intro. to Computing
•When Monitor is ready to display another character:
y^
p^ y
15
8 7
0
output data DDR DSR
1514
0
ready bit •When data is written to Display Data Register:– DSR[15] is set to zero
- current data -^ character in DDR[7:0] is displayedcharacter
in DDR[7:0] is displayed
BME303 Intro. to Computing
R1, DSRPtr BRzp POLLSTI
R0, DDRPtr
screenready? NO
R0, DDRPtr ... DSRPtr
FILL xFE
YES write
Polling
DSRPtr
.FILL xFE DDRPtr .FILL xFE
character
Write when the ready bit is “1”
BME303 Intro. to Computing
1
5
(^23)
3
4 Sets LD.DDRor selects DSR as input.