


        Figure 2 -- BIOS RTC function logic
        
        INT 15H Function 83H  (Set/Cancel Wait Interval)
             If Subfunction = 0 Then
                  If Wait Active Then
                       Exit With Error
                  Set Wait Active Flag (bit 1 at 0040:00A0)
                  Store Wait Count at 0040:009C
                  Store Wait Flag Address at 0040:0098
                  Enable Periodic Interrupt
             Else If Subfunction = 1 Then
                  Disable Periodic Interrupt
        
        INT 15H Function 86H (Wait)
             If Wait Active Then
                  Exit With Error
             Set Wait Active Flag (bit 1 at 0040:00A0)
             Store Wait Count at 0040:009C
             Store Wait Flag Address at 0040:0098
             Enable Periodic Interrupt
             Loop Until Bit 7 at 0040:00A0 Is Set
             Clear Wait Active
        
        INT 1AH Function 6 (Set User Alarm)
             If Alarm Currently Set Then
                  Exit With Error
             If RTC Not Operating Then
                  Attempt To Initialize
                  If Initialization Fails Then
                       Exit With Error
                  Set Alarm Bytes In CMOS RAM
                  Enable Alarm Interrupt
        
        INT 1AH Function 7 (Reset User Alarm)
             Disable Alarm Interrupt
        
        INT 70H (Real-Time Clock ISR)
             If Periodic Interrupt Enabled and 
                  Periodic Interrupt Occurred Then
                  Subtract 976 From Wait Count
                  If Wait Count < 0 Then
                       Clear Wait Active Flag
                       Set High Bit Of Wait Flag
                       Disable Periodic Interrupt
             If Alarm Interrupt Enabled and Alarm Interrupt Occurred Then
                  Invoke INT 4AH
