


        SIDEBAR
        Bugs in the BIOS?
        I've been in the bit-twiddling business long enough to know that  when 
        I  think  there's  a bug in the hardware or  operating  software,  I'm 
        probably  doing something wrong.  More often than not the problem  is 
        located  between  the ears; smack dab in the middle of the  ol'  brain 
        housing  group.   But, at 2 o'clock one morning after  a  weekend  of 
        furious  hair-ripping,  I decided to re-examine  my  assumptions.   As 
        Michael  Abrash  is  fond of pointing  out:   once  you've  eliminated 
        everything  that can't possibly be the bug, what's left has to be  the 
        bug, however unlikely that may be.  Time to debug the BIOS.
        
        So, what did I find?
        In  the 1-dozen BIOS that I've tested these routines on, not one  was 
        bug-free.  (I've yet to test a True Blue IBM or Compaq).  None of the 
        BIOS correctly shut down the RTC after all functions have  completed.  
        So,  once  any of the RTC functions is used, the RTC  interrupt  will 
        continue to occur until the machine is turned off.  This doesn't cause 
        problems,  it  just  slows your  machine  by  generating  unnecessary 
        interrupts.   The only way to stop the interrupts is  through  direct 
        hardware manipulation.
        
        If  the example program does not work correctly on your system,  the 
        following may be of some use:
        
        1)   INT  1A function 6 will not set an alarm and you know  that  no 
        other alarms are set in the system.
        First,  remove all TSR programs and unnecessary device drivers  that 
        could be the cause of the problem.  If the problem persists, trace the 
        BIOS  code and make sure the carry flag is being cleared  after  the 
        alarm  is  set.   In one BIOS that I tested,  the  carry  flag  wasn't 
        affected  unless  an error occurred--on  successful  completion,  the 
        carry  flag was returned in the same state as when the routine  was 
        called.
        
        2)   INT  1A function 7 is called to clear the alarm  but  subsequent 
        calls to function 6 report failure.
        Wait until next month to see how to clear the alarm in hardware.
        (Replace your ClearAlarm() function with a routine that resets the AIE 
        bit in Status Register B).
        
        3)  CancelWait () doesn't work or causes problems.
        First  of  all, if you're using my CancelWait () that  manipulates  the 
        BIOS  data areas, replace it with the BIOS call.  If problems  persist, 
        the BIOS is AFU and you're SOL.
        
        4)  Daylight Savings Time flag is undertimed.
        The  BIOS does not correctly implement the read time function.   Next 
        month I'll show you how to read the CMOS RAM directly.
        
        5)  None of the functions work!
        Make sure you're running on an AT.
        The INT 70H ISR is all goofed up.  Start tracing the BIOS code.   DOS 
        grabs  this interrupt and does some stack checking  before  executing 
        the  BIOS code.  The DOS stack check code works!  Somewhere  in  the 






        first 30 or so instructions of the DOS stack check code, you'll see an 
        instruction like:
             CALL FAR [01A0]
        The  DWORD  pointer stored at offset 01A0 in the DOS  code  segment 
        points to the beginning of the BIOS INT 70H ISR.  Start your debugging 
        here.



