Logic [ES:eDI] ← [port] if DF = 0 eDI ← eDI + n ; n = 1 for byte, 2 for word, else ; 4 for dword (386+) eDI ← eDI - n endif
The INS instruction reads a value from a port (specified in the DX register) and transfers it to memory (at ES:eDI). After the transfer, eDI is updated to point to the next string location. The port is always addressed through DX. If the address-size attribute is 16 bits, DI is used as destination-index register; if 32 bits, EDI is used.
Protected mode An exception occurs if the current task has insufficient privilege for the I/O. INS is not IOPL-sensitive in V86 mode.
Note: This instruction is always translated by the assembler into INSB, Input String Byte, INSW, Input String Word, or INSD, Input String Dword, depending upon whether destination refers to a string of bytes, words or doublewords. In either case, you must explicitly load the ES and eDI registers with the location of the destination.
INSB, INSW, and INSD are synonyms for the byte, word, and doubleword INS instructions that do not require an operand. They are simpler to use but provide no type or segment checking.
These instructions normally use a REP prefix to indicate a block read of the number of bytes as specified in eCX.
Example: les di,[pSec] ; Point ES:DI to storage mov dx,PORT_NUM ; DX = port number mov cx,512 ; No. of bytes to read cld ; String ops forward rep insb ; Read the port
Opcode Format 6C INS m8,DX ; = INSB (186+) 6D INS m16,DX ; = INSW (186+) 6D INS m32,DX ; = INSD (386+)