27
27
; - MSM5832: 310h, 210h
28
28
; - MM58167: *240h, *340h, *2C0h, 250h, *300h, 350h, 377h, 037Dh, 027Dh
29
29
; - RP5C15: *2C0h
30
- ; - MSM6242: 2C0, 240, 250, 300, 340, 350
31
- ;
32
- ; * overlapping port numbers: 240h, 2C0h, 340h
30
+ ; - MSM6242: 2C0h, 240h, 250h, 300h, 340h, 350h
33
31
;
34
32
; TODO:
33
+ ; - RTC Detection with overlapping port numbers: 240h, 2C0h, 340h
35
34
; - Other Clock Types:
36
35
; - MSM-58321 (is different than 5832?): 2C0, 27E, 37E, 02A2-02A3?
37
36
; - DS1216E/DS1315 "SmartWatch"
41
40
;
42
41
;----------------------------------------------------------------------------;
43
42
VER_NAME EQU 'GLaTICK'
44
- VER_NUM EQU '0.8.3 ' ; (max 6 chars)
45
- VER_DATE EQU '05/09 /23' ; must be MM/DD/YY format
43
+ VER_NUM EQU '0.8.4 ' ; (max 6 chars)
44
+ VER_DATE EQU '05/11 /23' ; must be MM/DD/YY format
46
45
COPY_YEAR EQU '2023'
47
46
48
47
;----------------------------------------------------------------------------;
@@ -52,17 +51,6 @@ SHOW_BANNER = 1 ; always show full banner at POST
52
51
SHOW_RTC = 1 ; show detected RTC and clock
53
52
SHOW_CLOCK = 1 ; if above, show date/time at POST
54
53
55
- ;----------------------------------------------------------------------------;
56
- ; RESET_ON_ERROR:
57
- ; If enabled, this will validate the date and time read from the clock at POST
58
- ; and if invalid attempt to reset the clock to 1980-01-01 00:00:00. This is
59
- ; to prevent the "chicken and egg" scenario where DOS will not enable the RTC
60
- ; thus preventing the date from being set using DATE/TIME.
61
- ; If disabled, non-error/CF results will be displayed as returned by the clock
62
- ; driver. This may be helpful for debugging clock read issues.
63
- ;
64
- RESET_ON_ERROR = 1 ; reset date if error on POST
65
-
66
54
MAGIC_WORD EQU 0AA55H ; Magic Word used for option ROM
67
55
ROM_SIZE EQU 800H ; size of ROM (2K)
68
56
@@ -76,7 +64,7 @@ DATE_FMT = 3 ; 0 = MM/DD/YY (Ye Olde BIOS style)
76
64
TIME_SEC = 0 ; 1 = HH:MM:SS, 0 = HH:MM only
77
65
78
66
;----------------------------------------------------------------------------;
79
- ; Formatting based on display config
67
+ ; Date/time display formatting based on display config
80
68
;
81
69
IF DATE_FMT LT 2
82
70
DATE_SEP = '/' ; '/' date separator
@@ -98,8 +86,8 @@ INCLUDE SEGS.INC
98
86
ASSUME DS :OPTROM , SS :OPTROM , CS :OPTROM , ES :OPTROM
99
87
OPTROM SEGMENT BYTE PUBLIC 'CODE'
100
88
101
- PUBLIC INT_1A_DEFAULT , IS_LEAP , LEAP_NEXT , GET_RTC
102
- PUBLIC PACK_BCD , BCD_TO_WORD , BCD_TO_BYTE , STR_CRLF
89
+ PUBLIC INT_1A_DEFAULT , IS_LEAP , LEAP_NEXT , GET_RTC , STR_CRLF
90
+ PUBLIC PACK_BCD , UNPACK_BCD , BCD_TO_WORD, BCD_TO_BYTE , BYTE_TO_BCD
103
91
104
92
EXTRN OUT_CHAR:NEAR , OUT_SZ_ATTR:NEAR , OUT_SZ:NEAR , OUT_SZ_NL:NEAR
105
93
EXTRN WORD_HEX:NEAR , BYTE_HEX:NEAR
@@ -113,11 +101,12 @@ EXTRN POST_END_COL:NEAR, POST_END_COL_NL:NEAR, IS_GLABIOS:NEAR
113
101
ROM_HEADER PROC FAR
114
102
DW MAGIC_WORD ; ROM magic number
115
103
DB ROM_SIZE / 512 ; ROM size (512 byte blocks)
116
- ROM_HEADER ENDP ; fall through to INIT
104
+ ROM_HEADER ENDP
117
105
118
106
;----------------------------------------------------------------------------;
119
107
; INIT procedure called during POST
120
108
;----------------------------------------------------------------------------;
109
+ ORG 0003H ; fixed offset for INIT
121
110
ROM_INIT PROC
122
111
PUSHF
123
112
PUSH AX ; preserve all registers
@@ -264,7 +253,7 @@ DETECT_SET:
264
253
CALL BCD_TIME_TO_TICKS ; set BIOS time/clock from BCD values
265
254
MOV AH , 1
266
255
INT 1AH
267
- MOV DL , 1 ; set time is valid flag
256
+ MOV DL , 1 ; set " time is valid" flag (DL=1)
268
257
269
258
DETECT_DONE:
270
259
IF SHOW_RTC EQ 1
@@ -290,18 +279,19 @@ DETECT_RESET:
290
279
MOV CX , 1980H ; default to beginning of time
291
280
MOV DX , 0101H ; Jan 01
292
281
INT 1AH
282
+
293
283
MOV AH , 3 ; reset time to 00:00:00
294
284
CWD ; DX = 0
295
285
MOV CX , DX ; CX = 0
296
286
INT 1AH
297
- IF SHOW_RTC EQ 1
287
+ IF SHOW_RTC EQ 1
298
288
;----------------------------------------------------------------------------;
299
289
; Force 'Error' message since clock was reset
300
290
;
301
- CWD ; DL = 0 (invalid read )
302
- ENDIF
291
+ CWD ; clear "time is valid" flag (DL=0 )
292
+ ENDIF ; END IF SHOW_RTC
303
293
JMP SHORT DETECT_DONE
304
- ENDIF ; / RESET_ON_ERROR
294
+ ENDIF ; END IF RESET_ON_ERROR
305
295
306
296
;----------------------------------------------------------------------------;
307
297
; Print detected clock type and I/O port (if enabled)
@@ -312,7 +302,7 @@ DETECT_RESET:
312
302
; DL = valid flag: 1 = display time, 0 = print 'Error'
313
303
;----------------------------------------------------------------------------;
314
304
PRINT_DETECTED PROC
315
- POST_COL_1 STR_DETECT , POST_CLR_VAL2 , 1 ; display 'RTC' row label
305
+ POST_COL_1 STR_RTC , POST_CLR_VAL2 , 1 ; display 'RTC' row label
316
306
CALL OUT_SZ ; display RTC name in SI
317
307
TEST DI , DI ; port number zero?
318
308
JZ RTC_DONE ; if zero, do not display
@@ -331,7 +321,7 @@ PORT_DONE:
331
321
;----------------------------------------------------------------------------;
332
322
PRINT_DATETIME PROC
333
323
CALL POST_END_COL ; end first column
334
- POST_COL_2 STR_DT , POST_CLR_VAL2 ; start second column
324
+ POST_COL_2 STR_CLK , POST_CLR_VAL2 ; start second column
335
325
336
326
;----------------------------------------------------------------------------;
337
327
; Check if clock was previously in error and reset
@@ -357,7 +347,7 @@ PRINT_DATETIME PROC
357
347
POP CX ; discard date and time values
358
348
POP DX
359
349
RTC_PRINT_ERR:
360
- MOV SI , OFFSET STR_DT_ERR ; print 'Error' message
350
+ MOV SI , OFFSET STR_ERR ; print 'Error' message
361
351
CALL OUT_SZ
362
352
JMP SHORT RTC_DONE ; end column and exit
363
353
@@ -414,13 +404,13 @@ RTC_PRINT_DATE:
414
404
MOV AL , ' '
415
405
CALL OUT_CHAR
416
406
417
- ;----------------------------------------------------------------------------;
418
- ; Display Time
419
- ;----------------------------------------------------------------------------;
420
407
POP CX ; restore time
421
408
POP DX
422
- MOV AL , CH ; AL = BCD hours
423
409
410
+ ;----------------------------------------------------------------------------;
411
+ ; Print Time
412
+ ;----------------------------------------------------------------------------;
413
+ MOV AL , CH ; AL = BCD hours
424
414
IF TIME_FMT EQ 1 ; 12 hour time
425
415
CMP AL , 12H ; is noon or before?
426
416
JLE TIME_12_DONE ; jump if so
@@ -457,9 +447,9 @@ TIME_12_DONE:
457
447
; If 12 hour time, display a/p
458
448
;
459
449
MOV AL , 'a'
460
- CMP CH , 12H
461
- JL TIME_12_DONE_1
462
- MOV AL , 'p'
450
+ CMP CH , 12H ; hours > 12?
451
+ JL TIME_12_DONE_1 ; if not, leave 'a'
452
+ MOV AL , 'p' ; otherwise, change to 'p'
463
453
TIME_12_DONE_1:
464
454
CALL OUT_CHAR
465
455
ENDIF ; END IF 12 hour time
@@ -556,7 +546,7 @@ GET_RTC ENDP
556
546
;----------------------------------------------------------------------------;
557
547
INT_1A_DEFAULT PROC NEAR
558
548
INT INT_1A_BIOS ; use BIOS function instead
559
- IRET
549
+ IRET ; clobber BIOS INT 1Ah flags and IRET
560
550
INT_1A_DEFAULT ENDP
561
551
562
552
;----------------------------------------------------------------------------;
@@ -569,7 +559,7 @@ INT_1A_DEFAULT ENDP
569
559
;----------------------------------------------------------------------------;
570
560
BCD_TO_WORD PROC
571
561
PUSH BX
572
- MOV BX , AX ; save
562
+ MOV BX , AX ; save input
573
563
CALL BCD_TO_BYTE ; convert low byte
574
564
XCHG AX , BX ; BL = low byte
575
565
MOV AL , AH ; AL = high byte
@@ -592,11 +582,24 @@ BCD_TO_WORD ENDP
592
582
; Clobbers: AH
593
583
;----------------------------------------------------------------------------;
594
584
BCD_TO_BYTE PROC
595
- UNPACK_BCD ; split nibbles in AL into BCD in AH/AL
585
+ CALL UNPACK_BCD ; split nibbles in AL into BCD in AH/AL
596
586
AAD ; AL = unpacked BCD nibbles into decimal
597
587
RET
598
588
BCD_TO_BYTE ENDP
599
589
590
+ ;----------------------------------------------------------------------------;
591
+ ; Convert packed BCD to unpacked BCD
592
+ ;----------------------------------------------------------------------------;
593
+ ; Input:
594
+ ; AL = packed BCD value
595
+ ; Output:
596
+ ; AH/AL = unpacked BCD value
597
+ ;----------------------------------------------------------------------------;
598
+ UNPACK_BCD PROC
599
+ UNPACK_NIB ; unpack nibbles
600
+ RET
601
+ UNPACK_BCD ENDP
602
+
600
603
;----------------------------------------------------------------------------;
601
604
; Convert BYTE to packed BCD
602
605
;----------------------------------------------------------------------------;
@@ -610,19 +613,16 @@ BYTE_TO_BCD PROC
610
613
AAM ; split nibbles to AH / AL
611
614
612
615
;----------------------------------------------------------------------------;
613
- ; Convert Unpacked BCD to Packed BCD in AX
616
+ ; Convert unpacked BCD to packed BCD
614
617
;----------------------------------------------------------------------------;
615
618
; Input:
616
- ; AX = Unpacked BCD value
619
+ ; AH/AL = Unpacked BCD value
617
620
; Output:
618
621
; AL = Packed BCD value, CF = 0
619
622
; Clobbers: AH
620
623
;----------------------------------------------------------------------------;
621
624
PACK_BCD PROC
622
- REPT 4
623
- SHL AH , 1 ; shift low nibble into high nibble
624
- ENDM
625
- OR AL , AH ; combine nibbles
625
+ PACK_NIB ; pack nibbles
626
626
RET
627
627
PACK_BCD ENDP
628
628
BYTE_TO_BCD ENDP
@@ -755,7 +755,6 @@ LEAP_NEXT ENDP
755
755
; CF = 1 if error
756
756
; Clobbers: AX
757
757
;----------------------------------------------------------------------------;
758
- PUBLIC VALIDATE_TIME
759
758
VALIDATE_TIME PROC
760
759
MOV AL , CH
761
760
CALL BCD_TO_BYTE ; AL = BYTE hours
@@ -787,7 +786,6 @@ VALIDATE_TIME ENDP
787
786
; CF = 1 if error
788
787
; Clobbers: AX
789
788
;----------------------------------------------------------------------------;
790
- PUBLIC VALIDATE_DATE
791
789
VALIDATE_DATE PROC
792
790
793
791
;----------------------------------------------------------------------------;
@@ -838,44 +836,40 @@ VER_BANNER DB CR, LF
838
836
DB VER_NAME , ' [' , HEART , '] '
839
837
DB "It' s About Time"
840
838
DB CR , LF
839
+ DB 'Ver: '
840
+ ELSE
841
+ DB VER_NAME , ' ' ; embed name and version
842
+ ENDIF
843
+ DB VER_NUM , ' '
841
844
DB '(C) '
842
845
DB COPY_YEAR
843
846
DB ' 640KB Released under GPLv3'
844
- ELSE
845
- DB VER_NAME , ' '
846
- ENDIF
847
847
STR_CRLF DB CR , LF , 0
848
-
849
- ;VER DB 'v', VER_NUM, ' ', VER_DATE, 0
850
- VER DB VER_NUM , 0
851
-
852
- STR_DT DB 'Clock' , 0
853
- STR_DT_ERR DB 'Error' , 0
854
- STR_DETECT DB 'RTC '
855
- DB POST_L , 0
856
- POST_RSEP DB POST_R , 0
848
+ STR_RTC DB 'RTC' , 0
849
+ STR_CLK DB 'Clock' , 0
850
+ STR_ERR DB 'Error' , 0
857
851
858
852
;----------------------------------------------------------------------------;
859
853
; RTC type display
860
854
;
861
855
STR_NONE DB 'None' , 0
862
856
IFDEF RTC_ AT
863
- STR_ AT DB 'AT ' , 0 ; 1 = AT = DS1285/MC146818
857
+ STR_ AT DB 'AT ' , 0 ; AT = DS1285/MC146818
864
858
ENDIF
865
859
IFDEF RTC_OK
866
- STR_OK DB '5832 ' , 0 ; 2 = OK = MSM5832/1
860
+ STR_OK DB '5832 ' , 0 ; OK = MSM5832/1
867
861
ENDIF
868
862
IFDEF RTC_OK2
869
- STR_OK2 DB '6242 ' , 0 ; = OK2 = MSM6242
863
+ STR_OK2 DB '6242 ' , 0 ; OK2 = MSM6242
870
864
ENDIF
871
865
IFDEF RTC_RP
872
- STR_RP DB 'RP5C15 ' , 0 ; 3 = RP = RP5C15
866
+ STR_RP DB 'RP5C15 ' , 0 ; RP = RP5C15
873
867
ENDIF
874
868
IFDEF RTC_SW
875
- STR_SW DB 'DS1216 ' , 0 ; 4 = SW = DS1216x
869
+ STR_SW DB 'DS1216 ' , 0 ; SW = DS1216x
876
870
ENDIF
877
871
IFDEF RTC_NS
878
- STR_NS DB '58167 ' , 0 ; 6,7 = NS = MM58167AN
872
+ STR_NS DB '58167 ' , 0 ; NS = MM58167AN
879
873
ENDIF
880
874
881
875
;----------------------------------------------------------------------------;
0 commit comments