procedure that swaps the bytes (low/high) of a Word variable
- by Altar
Hi.
I have this procedure that swaps the bytes (low/high) of a Word variable (It does the same stuff as System.Swap function). The procedure works when the compiler optimization is OFF but not when it is ON.
Can anybody help me with this?
{ UNSAFE! IT IS NOW WORKING WHEN COMPILER OPTIMIZATION IS ON ! }
procedure SwapWord_NotWorking(VAR TwoBytes: word);
asm
Mov EBX, TwoBytes
Mov AX, [EBX]
XCHG AL,AH
Mov [EBX], AX
end;