🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #19

Re: help sought, possible asm/cpu/other problem???

#19
From: Larry Griffiths
Date: Fri, 18 Jul 2008 13:24
95 lines
2685 bytes
Nice job Bob!

:)

Larry Griffiths

"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: <4880999a$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!feeder.erje.net!news.isoc.lu!newsgroups.borland.com!not-for-mail
References: <487e5d3c$1@newsgroups.borland.com> <487fe05e$1@newsgroups.borland.com> <8bqv74t64fcgrl6largtp9p68n3d0m0rkh@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Larry Griffiths" <nospame@nowhere.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 08:24:30 -0500
Lines: 97
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: 70.252.174.162
Message-ID: <4880999a$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1216387482 70.252.174.162 (18 Jul 2008 06:24:42 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!feeder.erje.net!news.isoc.lu!newsgroups.borland.com!not-for-mail