News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Counting Set Bits

Started by veronicak5678, October 15, 2009, 03:16:17 AM

Previous topic - Next topic

dedndave

Hutch tells me that XLAT is slow on P4's - that may only apply to 32-bit code - i dunno
you could probably make that zing with mov al,CntTable[bx] though -  :bg
i don't think we can use Michael's timing macros in 16-bit world and get meaningful readings
i could be wrong, there, but i think we need a 16-bit timer of some sort

ilian007

hey Veronica why you have the varible "number" it seems it doesnt do anything just printing statement is between the two number,ax  ax,number ?

FORTRANS

Hi Dave,

   I found some timer code from Abrash's book(s).  But
the souce was apparently OCRed somewhere along the line,
And there will be some clean-up involved.  Do you have any
interest in seeing timing results?

Regards,

Steve N.

dedndave

sure - although - i dunno what "OCR'ed" means - lol
but i am sure if they have workable code, we can make it fly
it would be good to have some 16-bit timing code around
it shouldn't be very large
and - all we really need is a concept
i suppose we could use the counter-timer, but that means long tests because it has poor resolution

sinsi

Is that the zen timer? Have a look at chapter 22 here
Light travels faster than sound, that's why some people seem bright until you hear them.

dedndave

hiyas Sinsi
i finally found the zen timer in ch 3 - lol
that looks like a good resource - thanks
let me have a look at the timer.....

dedndave

i found the lib with source...
http://www.programmersheaven.com/download/13855/download.aspx
at first glance, it appears to use the counter/timer chip


yah - it uses the 8253 - which means no clock cycle readings like we have come to love from Michael's macros
what would be really cool would be to learn to load and run a 16-bit app under a 32-bit console using NTVDM.EXE
then, we could use Michael's macros and subtract the load-time overhead
using the counter/timer means we need some way to measure the CPU clock frequency under 16-bit
i.e. the zen timer will yield times to the nearest 18.2 ms - not clock cycles

sinsi

I don't see why michael's macros can't be used in 16-bit real mode with a bit of adjustment. We can still use rdtsc, which is the guts of measuring cycles.
Light travels faster than sound, that's why some people seem bright until you hear them.

dedndave


FORTRANS

Hi,

Quotei dunno what "OCR'ed" means

   Sorry.  Optical Character Recognition, scan in a printed
copy, and make a guess as to what the text really is.
Error prone if the hard copy is poor.  Plus in the version I
tracked down, all the "'" got changed to something out
of M$ Word.

QuoteIs that the zen timer? Have a look at chapter 22 here

   Well, another source, but chapter 3 of that book.

QuoteMichael wrote a nice set of macros for us

   Goodie!  Saves me some effort, though it won't work
on my 80186.

Thanks.

Steve N.

MichaelW

Quotei.e. the zen timer will yield times to the nearest 18.2 ms - not clock cycles

In theory it will yield times to the nearest 838ns (1 / 1193182Hz).

eschew obfuscation