AngoLinux

80386 Programmer's Reference Manual -- Opcode XCHG


XCHG -- Exchange Register/Memory with Register

OpcodeInstructionClocks DescriptionExample
90 + rxchgw r16,ax3 Exchange word register with AXxchgw %bx,%ax
90 + rxchgw ax,r163 Exchange word register with AXxchgw %ax,%bx
90 + rxchgl r32,eax3 Exchange dword register with EAXxchgl %ebx,%eax
90 + rxchgl eax,r323 Exchange dword register with EAXxchgl %eax,%ebx
86 /rxchgb r8,r/m83 Exchange byte register with EA bytexchgb %bh,%dl
xchgb %bh,(%ebx,1)
xchgb %bh,m8(%ebx,1)
xchgb %bh,m8(%ebx,%ebp,1)
86 /rxchgb r/m8,r83/5 Exchange byte register with EA bytexchgb %dl,%bh
xchgb (%ebx,1),%bh
xchgb m8(%ebx,1),%bh
xchgb m8(%ebx,%ebp,1),%bh
87 /rxchgw r16,r/m163 Exchange word register with EA wordxchgw %bx,%cx
xchgw %bx,(%ebx,1)
xchgw %bx,(%ebx,2)
xchgw %bx,(%ebx,%ebp,1)
87 /rxchgw r/m16,r163/5 Exchange word register with EA wordxchgw %cx,%bx
xchgw (%ebx,1),%bx
xchgw (%ebx,2),%bx
xchgw (%ebx,%ebp,1),%bx
87 /rxchgl r32,r/m323 Exchange dword register with EA dwordxchgl %ebx,%ecx
xchgl %ebx,(%ebx,2)
xchgl %ebx,(%ebx,4)
xchgl %ebx,(%ebx,%ebp,1)
87 /rxchgl r/m32,r323/5 Exchange dword register with EA dwordxchgl %ecx,%ebx
xchgl (%ebx,2),%ebx
xchgl (%ebx,4),%ebx
xchgl (%ebx,%ebp,1),%ebx

Operation




temp := DEST
DEST := SRC
SRC := temp

Description

XCHG exchanges two operands. The operands can be in either order. If a memory operand is involved, BUS LOCK is asserted for the duration of the exchange, regardless of the presence or absence of the LOCK prefix or of the value of the IOPL.

Flags Affected

None

Protected Mode Exceptions

#GP(0) if either operand is in a nonwritable segment; #GP(0) for an illegal memory operand effective address in the CS, DS, ES, FS, or GS segments; #SS(0) for an illegal address in the SS segment; #PF(fault-code) for a page fault

Real Address Mode Exceptions

Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to 0FFFFH

Virtual 8086 Mode Exceptions

Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault


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