Title: Basic Input/Output
1Basic Input/Output
Wannachai Wannasawade Department of Computer
Education Faculty of Technical Education, KMITNB.
2Basic Input/Output
- ?????????????????????????????????????????????????
????????????? ??????????????????????????????????-?
??????? ??????????????? I/O port
??????????????????????????????????????????????????
???????????????????????????????????? - ????????????????????-??????????????????????????
2 ????????? - ?????????? (Parallel)
- ???????????? (Serial)
- ?????????????????????????????????????????????????
????????? ?????????????????????????
???????????????? ?????????????????????????????????
??????????? ????????? 8 ??? 16 ??? 32 ??? ???? 64
??? ?????? ???????????????????????????????????????
???????????????????????????
3Basic Input/Output
- ??????????????????????????????? ??????????????
??????????????????????????? ??????????????????????
?????????????????????? ???????????????????????????
???????????????? ?????????????????????????????????
???? ???? ????????????????????? (Full-Duplex)
??????????????????? 3 ???? - Transmit Data
- Receive Data
- Common Ground between Computer and Peripheral
4Basic Input/Output
Type of Input/Output
- Parallel I/O
- Serial I/O
- Programmed I/O
- Interrupt-Driven I/O
- Direct Memory Access
5Basic Input/Output
I/O Instructions
?????????????????????????????????????????????????
??-???????????? ? ?????????? 2 ?????????? ?
??? IN ????????????????????????????????????????
???????-???????? OUT ????????????????????????????
?????????????????????????-????????
6Basic Input/Output
- Instruction Data Width Function
- IN AL,p8 8 Read byte from port p8(8 bit) into AL
- IN AX,p8 16 Read word from port p8(8 bit) into
AX - IN EAX,p8 32 Read doubleword from port p8(8 bit)
into EAX - IN AL,DX 8 Read byte from port address by DX into
AL - IN AX,DX 16 Read word from port address by DX
into AX - IN EAX,DX 32 Read doubleword from port address by
DX into EAX - INSB 8 Read byte from port address by DX into
Extra Segment by DI DI (,-) 1 - INSW 16 Read word from port address by DX into
Extra Segment by DI DI (,-) 2 - INSD 32 Read doubleword from port address by DX
into Extra Segment by DI DI (,-) 4
7Basic Input/Output
Instruction Data Width Function OUT
p8,AL 8 Write byte from AL to port p8(8 bit) OUT
p8,AX 16 Write word from AX to port p8(8
bit) OUT p8,EAX 32 Write double word from EAX to
port p8(8 bit) OUT DX,AL 8 Write byte from AL to
port address by DX OUT DX,AX 16 Write word from
AX to port address by DX OUT DX,EAX 32 Write
double word from EAX to port address by
DX OUTSB 8 Write byte from Data Segment to port
address by DX SI SI(,-)1 OUTSW 16 Write
word from Data Segment to port address by DX
SI SI(,-)2 OUTSD 32 Write double word from
Data Segment to port address by DX SI
SI(,-)4
8Basic Input/Output
???????????????? 2 ??????????????????????????????
??? Accumulator ??????????????????? (AL, AX, EAX)
??????? I/O Address ????????????? Register DX
????????? 16 ??? ???? 8 ??? ?????????? Opcode ???
Intel ????? port ???? 8 ??? (p8) ???? Fixed
Address ??? 16 ??????????????? DX ???? Variable
Address I/O Address ???????????? Port Number
???? Fixed port number (p8) ??????????????
Address 8 ??????? A0-A7 (0-255 ???? 0000H-00FFH)
???? Variable port number ???????????? Address 16
??????? A0-A15(0-65535 ???? 0000H-FFFFH) ??????
256 ????????????????????????????? Fixed port
number ??? Variable port number
??????????????????????? Variable port number
???????? ????????????????????????????????????????
???????????-?????????????????? 00XXH-03XXH
9Basic Input/Output
Isolated I/O
???? I/O ????????????????????????????????????????
??????? I/O Address ????????? I/O ????????
Ports ????????????????????? ????????????????????
??????????????????????????????????????? I/O port
??????????????????? ??????????????????????????????
????? ???????????? M/IO ??? W/R ??????? IORC ???
IOWC Isolate I/O ????????????????????????????????
??? port ???? 8 ?????????????????? System Board
???? port ???? 16 ????????????????????????????????
??????
FFFFFH
1M X 8
0FFFFH
64K X 8
00000H
00000H
Isolate I/O
10Basic Input/Output
Memory Mapped I/O
?????????????????????????????????????????????????
?????????? I/O ?????????????????
???????????????????????????????????? ????????
????????????????????????????? ????????????????????
???????????????????? ???????????????
???????????????????????? I/O (IN, INS, OUT, OUTS)
??????????????????????????????????????????????????
?????????????? ??? I/O ???
11Basic Input/Output
Personal Computer I/O Mapped
Port 0000H-03FFH ?????????????????????????? Port
0400H-FFFFH ????????????????
12Basic Input/Output
Basic Input
13Basic Input/Output
- Basic Input Interface
- Three-State Buffer
- External TTL connect to inputs of buffer
- Outputs of buffer connect to Data bus
- Data bus size depend on version of the
Microprocessor such as 8086 has data bus 16 bits
80486 has data bus 32bits and Pentium II has data
bus 64 bits - Microprocessor can receive data when execute IN
Instruction
14Basic I/O Interface Output
15Basic Input/Output
- Basic Output Interface
- Receive data from Microprocessor and must hold
data for some external device - Latches or Flip-flop, like the buffers
- Used OUT instruction then send data from AL,
AX, EAX - Data must hold until next OUT Instruction
execute
16Basic Input/Output
- Handshaking
- Many I/O device much slower rate than the
microprocessor. Thus, How to control I/O device? - Handshaking or Polling
- Synchronizes the I/O with the microprocessor
- Example Parallel Printer BUSY indicates that
the printer busy and STB is clock pulse used to
send data to printer
17Basic Input/Output
Input Device ???????? ?????? TTL
??????????????????????????????????
???????????????????????? ??????????????????????
?????????????????????????????????????????
????????????????? Resistor ??????????? R Pull-up
??????????????????????? ( TTL Logic Level
0 0.0 V - 0.8 V 1 2.0 V - 5.0 V )
????????? R ??????????? 1KW - 10KW
??????????????????????????????????
??????????????????????????????????????????????????
??????????????????????????????????????????????????
??????????????????????????????????
18Basic Input/Output
19Basic Input/Output
20Basic Input/Output
Output Device ??????????????????????????????????
???????? ??????????????????????
????????????????????????? ????????????????????????
???????????????????????????????? TTL
??????????????????????????????? ???????? 0
?????????????????? 0.0 V - 0.4 V ???????? 1 ???
2.4 V - 5.0 V ???????????????????????? 0
????????? 0.0 - 2.0 mA ??????????? 1 ?????????
0.0 - 400 mA
21Basic Input/Output
22Basic Input/Output
23Basic Input/Output
I/O Port Address Decode
??? Decode Address ??? I/O ????????????? Decode
Address ??????????????????? I/O
?????????????????? ?????????????????????????
???????? ?????? Address ?????? ???? Decode
?????????????????????? Address A0-A31, A0-A24
???? A0-A19 ??? I/O ????????? Address ??? A0-A15
???????? ????????????????????? ??? IORC ??? IOWC
??????????? Decode ????
24I/O Port Decoding
25Basic Input/Output
8 Bit Decode
26Basic Input/Output
16 Bit Decode
27Basic Input/Output
16 Bit 2 Bank Decode
28Basic Input/Output
16 Bit Decode
29Basic Input/Output
32 Bit Decode
30Use 8 LEDs
A19
A18
A0
mov al, 55 out dx, al
D7
D6
D5
D4
D3
D2
8088
D1
Minimum
D0
Mode
IOR
IOW
31Use of 74LS245 and Address Decoder
A19
A18
A0
D7
D6
D5
D4
D3
D2
8088
D1
Minimum
D0
Mode
IOR
mov al, 55 mov dx, F000 out dx, al
IOW
32Use of 74LS373 and Address Decoder
A19
A18
A0
D7
D6
D5
D4
D3
D2
8088
D1
Minimum
D0
Mode
IOR
mov al, 55 mov dx, F000 out dx, al
IOW
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
IOW
1
1
1
1
1
1
9
8
7
6
5
4
3
2
1
0
5
4
3
2
1
0
33Use of 74LS245 and Address Decoder
A19
5V
A18
A0
D7
D6
D5
D4
D3
D2
8088
D1
Minimum
D0
Mode
IOR
mov dx, F000 in al, dx
IOW
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
IOR
1
1
1
1
1
1
9
8
7
6
5
4
3
2
1
0
5
4
3
2
1
0
Same address for input and output?
34Polling
mov dx, F000 in al, dx L1 cmp al, FF je
L1