procedure that swaps the bytes (low/high) of a Word variable
Posted
by
Altar
on Stack Overflow
See other posts from Stack Overflow
or by Altar
Published on 2011-02-27T15:09:19Z
Indexed on
2011/02/27
15:24 UTC
Read the original article
Hit count: 230
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;
© Stack Overflow or respective owner