Free Electronic Circuits & 8085 projects

Electronic projects with circuit diagram and 8085 microprocessor projects.

Explanation of Instruction set of 8086 with free Sample Programs –Data Transfer Instructions2

Published on Oct 29 2009 // 8086 Instruction set, 8086 Sample programs

SIMPLE INPUT AND OUTPUT PORT TRANSFER INSTRUCTION


  •  IN Instruction – Copy data from a port IN accumulator, port

This IN instruction will copy data from a port to the AL or AX register. For the Fixed port IN instruction type the 8 – bit port address of a port is specified directly in the instruction.

Example:

IN AL,0C8H                     ;Input a byte from port 0C8H to AL
IN AX, 34H                      ;Input a word from port 34H to AX
A_TO_D EQU 4AH
IN AX, A_TO_D                ;Input a word from port 4AH to AX

For a variable port IN instruction, the port address is loaded in DX register before IN instruction. DX is 16 bit. Port address range from 0000H – FFFFH.

Example:

MOV DX, 0FF78H             ;Initialize DX point to port
IN AL, DX                        ;Input a byte from a 8 bit port 0FF78H to AL
IN AX, DX                        ;Input a word from 16 bit port to 0FF78H to AX.

  • OUT Instruction – Output a byte or word to a port – OUT port, accumulator AL or AX.

The OUT instruction copies a byte from AL or a word from AX or a double from the accumulator to I/O port specified by op. Two forms of OUT instruction are available : (a) Port number is specified by an immediate byte constant, ( 0 – 255 ).It is also called as fixed port form. (b) Port number is provided in the DX register ( 0 – 65535 )

Example: (a)

OUT 3BH, AL              ;Copy the contents of the AL to port 3Bh
OUT 2CH,AX               ;Copy the contents of the AX to port 2Ch

Example: (b)

MOV DX, 0FFF8H        ;Load desired port address in DX
OUT DX, AL                ; Copy the contents of AL to FFF8h
OUT DX, AX                ;Copy content of AX to port FFF8H