22 lines
687 B
Text
22 lines
687 B
Text
xchg ax,bx ;exchanges ax with bx
|
|
|
|
xchg ah,al ;swap the high and low bytes of ax
|
|
|
|
|
|
;XCHG a register with memory
|
|
mov dx,0FFFFh
|
|
mov word ptr [ds:userRam],dx
|
|
mov si,offset userRam
|
|
mov ax,1234h
|
|
xchg ax,[si] ;exchange ax with the value stored at userRam. Now, ax = 0FFFFh and the value stored at userRam = 1234h
|
|
|
|
|
|
;XCHG a register with a value on the stack.
|
|
mov ax,1234h
|
|
mov bx,4567h
|
|
push bx
|
|
push bp
|
|
mov bp,sp ;using [sp] as an operand for XCHG will not work. You need to use bp instead.
|
|
|
|
xchg ax,[2+bp] ;exchanges AX with the value that was pushed from BX onto the stack. Now, AX = 4567h,
|
|
;and the entry on the stack just underneath the top of the stack is 1234h.
|