80386 Programmer's Reference Manual -- Opcode IN

IN -- Input from Port

OpcodeInstructionClocks DescriptionExample
E4 ibinb imm8,al12,pm=6*/26** Input byte from immediate port into ALinb $0x7f,%al
E5 ibinw imm8,ax12,pm=6*/26** Input word from immediate port into AXinw $0x7f,%ax
E5 ibinl imm8,eax12,pm=6*/26** Input dword from immediate port into EAXinl $0x7f,%eax
ECinb dx,al13,pm=7*/27** Input byte from port DX into ALinb %dx,%al
EDinw dx,ax13,pm=7*/27** Input word from port DX into AXinw %dx,%ax
EDinl dx,eax13,pm=7*/27** Input dword from port DX into EAXinl %dx,%eax


   *If CPL <= IOPL
  **If CPL > IOPL or if in virtual 8086 mode


IF (PE = 1) AND ((VM = 1) OR (CPL > IOPL))
THEN (* Virtual 8086 mode, or protected mode with CPL > IOPL *)
   IF NOT I-O-Permission (SRC, width(SRC))
   THEN #GP(0);
DEST := [SRC]; (* Reads from I/O address space *)


IN transfers a data byte or data word from the port numbered by the second operand into the register (AL, AX, or EAX) specified by the first operand. Access any port from 0 to 65535 by placing the port number in the DX register and using an IN instruction with DX as the second parameter. These I/O instructions can be shortened by using an 8-bit port I/O in the instruction. The upper eight bits of the port address will be 0 when 8-bit port I/O is used.

Flags Affected


Protected Mode Exceptions

#GP(0) if the current privilege level is larger (has less privilege) than IOPL and any of the corresponding I/O permission bits in TSS equals 1

Real Address Mode Exceptions


Virtual 8086 Mode Exceptions

#GP(0) fault if any of the corresponding I/O permission bits in TSS equals 1

[Home Page dell'ITIS "Fermi"] [80386 Programmer's Reference Manual Index] [Previous] [Next]