home *** CD-ROM | disk | FTP | other *** search
- ;*************************************************************************
-
- CODE_SEG SEGMENT PUBLIC
- ORG 100H
- ASSUME CS:CODE_SEG,DS:CODE_SEG
-
- SETCLOCK PROC FAR
- JMP START ;JUMP OVER DATA DECLARATIONS
-
- ;-------------------------------------------------------------------------
-
- ; This program can be used by AT&T PC6300 users running IBM PC-DOS
- ; to set the DOS clock from the 6300s on-board clock/calendar chip
-
- ; Program Notes:
- ;
- ; For the IBM PC, a timer tick is generated approximately 18.21 times
- ; per second. The AT&T 6300 generates exactly 18.75 timer ticks per
- ; second.
-
- ; Access to the 6300s on-board clock/calendar chip (set and read time and
- ; date) can be accomplished through calls to the ROM BIOS interrupt
- ; number 1A (hex). On an IBM PC, this call supports 2 functions:
- ; GET TIMER COUNT ===> AH=0
- ; SET TIMER COUNT ===> AH=1
- ; For both functions, CX = high word of timer count
- ; DX = low word of timer count
- ; On a 6300, this BIOS call supports 2 additional functions as follows:
- ; SET REAL TIME CLOCK/CALENDAR
- ; AH = 0FFh
- ; BX = Days from 1/1/84
- ; CH = Hours
- ; CL = Minutes
- ; READ REAL TIME CLOCK/CALENDAR
- ; AH = 0FEh
- ; BX = same as function 0FFh
- ; CH = ditto
- ; CL = ditto
- ; DH = Seconds
- ; DL = Hundreths of seconds
- ;
- ; For all interrupt 1Ah functions, AH serves as the error flag for the
- ; call (ie. if AH=0 on return, all is well)
- ;
- ; The 6300 System Programmer's Guide contains a listing of the ROM BIOS
- ; code for this interrupt. This listing contains a comment explaining
- ; the usage of the BX register as day "from 1-1 of leap year up to
- ; 12-31 of leap year+7 (0 - B69h)". While I'm not sure exactly what
- ; this means, setting BX to zero sets the date to 1/1/84 and setting BX
- ; to 0B69h sets the date to 12/31/91. Setting BX to a value greater
- ; than 0B69h results in an error. I suppose this means that a new
- ; clock/calendar chip will have to be installed sometime in 1991!
-
- ;-------------------------------------------------------------------------
-
- ;---- IBM PC-DOS Timer Tick equivalents --------------------------------
- ;---- Note that since the 6300 generates 18.75 ticks per second (as
- ;---- opposed to the IBM PC which generates only 18.21 per second),
- ;---- the PC-DOS clock will seem to run a bit fast
- ;-----------------------------------------------------------------------
- TICKS_PER_HOUR DD 65543
- TICKS_PER_MIN DW 1092
-
- TIMER_TICKS DD 0
-
- CURR_HOUR DB ?
- CURR_MIN DB ?
-
- ;-------------------------------------------------------------------------
-
- START: MOV AH,0FEH ;BIOS INTERRUPT 1A FUNCTION
- INT 1AH ; TO READ THE 6300s ON-BOARD
- MOV CURR_HOUR,CH ; CLOCK CALENDAR CHIP
- MOV CURR_MIN,CL ; RETURNS HOURS IN CH, MINUTES IN CL
-
- ; Given the "real" time from the on-board clock, we can convert to BIOS
- ; timer ticks so that PC-DOS will know what time it is
-
- HOURLY_TICKS: MOV AX,WORD PTR TICKS_PER_HOUR[2]
- MOV BX,WORD PTR TICKS_PER_HOUR
- XOR CH,CH
- MOV CL,CURR_HOUR
- JCXZ MINUTE_TICKS ;skip hours if zero
- ADD_LOOP: ADD WORD PTR TIMER_TICKS,BX
- ADC WORD PTR TIMER_TICKS[2],AX
- LOOP ADD_LOOP
-
- MINUTE_TICKS: MOV CX,TICKS_PER_MIN
- MOV AL,CURR_MIN
- XOR AH,AH
- MUL CX
- ADD WORD PTR TIMER_TICKS,AX
- ADC WORD PTR TIMER_TICKS[2],DX
-
- ; We now know what time it is in terms of PC-DOS timer ticks. We will
- ; use the ROM BIOS function 1A to set the timer tick value in the
- ; BIOS data segment to this calculated value
-
- SET_TIMER: MOV CX,WORD PTR TIMER_TICKS[2]
- MOV DX,WORD PTR TIMER_TICKS
- MOV AH,1 ;SET BIOS TIMER TICK FUNCTION
- INT 1AH ;CALL BIOS
-
- INT 20H ;EXIT
-
- SETCLOCK ENDP
- CODE_SEG ENDS
- END SETCLOCK