From: Robert Lee Subject: Re: Assember (in-line) help Date: 21 Nov 1997 00:00:00 GMT Message-ID: <347586A1.F9F6F4F9@nwu.edu> References: <34746066.8462150@news.cjnetworks.com> <652f66$bci@cocoa.brown.edu> <3474df1b.2228469@news.cjnetworks.com> <653rup$i00@cocoa.brown.edu> Organization: Northwestern University, Evanston, IL, US Newsgroups: comp.lang.pascal.delphi.misc John_Mertus wrote: > In article <3474df1b.2228469@news.cjnetworks.com>, > nospam.aburton@mizehouser.com says... > > > >Thank you to everyone. I had to temporarily rely on some math routine > >to swap things around. As you can guess that is a lot slower. > > > Damn, I realized my second routine had the same problem as xchg,a > faster, better Pentium Pro, II routine is. > > Procedure Swap32c (Var LongVar : LongInt) ; Assembler ; > Asm > mov esi,longvar > > xor eax,eax > mov ax,[esi] > xor edx,edx > mov dx,[esi+2] > > mov [esi],dh > mov [esi+1],dl > mov [esi+2],ah > mov [esi+3],al > > End {Swap32} ; Actually there are clock penalties for addressing the same dWord in the same clock cycle and writing to the same register in same cycle so the above takes 8 clocks. The best anwser is still bswap. Its one cycle on a pentium. By the way LongVar is loaded into EAX and so there's no reason to move it to ESI. Procedure Swap32d (Var LongVar : LongInt) ; Assembler ; Asm bswap LongVar // LongVar=eax End {Swap32} ; Bob Lee