1.

Input/output instructions

Answer»

INPUT/OUTPUT INSTRUCTIONS : 

IN acc, port :

In transfers a byte or a word from input port to the AL register or the AX register respectively. The port number my be specified either with an immediate byte constant, allowing access to ports numbered 0 through 255 or with a number previously placed in the DX register allowing variable access (by changing the value in DX) to ports numbered from 0 through 65,535. 

In Operands 

Example 

acc, immB IN AL, 0E2H (OR) IN AX, PORT 

acc, DX IN AX, DX (OR) IN AL, DX 

OUT port, acc:

Out transfers a byte or a word from the AL register or the AX register respectively to an output port. The port numbers may be specified either with an immediate byte or with a number previously placed in the register DX allowing variable access.

No flags are affected.

In Operands Example

Imm 8, acc OUT 32, AX (OR) OUT PORT, AL 

DX, acc OUT DX, AL (OR) OUT DX, AX 

29 

XCHG D, S : 

Mnemonic Meaning Format Operation Flags affected 

XCHG Exchange XCHGD,S (D) ↔ (S) None 

Destination Source Example 

Accumulator Reg 16 XCHG, AX, BX 

Memory Register XCHG TEMP, AX 

Register Register XCHG AL, BL 

In the above table register cannot be a segment register 

Example : For the data given, what is the result of executing the instruction. 

XCHG [SUM], BX 

((DS) + SUM) ↔ (BX) 

if (DS) = 0200, SUM = 1234 

PA = 02000 + 1234 = 03234 

ASSUME (03234) = FF [BX] = 11AA 

(03235) = 00 

(03234) ↔ (BL) 

(03235) ↔ (BH) 

We get (BX) = 00FF 

(SUM) = 11AA

XLAT (translate)

This instruction is useful for translating characters from one code such as ASCII to another such as EBCDIC, this is no operand instruction and is called an instruction with implied addressing mode. 

The instruction loads AL with the contents of a 20 bit physical address computed from DS, BX and AL. This instruction can be used to read the elements in a table where BX can be loaded with a 16 bit value to point to the starting address (offset from DS) and AL can be loaded with the element number (0 being the first element number) no flags are affected. 

XLAT instruction is equivalent to 

MOV AL, [AL] [BX] 

AL ← [(AL) + (BX) + (DS)] 

30 



Discussion

No Comment Found

Related InterviewSolutions