written 6.1 years ago by |
I/O addresses in 8086 can be either 8–bit or 16-bit. I/O addresses can be used in two modes, direct and indirect addressing modes.
Direct Addressing Mode:
If we use 8-bit I/O address we get a range of 00H -- FFH. This gives a total of 256 I/O ports. Here we use Direct addressing Mode, that is, the I/O address is specified in the instruction.
Example:
IN AL, 80H ; AL gets data from I/O port address 80H.
IN AX, 80H ; AX gets 16-bit data from I/O port address 80H
OUT 80H, AL ; I/O port 80H gets 8-bit data from AL
OUT 80H, AX ; I/O port 80H gets 16-bit data from AX
This is also called Fixed Port Addressing.
Indirect Addressing Mode:
If we use 16-bit I/O address we get a range of 0000H--FFFFH. This gives a total of 65536 I/O ports. Here we use Indirect addressing Mode, that is, the I/O address is specified by DX register.
MOV DX, 2080H
IN AL, DX ; AL gets data from I/O port address 2080H given by DX.
IN AX, DX ; AX gets 16-bit data from I/O port address given by DX.
OUT DX, AL ; I/O port whose address is given by DX gets 8-bit data from AL
OUT DX, AX ; I/O port whose address is given by DX gets 16-bit data from AX
This is also called Variable Port Addressing.