Input - Output (I/O)
– I/O devices are controlled by reading and/or writing bit
patterns to/from special registers associated with the
particular device. These registers are very similar to ordinary
memory locations, but are located on the I/O devices
interface card, which sits between the device and the
computer bus.
– These registers are connected to PORTS. One way of
remembering what a PORT means is P(ort) means
P(hysical) connection via wires to P(eripheral).
– On many computers (e.g. Motorola 68000) I/O devices are
all memory-mapped, that is their registers appear to the
CPU exactly like ordinary memory locations. Therefore there
are no special I/O instructions - the ordinary mov
instructions suffice.
I/O on the 8086 (D6)
– On the 8086 however most I/O is done via special in and
out instructions, which refer to a completely separate 16 bit
I/O memory-map.
– The out instruction writes a byte to a register associated
with an output device.
– Similarly the in instruction inputs a byte from an input
device.
The OUT instruction
The IN and out instructions are always used in conjuction with
the DX and AL registers.
out dx,al
– outputs the byte stored in al to the output port indicated by the
contents of dx. So
mov dx,4100
mov al,08
out dx,al
– Writes the bit pattern 00001000 to the output device connected to
port 4100. This bit pattern will have an effect that depends on the
device that is connected physically to the port at this address.
On a D6 it will output a 1 to the speaker.
The OUT Instruction
Select Port Data Sent to Port
– Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Port Address [4100] 0 0 0 0 1 0 0 0
Speaker
Output a “1” on bit 3 of byte sent to address 4100 switches the
Speaker “ON”.
Output a “0” on bit 3 of byte sent to address 4100 switches the
Speaker “OFF”.
Continuous ON/OFF/ON... switching of bit 3 creates an
ON/OFF/ON… pulse that causes the speaker to emit a sound.
The Displays
– Each display consists of 8 elements, the seven segments
that make up the characteristic "8" shape, and a small dot to
the bottom right of the "8". Each bit of the byte written to
4106 turns on or off one of these elements. Confusingly a 0
turns an element on, and a 1 turns it off (reverse logic). The
relationship between bits and elements is given below
bit 0 - top bar
bit 1 - top right bar
bit 2 - bottom right bar
bit 3 - bottom bar
bit 4 - bottom left bar
bit 5 - top left bar
bit 6 - middle bar
bit 7 - the dot
The Keypad
– The D6 keypad consists of three rows, each consisting of 8
keys.
– We use the OUT instruction to send out a signal (strobe) to
the keypad. We use the IN instruction to read back in the
signal as modified by a key-press.
– Two I/O registers are associated with the D6 keypad.
– To determine what key or keys are currently being held
down we strobe each row individually, by setting one of the
bottom three bits of the byte in address 4100 to zero.
– Bit 0 corresponds to the bottom row, bit 1 to the middle row,
and bit 2 to the top row.
– Again negative logic is being used, so by writing 110 to the
bottom three bits, we are actually strobing the bottom row,
101 corresponds to the middle row, and 011 to the top row.
- After issuing the strobe, we then read the contents of I/O
register 4101 to find out if a key or keys on that row are
being pressed down.
– Each bit from 4101 corresponds to a particular key, with 0
indicating that the key is depressed, 1 indicating that it is not.
Bit 0 corresponds to the leftmost key on the row, bit 7 to the
rightmost. If 4101 returns a value of 11111111, no keys are
being pressed.
.CODE
.STARTUP
start: mov dx,4100 ; Row Port Address Select
mov al,05 ; Select Middle Row
out dx,al ; Strobe Middle
mov dx,4101 ; Select Column Port Address
in al,dx ; Read in Keypress
Spring 2001 CA103 Computer Architecture
Saturday, December 8, 2007
Advanced Microprocessors 8086 Interfacing
Posted by Biplav at 10:20 AM
Labels: Advanced Microprocessors 8086, Fifth Semester, Laboratory
Subscribe to:
Post Comments (Atom)
1 comment:
the display u told abt..can u explain it like for eg if i hav to display fire help wat will b the codes for it???could u just tell it briefly!!!asap...
Post a Comment