Article View: borland.public.cppbuilder.nativeapi
Article #12Re: help sought, possible asm/cpu/other problem???
From: dhoke
Date: Fri, 18 Jul 2008 07:15
Date: Fri, 18 Jul 2008 07:15
92 lines
2833 bytes
2833 bytes
Well, since you've gone to the trouble, maybe the other isn't fast enough
anymore... :)
"Bob Gonder" <none@nowhere.invalid> wrote in message
news:8bqv74t64fcgrl6largtp9p68n3d0m0rkh@4ax.com...
> Larry Griffiths wrote:
>
>>Look at this and see if it is close to what you want.
>
> Three to four times faster (tested):
>
> #pragma argsused
> __declspec(naked)
> BOOL __fastcall BytesOKBob( unsigned char *pAddr, unsigned char bval,
> unsigned nbytes )
> { // eax = pAddr edx = bval ecx = nbytes
> asm{
> mov dh,dl
> sub ecx,4
> jc short loop2
> push edx // mul edx, 0x00010001
> mov word ptr [esp+2],dx
> pop edx
> }
> loop4:
> asm{
> cmp [eax],edx
> jne short fail
> add eax,4
> sub ecx,4
> jnc loop4
> }
> loop2:
> asm{
> add ecx,2
> js short loop1
> cmp [eax],dx
> jne short fail
> add eax,2
> sub ecx,2
> }
> loop1:
> asm{
> add ecx,1
> js short pass
> cmp [eax],dl
> jne short fail
> }
> pass:
> asm{
> xor eax,eax ;// return 0
> ret
> }
> fail:
> asm{
> cmp [survivalmode],0
> jne short noint
> cmp [callint3onerror],0
> je short noint
> int 3
> }
> noint:
> asm{
> mov eax,1 ;// return 1
> ret
> }
> return 1; // compiler prefers to see a C return.
> // but there is a no-stack bug that doesn't generate the ret.
> }
>
>>bool BytesOK( unsigned char *pAddr, unsigned char bval, unsigned nbytes )
>>{
>> if( nbytes )
>> {
>> _asm
>> {
>> cld
>> mov al, bval // Value to compare
>> mov ecx, nbytes // Number of bytes to compare
>> mov edi, pAddr // Address of buffer
>> repe scasb
>> jz ItsOK:
>> }
>> //if(!MM3AdminData.survivalmode)
>> // if(MM3AdminData.callint3onerror) __asm int 3 ;
>> return 0 ;
>> }
>> ItsOK:
>> return 1 ;
>>}
>
>
Technical Details
Message-ID:
<4880433d@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news3.google.com!feeder.news-service.com!news.isoc.lu!newsgroups.borland.com!not-for-mailReferences:
<487e5d3c$1@newsgroups.borland.com> <487fe05e$1@newsgroups.borland.com> <8bqv74t64fcgrl6largtp9p68n3d0m0rkh@4ax.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,ced19374283c232f X-Google-Attributes: gid10cc67,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "dhoke" <dhoke.nojunk@east-shore.com> From: "dhoke" <dhoke.nojunk@east-shore.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <487e5d3c$1@newsgroups.borland.com> <487fe05e$1@newsgroups.borland.com> <8bqv74t64fcgrl6largtp9p68n3d0m0rkh@4ax.com> Subject: Re: help sought, possible asm/cpu/other problem??? Date: Fri, 18 Jul 2008 03:15:38 -0400 Lines: 94 Organization: East Shore Technologies, Inc. X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 71.245.145.51 Message-ID: <4880433d@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1216365373 71.245.145.51 (18 Jul 2008 00:16:13 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news3.google.com!feeder.news-service.com!news.isoc.lu!newsgroups.borland.com!not-for-mail