Re: count2.asm





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

.



Relevant Pages

  • Re: entering more characters
    ... i enter more characters into a character array. ... Prev by Date: ...
    (comp.lang.c)
  • Re: Picking Element from Array one by one
    ... >>Rita wrote: ... >>> I am getting some values from loop and i store all that value in array ... >>then sort on keys of %and print key value pair ... Regards ...
    (comp.lang.perl.misc)
  • Re: value of #s in column if between dates
    ... No need to array enter it ... > format and didn't know how. ... >> Regards, ... >> Peo Sjoblom ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Increment an Array question
    ... > Regards and thanks. ... > "Tom Ogilvy" wrote in message ... >> I am not sure what role "i" plays, but you increment that and don't use ... >>> to an array. ...
    (microsoft.public.excel.programming)
  • Re: UART detection?
    ... Above array is initialized with following structures. ... Regards ... > Remember that if you want do use modprobe to redirect the module messages, ... > I want to detect this inside a kernel module. ...
    (Linux-Kernel)