VOGONS

Common searches


First post, by Thandor

User metadata
Rank Member
Rank
Member

One thing I have been tinkering with years ago, recently popped up in my mind: I want to "pause" or fix the real-time clock in DOS to a certain date/time. In the past I wrote a simple TSR in Turbo Pascal which configured a given date over and over as fast as it could. This worked but was not stable. In order to attack the problem at another level I tried loading up the DOSBox source code but after getting a gazillion errors (I'm probably cursed in importing source code in VC++) I dropped this idea and thought about asking this forum:

Who knows about a way or DOS-program that is able to fix/lock the date/time? 😀

thandor.net - hardware
And the rest of us would be carousing the aisles, stuffing baloney.

Reply 1 of 3, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author

You can effectively stop the BIOS clock by redirecting INT 8 to a handler that doesn't increment the timer ticks like the BIOS handler does.

As for freezing the RTC... take out the battery? 😜 I don't know of a way to instruct the RTC to stop keeping time, but I guess you could use the INT 8 handler mentioned above to periodically reset the RTC to a specific time.

Reply 2 of 3, by acp

User metadata
Rank Newbie
Rank
Newbie

The easiest and quickest method nowadays is to run DOS inside VM 😉

If you want to achieve similar functionality from plain DOS without any virtualization/hardware aid the thing is a bit more complex. Here are some tips:

First of all you can disable RTC by using ports 70h and 71h. Before disabling RTC you need to disable software interrupts using cli instruction and NMI by writing to port 70h again.

You can also use PIC to disable IRQ 8 instead by setting bit 0 on port 21h.

However messing with time can have undesired side effect even in simple OS like DOS so I would suggest to first check at least for DOS Idle and InDOS flag before actually taking over the control of system time.

ASM beyond Repair https://corexor.wordpress.com blog about assembly related stuff

Reply 3 of 3, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Another approach that will work to some extent is to make a TSR program that intercepts the DOS and BIOS functions that read date and time, and then return specific values. However, some software may read the BIOS timer ticks and RTC registers directly, and my prior suggestion would be needed for those cases. Thinking about it more, quite a few programs could hang up while waiting for a certain amount of time to elapse, so for the clock to not advance at all is inherently problematic.

acp wrote:

you can disable RTC by using ports 70h and 71h.

Those are the ports through which one can read and write various CMOS registers, but how do you propose to *disable* the RTC's time-keeping by "using" them, exactly? AFAIK, the NMI enable/disable bit 7 on port 70h has no effect on RTC time-keeping, if that's what you were referring to.

acp wrote:

You can also use PIC to disable IRQ 8 instead by setting bit 0 on port 21h.

That will mask IRQ 0, the timer interrupt (INT 8). Much of DOS software needs a functional timer interrupt, and masking it more than temporarily on the PIC could cause issues large and small. It's so important that either a BIOS function, a component of DOS, or some piece of software will likely presume to unmask it, anyway. It seems to me the OP's intention is to stop the clock, not the system's heartbeat. Perhaps you were thinking of masking IRQ 8 by setting bit 0 on the second PIC (port A1h), but the RTC interrupt has no effect on time-keeping.