chrisb4748

Count how many words are being used

7 posts in this topic

I am looking to count how many words are being used in a set range.

i.e. I want to be able how to count how many words are being used between D0 - D2000 

Thanks.

Share this post


Link to post
Share on other sites

What do you mean by "used"?? Do you want to count words which contain a non-zero value??

Share this post


Link to post
Share on other sites

It seems like you should be able to use the SRCH(181) instruction to do that. It will output the number of matches found to DR0. It is listed under Data Table Processing instructions in the W474 manual.

I suggest that you search for words containing zero. The SRCH instruction will give you a count of them in DRO. You can then subtract DRO from the total number of words to get the number of non-zero words.

Nonzero word search.cxp

Edited by Mendon Systems
Further explanation

Share this post


Link to post
Share on other sites

Use a FOR/NEXT loop with Index Register.

See attached example:-

At rising edge of W0.
Searches 10 words D0-D9 for value greater than 0.
Place result in D100.

Word Search Greater than 0.cxp

Share this post


Link to post
Share on other sites

Personally prefer to use IR pointer vs SRCH (181).

Faster scan time,

Attached is update program. Note that D0 to D2000 is 2001 loops.

 

Count result of data memory >0 is in D2100

 

Word Search Greater than D0-D2000.cxpWord Search Greater than D0-D2000.cxpWord Search Greater than D0-D2000.cxps.

 

Edited by BITS N BYTES

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now