[ros-dev] [ros-diffs] [greatlrd] 23826: Wrote RtlUshotByteSwap RtlUlongByteSwap and RtlUlonglongByteSwap to asm code. but we need a C api for header to linking it right. Put the asm version to i386
Magnus Olsen
magnus at itkonsult-olsen.com
Thu Aug 31 19:58:22 CEST 2006
Hi
Royce3
alex solv it
and he also wrote some other rtl* to asm
with some commit.
----- Original Message -----
From: "Reuel ben Yisrael" <reuel at ev1.net>
To: <ros-dev at reactos.org>
Sent: Wednesday, August 30, 2006 11:29 PM
Subject: Re: [ros-dev] [ros-diffs] [greatlrd] 23826: Wrote RtlUshotByteSwap
RtlUlongByteSwap and RtlUlonglongByteSwap to asm code. but we need a C api
for header to linking it right. Put the asm version to i386
> greatlrd at svn.reactos.org wrote:
>
> >Author: greatlrd
> >Date: Thu Aug 31 01:17:53 2006
> >New Revision: 23826
> >
> >URL: http://svn.reactos.org/svn/reactos?rev=23826&view=rev
> >Log:
> >Wrote RtlUshotByteSwap RtlUlongByteSwap and RtlUlonglongByteSwap to asm
code.
> > but we need a C api for header to linking it right. Put the asm
version to i386
> >
> >
> sure there must be away to avoid this double-function-call overhead?
>
> >+.globl _UlongByteSwap
> >+
> >+.intel_syntax noprefix
> >+
> >+/* FUNCTIONS
***************************************************************/
> >+
> >+_UlongByteSwap:
> >+ push ebp // save base
> >+ mov ebp,esp // move stack to base
> >+ mov eax,[ebp+8] // load the ULONG
> >+ bswap eax // swap the ULONG
> >+ pop ebp // restore the base
> >+ ret
> >
> >
> this should work:
>
> _UlongByteSwap:
> mov eax,[esp+8] // load the ULONG
> bswap eax // swap the ULONG
> ret
>
>
> >+.globl _UlonglongByteSwap
> >+
> >+.intel_syntax noprefix
> >+
> >+/* FUNCTIONS
***************************************************************/
> >+
> >+_UlonglongByteSwap:
> >+ push ebp // save base
> >+ mov ebp,esp // move stack to base
> >+ mov edx,[ebp+8] // load the higher part of
ULONGLONG
> >+ mov eax,[ebp+12] // load the lower part of
ULONGLONG
> >+ bswap edx // swap the higher part
> >+ bswap eax // swap the lower part
> >+ pop ebp // restore the base
> >+ ret
> >
> >
> _UlonglongByteSwap:
> mov edx,[esp+8] // load the higher part of
ULONGLONG
> mov eax,[esp+12] // load the lower part of
ULONGLONG
> bswap edx // swap the higher part
> bswap eax // swap the lower part
> ret
>
> >+_UshortByteSwap:
> >+ push ebp // save base
> >+ mov ebp,esp // move stack to base
> >+ mov eax,[ebp+8] // load the USHORT
> >+ bswap eax // swap the USHORT, xchg is
slow so we use bswap with rol
> >+ rol eax,16 // make it USHORT
> >+ pop ebp // restore the base
> >+ ret
> >
> >
>
> _UshortByteSwap:
> mov eax,[esp+8] // load the USHORT
> bswap eax // swap the USHORT, xchg is slow
so we use bswap with rol
> rol eax,16 // make it USHORT
> ret
>
>
> or to save a byte...
>
> _UshortByteSwap:
> mov ebx,[esp+8] // load the USHORT
> mov al, bh
> mov ah, bl
> ret
>
>
>
> _______________________________________________
> Ros-dev mailing list
> Ros-dev at reactos.org
> http://www.reactos.org/mailman/listinfo/ros-dev
More information about the Ros-dev
mailing list