flat assembler
Message board for the users of flat assembler.

Index > DOS > Good alternative for high-resolution timing?

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
LocoDelAssembly wrote:
Yep, pretty bad documentation, AMD's nor Intel's manuals mention such instruction.
Intel - Vol 3B wrote:
The RDMSR and WRMSR instructions read and write the time-stamp counter, treating
the time-stamp counter as an ordinary MSR (address 10H). In the Pentium 4, Intel
Xeon, and P6 family processors, all 64-bits of the time-stamp counter are read using
RDMSR (just as with RDTSC). When WRMSR is used to write the time-stamp counter
on processors before family [0FH], models [03H, 04H]: only the low-order 32-bits of
the time-stamp counter can be written (the high-order 32 bits are cleared to 0). For
family [0FH], models [03H, 04H, 06H]; for family [06H]], model [0EH, 0FH]; for
family [06H]], display_model [17H, 1AH, 1CH, 1DH]: all 64 bits are writable.


The truth is out Shocked

Cas wrote:

> yes, you can use it on any ring, but I guess you can't change the
> frequency from a ring other than 0, because you have to access
> ports. Am I right?

NO. You need port access to both read and write (change frequency). Also, you CAN write the ports from Ring3 (not from NTVDM, though).

> concern about using high frequency PIT is that, if not in pure DOS,

NTVDM ??? Sad Are you sure you want to support it ???

> there is a chance that the code behind the INT08 is HUGE!

Other problems: no access to hardware, no access to physical memory, no way to disable interrupts, ...

> I'm interested in measuring time, not clocks, but I know that, with
> one loop, I can calculate the proportion and then use the
> TSC to measure time as well.

Just find out the CPU frequency using the BIOS 18.2 Hh timer or the DOS clock Wink

> One example of when I would need this high resolution is this: suppose
> I want a routine to run at the start of every vertical retrace, but my board,
> as many others, does not support interrupt triggering. I have no option
> but to poll, but then, if I'm busy doing other things, when my polling tells
> me there's a VR going on, it may be just about to end... so I have to
> "sit and wait" for it! What if I'm busy doing other things?

FreeBASIC also has this problem. You have to poll inside a PIT-based ISR or your main loop, but then your main loop should not be too busy too long Neutral

> Another example... suppose I'm recording audio in CD resolution to a buffer

So you are able to use sound recording with PCI sound hardware ?

> react immediately if a sound of a certain type (i.e.: a square
> wave of a given frequency) enters the buffer.

???

> I would need to be checking the buffer freq/2 times, that is, at 22KHz.

And check the full buffer size Laughing

> but that does not have to be the case.

I have no idea what you are trying to do ...

> Can I have different frequencies for the different PIT channels

YES

> while not using the PC speaker (having the output off all time)... use
> its channel for other purposes?

YES

> This would be a good background counter, compatible with very
> old hardware

YES
Post 18 Dec 2009, 01:56
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Cas, take a look at this: http://atc.ugr.es/docencia/udigital/1203.html (Spanish, sorry the rest). Take in mind that the book talks about the old AT and PS/2 computers so things like "channel 1 used for memory refresh" are hardly true nowadays, but what it says about channels 0 and 2 is still true today.
Post 18 Dec 2009, 03:13
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4238
Location: 2018
edfed
what is the execution time of a minimal periodic interrupt with PIT?
Post 18 Dec 2009, 17:57
View user's profile Send private message Visit poster's website Reply with quote
Cas



Joined: 26 Feb 2004
Posts: 82
Location: Argentina
Cas
Quote:
> Another example... suppose I'm recording audio in CD resolution to a buffer

So you are able to use sound recording with PCI sound hardware ?


Unfortunately, not yet, DOS386. I know some tricks, but I'm not as experience as you guys are at low level programming and my efforts to develop sound drivers for DOS are taking me a lot of time. I'm having a hard time trying to understand other people's code... people who're much better than I am. Most helpful I've found is MPXPLAY's source code, but it does not include recording. Still, I do have a computer at home with a SBAWE64 ISA, where I can work sound under pure DOS.

When I say I have a concern about compatibility with non-pure DOS, I don't mean I want to support windows-dependent standards. That'd be the last thing I'd do! But I do believe I should try to make my applications compatible with DOSBox, as much as possible, so that they can be run in other OS's. Still, I wish most DOS users would have, as I do, a partition specially dedicated for FreeDOS, instead of virtualising the environment all the time. I do understand the complication this means, though.

CMOS Real Time Clock is very interesting. How likely is it for a board to support it? I've been reading the DOC. I'll put it in my "RESEARCH" directory. Very good

_________________
Ā«Earth is my country; science is my religionĀ» - Christian Huygens
Post 20 Dec 2009, 13:40
View user's profile Send private message Yahoo Messenger MSN Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17287
Location: In your JS exploiting you and your system
revolution
Cas wrote:
CMOS Real Time Clock is very interesting. How likely is it for a board to support it?
Very likely indeed. IIRC only the very old 8086 and 8088 boards didn't have an RTC.

And it is safe to say that any 32bit CPU on a commercially available mobo will definitely have the RTC.
Post 20 Dec 2009, 14:10
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
Quote:
When I say I have a concern about compatibility with non-pure DOS, I don't mean I want to support windows-dependent standards. That'd be the last thing I'd do! But I do believe I should try to make my applications compatible with DOSBox, as much as possible, so that they can be run in other OS's


... but not in DOS ... or without sound at best Sad

Quote:
I do have a computer at home with a SBAWE64 ISA, where I can work sound under pure DOS.


Public value of this fact won't necessarily increase in future.

Quote:
my efforts to develop sound drivers for DOS are taking me a lot of time


So you are developping sound drivers ... there are also 2 at the forum of BTTR.

I would of course prefer a driver that can play in DOS from a thing that can record in DOG-BOX Wink
Post 21 Dec 2009, 08:12
View user's profile Send private message Reply with quote
Cas



Joined: 26 Feb 2004
Posts: 82
Location: Argentina
Cas
Yeah... I hate it! Many people who say they love DOS (actually they say they "loved" DOS) or that still feel a passion for an old piece of software that runs under it (for example, the games Stunts [Stunts portal] and Supaplex [Elmer productions]) are wishing they can port these games for other operating systems or that they can create a new version that can run under such systems. None of them seem to be willing to install DOS in their computers and support native access to these pieces of art!
There is a side of the DOS emulators that is quite bad... as they get people who somewhat love DOS to choose an "easy solution"... but I believe they also have a good part, in that most of these people would simply give up if it weren't for these emulators. Until we have succeeded to make DOS complete enough for all of these people's likes, it's better for emulators to be there.
In the meantime... I'm trying hard to develop the drivers, but I'm not that good! I wish you or other people here can give me a hand. I have a nice idea of how I want the driver, but damn, it's so hard to deal with other people's code! What's the basic of those two drivers you tell about?
Post 21 Dec 2009, 12:53
View user's profile Send private message Yahoo Messenger MSN Messenger Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
> it's better for emulators to be there.

Use BOCHS Wink

> but I'm not that good!

I see ...

> I wish you or other people here can give me a hand.

I'm not expert in PCI either Sad check DOSferatu guy at BTTR forum and his drivers Wink
Post 21 Dec 2009, 13:20
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4238
Location: 2018
edfed
to deal with time in a clock based machine, you should think in the Z domain.
instead of a linear time scale, you have a z domain, or Z transform, with interval between two consecutive samples to be variable.

the pit will generate a rate like 100Hz (fast and precise enough for human perception) and the code will mesure time as cents of second.

for sound play, it is an other interrupt (from a sound card).

the interrupt should be the faster possible, like 20 or 30 cpu cylces to update the pit counter 100 times per second (2000 or 3000 cylces)
if the CPU runs at 1MHz, it will take only 3/1000 of the power. negligeable...
Post 02 Jan 2010, 02:35
View user's profile Send private message Visit poster's website Reply with quote
ring0



Joined: 14 Mar 2005
Posts: 15
Location: Australia
ring0
Better late than never: Try this link for a more thorough discussion:

http://www.cs.rice.edu/CS/Systems/Soft-timers/code/README.html
Post 31 Jan 2010, 02:34
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.