Re: count2.asm
- From: "Alex McDonald" <alex_mcd@xxxxxxxxxxxxxxx>
- Date: 26 Jul 2005 07:19:10 -0700
hutch-- wrote:
> Frank,
>
> I may have missed something in reading your first post but if the task
> is to count characters in a file of any type, it is a very simple
> operation. With the following you just feed it the source address,
> bytecount and an array of 256 DWORDS and it dumps the result in the
> array. It could do with unrolling as it is a bit memory bound but its
> by no means slow.
>
> ;
> «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
>
> align 4
>
> byte_count proc src:DWORD,cnt:DWORD,array:DWORD
>
> push esi
>
> mov edx, array ; array address in EDX
> mov esi, src ; source in ESI
> mov ecx, cnt ; count in ECX
> add esi, ecx ; add count to source
> neg ecx ; invert sign in ECX
>
> @@:
> movzx eax, BYTE PTR [esi+ecx] ; zero extend current byte into EAX
> add DWORD PTR [edx+eax*4], 1 ; add 1 to its location in table
> add ecx, 1
> jnz @B
>
> pop esi
>
> ret
>
> byte_count endp
>
> ;
> «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
>
> Regards,
>
> hutch at movsd dot com
It was slightly more complex than that, as it was to count words as
well; the conditional part did that.
--
Regards
Alex McDonald
.
- References:
- count2.asm
- From: Frank Kotler
- Re: count2.asm
- From: Alex McDonald
- count2.asm
- Prev by Date: Re: count2.asm
- Next by Date: Re: count2.asm
- Previous by thread: Re: count2.asm
- Next by thread: Re: count2.asm
- Index(es):
Relevant Pages
|