Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Peter Norton Programmer's Guide - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

  Interrupt 1AH (decimal 26) provides the time-of-day services. Unlike other
  interrupts covered in this section but like all other ROM BIOS services,
  several services can be activated by this interrupt. When you execute
  interrupt 1AH, you specify the service number, as usual, in register AH.
  (See Figure 12-18.)

  Service            Description
  --------------------------------------------------------------------------
  00H                Get Current Clock Count.
  01H                Set Current Clock Count.
  02H                Get Real-Time Clock Time.
  03H                Set Real-Time Clock Time.
  04H                Get Real-Time Clock Date.
  05H                Set Real-Time Clock Date.
  06H                Set Real-Time Clock Alarm.
  07H                Reset Real-Time Clock Alarm.
  09H                Get Real-Time Clock Alarm Time and Status.
  --------------------------------------------------------------------------

  Figure 12-18.  The ROM-BIOS time-of-day services invoked by interrupt 1AH.

  The ROM BIOS maintains a time-of-day clock based on a count of
  system-clock ticks since midnight. The system clock "ticks" by generating
  interrupt 8 at specific intervals. On each clock tick, the ROM BIOS
  interrupt 08H service routine increments the clock count by 1. When the
  clock count passes 24 hours' worth of ticks, the count is reset to 0 and a
  record is made of the fact that midnight has been passed. This record is
  not in the form of a count, so you can't detect if two midnights have
  passed.

  The clock ticks at a rate that is almost exactly 1,193,180 . 64 KB, or
  roughly 18.2 times a second. The count is kept as a 4-byte integer at
  low-memory location 0040:006CH. The midnight count value, used to compare
  against the rising clock count, is 1800B0H, or 1,573,040; when the clock
  hits the midnight count value, the byte at location 0040:0070H is set to
  01H and the count is reset. When DOS needs to know the time, it reads the
  clock count through the time-of-day service and calculates the time from
  this raw count. If it sees that midnight has passed, it also increments
  the date.

  You can use the following BASIC formulas to calculate the current time of
  day from the clock count:

  HOURS = INT(CLOCK / 65543)
  CLOCK = CLOCK - (HOURS * 65543)
  MINUTES = INT(CLOCK / 1092)
  CLOCK = CLOCK - (MINUTES * 1092)
  SECONDS = CLOCK / 18.2

  In reverse, we use the following formula to calculate a nearly correct
  clock count from the time:

  COUNT = (HOURS * 65543) + (MINUTES * 1092) + (SECONDS * 18.2)

  The ROM BIOS services in the PC/AT and PS/2s include time-of-day and date
  services that perform some of these tasks automatically.

  Service 00H (decimal 0): Get Current Clock Count

  Service 00H (decimal 0) returns the current clock count in two registers:
  the high-order portion in CX and the low-order portion in DX. AL = 00H if
  midnight has not passed since the last clock value was read or set; and AL
  = 01H if midnight has passed. The midnight signal is always reset when the
  clock is read. Any program using this service must use the midnight signal
  to keep track of date changes. DOS programs normally should not use this
  service directly. If they do, they must calculate and set a new date.

  --------------------------------------------------------------------------
  NOTE:
    It's curious that version 2.0 of DOS did not consistently update the
    date on the midnight signal. The next version of DOS (2.1) and all other
    versions of DOS do.
  --------------------------------------------------------------------------

  Service 01H (decimal 1): Set Current Clock Count

  Service 01H (decimal 1) sets the clock count in location 0040:006CH using
  the values you pass in registers CX and DX. This service automatically
  clears the midnight flag at 0040:0070H.

  Service 02H (decimal 2): Get Real-Time Clock Time

  The PC/AT and the PS/2s have a real-time clock that maintains the current
  date and time in nonvolatile memory. This clock runs in parallel to the
  system timer referenced by services 00H and 01H. When you boot a PC/AT or
  PS/2, the ROM BIOS initializes the system timer count with the time
  indicated by the real-time clock.

  You can access the real-time clock directly using service 02H (decimal 2).
  This service returns the time in binary-coded decimal format (BCD) in
  registers CH (hours), CL (minutes), and DH (seconds). If the real-time
  clock is defective, the ROM BIOS sets the carry flag.

  Service 03H (decimal 3): Set Real-Time Clock Time

  This service complements service 02H. It lets you set the real-time clock
  on a PC/AT or PS/2, using the same register assignments as service 02H.
  Again, the hours, minutes, and seconds values are in BCD format.

  Service 04H (decimal 4): Get Real-Time Clock Date

  Service 04H (decimal 4) returns the current date as maintained by the
  real-time clock in a PC/AT or PS/2. The ROM BIOS returns century (19 or
  20) in register CH, the year in CL, the month in DH, and the day in DL.
  Again, the values are returned in BCD format. As in service 02H, the ROM
  BIOS sets the carry flag if the real-time clock is not operating.

  Service 05H (decimal 5): Set Real-Time Clock Date

  Service 05H (decimal 5) complements service 04H. This service sets the
  real-time clock date, using the same registers as service 04H.

  Service 06H (decimal 6): Set Real-Time Clock Alarm

  Service 06H (decimal 6) lets you create an "alarm" program that executes
  at a specific time. This alarm program must be memory-resident at the time
  the alarm occurs. To use this service, make your alarm program
  memory-resident using the DOS Terminate-and-Stay-Resident service (see
  page 302), and be sure that interrupt vector 4AH (0000:0128H) points to
  the start of your program. Then call service 06H to set the time for the
  alarm to occur.

  Service 06H uses the same register values as service 03H: CH contains
  hours in BCD format, CL contains minutes, and DH contains seconds. The ROM
  BIOS sets the carry flag when it returns from this service if the
  real-time clock is not operating or if the alarm is already in use.

  When the real-time clock time matches the alarm time, the BIOS executes
  interrupt 4AH, which transfers control to your alarm program. Your program
  can then take appropriate action (display a message, for example). Because
  the ROM BIOS activates your alarm program by executing an
  INT 4AH instruction, the program must exit with an IRET instruction.

  Service 07H (decimal 7): Reset Real-Time Clock Alarm

  Use service 07H (decimal 7) to disable the real-time clock alarm if it has
  been set by a previous call to service 06H.

  Service 09H (decimal 9): Get Real-Time Clock Alarm Time and Status

  On PS/2 models 25 and 30, you can determine the current status of the
  real-time alarm by executing interrupt 1AH, service 09H. This service
  reports the alarm status in register DL. If DL = 01H, the alarm is active,
  and the alarm time is returned in CH, CL, and DH. If DL = 00H, the alarm
  isn't enabled.

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