Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>_bios_timeofday() access rom-bios system clock services</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _bios_timeofday()       Access ROM-BIOS system clock services

 #include   <bios.h>

 unsigned   _bios_timeofday(service, time);
  unsigned service; Time service desired -- see manifest constants below.
  long time;   Clock count, in clock ticks of about 18.2 per second (exactly
               1193180/65536). Values range from 0 to about 1573040
               ticks (midnight), after which the value is reset to 0.

    _bios_timeofday() uses ROM-BIOS interrupt 1Ah to get or set the
    current system time. The system time is reset every time the system
    is booted, and is set in one of three ways: from the battery-operated
    time chip if installed, from the MS-DOS time command, or set to 0
    otherwise. _bios_timeofday() offers another way of getting or setting
    the system time. The service desired is specified using one of the
    two manifest constants described below:

 _TIME_GETCLOCK Gets the current value of the system clock count and
                copies it to the location that time points to. If
                midnight has passed since the system clock was read or
                set, _bios_timeofday() returns 1; otherwise it returns 0.

 _TIME_SETCLOCK Sets the system clock to the value that time points to.
                There is no return value.

    Returns:    Varies by service. For service _TIME_GETCLOCK it returns
                0 if midnight has not yet passed, and 1 anytime after the
                the first midnight (including succeeding midnights if the
                system is left running for several days). For service
                _TIME_SETCLOCK no value is returned.

      Notes:    If _bios_timeofday() is used to represent
                hours:minutes:seconds then the user's code must perform
                all the necessary conversions from clock ticks to the
                required format.

                When _TIME_GETCLOCK is used the system clock rollover
                bit, which indicates that at least one midnight has
                passed, is reset to 0. For programs that are used only
                during a single day, and not near midnight, this should
                pose little problem. In other situations this service
                should be used with care.

                There are six additional time of day services specific to
                the AT and the PS/2, and two additional services unique
                to the PS/2, all of which can be accessed using int86()
                or int86x().

 Portability:   MS-DOS and PC-DOS only.

------------------------------- Example ---------------------------------

 This example gets the system clock tick value and converts it to an
 hour:minute:second.hundredths format

           #include <bios.h>

           main()
           {
              long ticks;
              float seconds;
              unsigned hours, minutes, remainder, newday;

              newday = _bios_timeofday(_TIME_GETCLOCK, &ticks);

              hours = ticks / 65543;
              remainder = ticks % 65543;
              minutes = remainder / 1092;
              remainder = remainder % 1092;
              seconds = remainder / 18.206;

              printf ("\n\tSystem clock time is %u:%u:%05.2f  hr:min:sec",
            hours, minutes, seconds);
            }



See Also: int86() int86x()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson