High Level Assembly Code?
A while back I needed to reverse the order of the 4 8-bit bytes in a 32-bit word, in some Delphi code. I worked out a way to do it with bit shifting, read the docs for a few minutes, and got something to work with AND, SHL, SHR, and some $FF constants. Later I encountered (on a usenet post which I can’t find at the moment), this implementation, which consists of some Delphi cruft around a single assembly statement:
function Swap32(aLong: Longint): Longint; assembler;
asm
BSWAP eax
end;
This is an unusual occurence: the assembly code is shorter, simpler, and more obviously correct (see this explanation of BSWAP), than the high level language implementation. Hmmm.


March 25th, 2007 at 1:16 pm
Hi Kyle,
Maybe this is the usenet thread you talk about?
http://groups.google.com/group/borland.public.delphi.objectpascal/msg/f0d5c40db3affe40
;)