summaryrefslogtreecommitdiff
path: root/v4.0/src/BIOS/CLOCKSUB.INC
diff options
context:
space:
mode:
Diffstat (limited to 'v4.0/src/BIOS/CLOCKSUB.INC')
-rw-r--r--v4.0/src/BIOS/CLOCKSUB.INC78
1 files changed, 78 insertions, 0 deletions
diff --git a/v4.0/src/BIOS/CLOCKSUB.INC b/v4.0/src/BIOS/CLOCKSUB.INC
new file mode 100644
index 0000000..65b6698
--- /dev/null
+++ b/v4.0/src/BIOS/CLOCKSUB.INC
@@ -0,0 +1,78 @@
1;
2; date_verify loosely checks bcd date values to be in range in bin_date_time
3;
4date_verify: ;
5assume ds:code,es:nothing
6 cmp byte ptr bin_date_time+0,20h ; century check
7 ja date_error ; jmp error
8 jz century_20 ; jmp in 20th century
9 cmp byte ptr bin_date_time+0,19h ; century check
10 jb date_error ; jmp error
11 cmp byte ptr bin_date_time+1,80h ; year check
12 jb date_error ; jmp error
13century_20: ;
14 cmp byte ptr bin_date_time+1,99h ; year check
15 ja date_error ; jmp error
16 cmp byte ptr bin_date_time+2,12h ; month check
17 ja date_error ; jmp error
18 cmp byte ptr bin_date_time+2,00h ; month check
19 jbe date_error ; jmp error
20 cmp byte ptr bin_date_time+3,31h ; day check
21 ja date_error ; jmp error
22 cmp byte ptr bin_date_time+3,00h ; day check
23 jbe date_error ; jmp error
24 clc ; set success flag
25 ret ;
26date_error: ;
27 stc ; set error flag
28 ret ;
29
30;
31; time_verify very loosely checks bcd date values to be in range in bin_date_time
32;
33time_verify:
34assume ds:code,es:nothing
35 cmp byte ptr bin_date_time+0,24H
36 ja time_error
37 cmp byte ptr bin_date_time+1,59H
38 ja time_error
39 cmp byte ptr bin_date_time+2,59H
40 ja time_error
41 clc
42 ret
43time_error:
44 stc
45 ret
46
47;
48; bcd_verify checks values in bin_date_time to be valid
49; bcd numerals. carry set if any nibble out of range
50;
51bcd_verify: ;
52assume ds:code,es:nothing
53 mov cx,4 ; 4 bytes to check
54 mov bx,offset bin_date_time ;
55bv_loop: ;
56 mov al,[bx] ; get a bcd number (0..99)
57 mov ah,al ;
58 and ax,0f00fh ; 10's place in high ah, 1's in al
59 cmp al,10 ; is 1's place in range?
60 ja bv_error ; jmp out of range
61 shr ah,1 ; swap nibbles
62 shr ah,1 ; ...
63 shr ah,1 ; ...
64 shr ah,1 ; ...
65 and ah,0fh ; get rid of any erroneous bits
66 cmp ah,10 ; is 10's place in range
67 ja bv_error ; jmp out of range
68 inc bx ; next byte
69 dec cx ;
70 jnz bv_loop ;
71 clc ; set success flag
72 ret ;
73bv_error: ;
74 stc ; set error flag
75 ret ;
76;
77; Dos 3.30 - The real time clock structures were moved to msbio2.asm
78;