0% found this document useful (0 votes)
12 views8 pages

Input Output

The document discusses the differences between memory-mapped I/O and isolated I/O in the context of the 8086 microprocessor. It explains how memory-mapped I/O uses the same address space as memory, while isolated I/O has a separate address space and requires dedicated instructions. Additionally, it provides examples of input/output instructions and applications, such as controlling a thermometer and printing characters on a VGA display.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views8 pages

Input Output

The document discusses the differences between memory-mapped I/O and isolated I/O in the context of the 8086 microprocessor. It explains how memory-mapped I/O uses the same address space as memory, while isolated I/O has a separate address space and requires dedicated instructions. Additionally, it provides examples of input/output instructions and applications, such as controlling a thermometer and printing characters on a VGA display.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Input/ Output

I/O vs. Memory mapped I/O


Heba Abdel-Nabi, Ph.D.
Introduction

❑ 8086 uses 16 address bits → A[15:0] to locate an I/O port


❑ 64k address space → 65,536 possible I/O ports
❑ Data transfer between ports and the processor is done over data bus
❑I/O devices serve two main purposes: To communicate with outside world
and to store data

Data bus
AL
AX
I/O I/O I/O

8086

Address bus A[15:0]

Based on Dr. Esam Slides

2
I/O address mapping
1. Memory-mapped I/O
• Uses the same shared memory of 8086
• Reading and writing are similar to memory read/write, e.g. MOV, XCHG
• Uses same memory read and write signals

2. Isolated I/O (AKA I/O mapped I/O)


• Separate I/O address space, thus, separate I/O read and write signals are needed
• uses dedicated I/O instructions (IN and OUT).
• 64 KB address space, can be any combination of 8- and 16-bit I/O ports

FFFFF FFFFF
Range of memory
Memory addresses
addressing I/O assigned for I/O transfers
space FFFF I/O
addressing Memory addressing
00000 space
00000 0000 space
Isolated I/O Memory-mapped I/O
Based on Dr. Esam Slides

3
I/O address mapping

I/O mapped I/O memory mapped I/O


Treated as an I/O device (has a Treated as a memory location (has a
Discussed later
separate 8- or 16- I/O address) 20-bit memory address)
Given an IOR’ and IOW’ signals Given an MEMR’ and MEMW’ signals
Can be accessed by IN/ OUT Can be accessed using any memory
instruction instruction
Only work with AL/AX registers Can work with any register
Example: Thermometer Example: Video Graphic arrays (VGA)
card →address of 0B8000H

4
Memory-mapped vs. Isolated I/O
Memory Space
00000
I/O Space
0000

1M  8
64K  8

FFFFF FFFF
Discussed later
IO/M = 0 IO/M = 1

MOV AX, DATA ; To Read from PORTA


MOV DS, AX MOV DX, PORTA
MOV BX, OFFSET IN AL, DX
; To Read from a Memory Location
MOV AL, [BX] ; To Write to PORTB
MOV DX, PORTB
MOV AL, VALUE
; To Write to a Memory Location
OUT DX, AL
MOV AL, VALUE
MOV [BX], AL

5
Input / Output Instructions
• For 8-bit port (data transferred size is 8 bits)
• Two possibilities (8-bit address or 16-bit address)
IN AL, Port # OUT Port #, AL → directly

MOV DX, Port # MOV DX, Port # → indirectly


IN AL, DX OUT DX, AL

• For 16-bit port (data transferred size is 16 bits)


• Two possibilities (8-bit address or 16-bit address)

IN AX, Port # OUT Port #, AX → directly

MOV DX, Port # MOV DX, Port # → indirectly


IN AX, DX OUT DX, AX

6
Example: thermometer control
again:
in al, 125 ; Data port Task: Control the thermometer
cmp al, 80 to maintain the temperature
jae off within the range of 60°C to
cmp al,60 80°C.
jb on •If the temperature drops
jmp again below 60°C, turn on the flame.
•If the temperature rises to or
above 80°C, turn off the flame.
off:
mov al,0
out 127,al ; Control port
jmp again

on:
mov al,1
out 127,al
jmp again
Example: VGA
• Print characters ‘a’ and ‘b’ directly without using DOS interrupt

mov ax, 0b800h


mov ds, ax

mov [0000],'a' ; each character takes two bytes


mov [0001],02h ; change the characteristics of the character
mov [0002],'b'
mov [0003],65h

You might also like