x86 Assembly Language Reference Manual

Output from Port (out, outs)

out{bwl} 	imm8
out{bwl} 	(%dx)
outs{bwl}
Operation

[AL|AX|EAX] -> imm[8|16|32]

[AL|AX|EAX] -> DX

ES:(E)DI -> DX

Description

Transfers a byte, word, or long from the memory address pointed to by the content of the AL, AX, or EAX register to the immediate 8-, 16-, or 32-bit port address.

The second form of the out instruction transfers a byte, word, or long from the AL, AX, or EAX registers respectively to a port (0 to 65535), specified by the DX register.

The outs instruction transfers a string from the memory byte or word pointed to by the ES:source index to the port addressed in the DX register. Load the desired port number into the DX register and the desired source address into the SI or ESI index register before executing the outs instruction. After a transfer occurs, the destination-index register is automatically incremented or decremented as determined by the value of the direction flag (DF). The index register is incremented if DF = 0 (DF cleared by a cld instruction); it is decremented if DF = 1 (DF set by a std instruction). The increment or decrement count is 1 for a byte transfer, 2 for a word, and 4 for a long. Use the rep prefix with the outs instruction for a block transfer of CX bytes or words.

Example

Transfer a word from the AX register into the 16-bit port address, 0xff:

outw $0xff

Transfer a long from the EAX register into the 32-bit port address specified by the DX register:

outl (%dx)

Transfer a string from the memory byte or word pointed to by the ES:source index to the port addressed in the DX register:

outsl