-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimerest.asm
61 lines (54 loc) · 1.34 KB
/
timerest.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
; TIMEREST: restore date/time from file
IDEAL
MODEL tiny
DATASEG
INCLUDE "common.inc"
msgerrread DB "Error reading from file"
endl
msgerrcorr DB "Saved time corrupt"
endl
succmsg:
MSuccMsg <"Time restored as">
CODESEG
P8086
ORG 100h
_start: DispatchFilename
DosCall DOS_OPEN_FILE, 0 ; read only, exclusive mode
jnc s1 ; call succeeded?
OpenErrExit
s1: mov bx, ax
mov cx, SIZE datetime
mov dx, offset datetime
DosCall DOS_READ_FROM_HANDLE
jc @@f2 ; call failed?
cmp ax, SIZE datetime ; short read?
je @@s2
@@f2: ErrExit msgerrread
@@s2: DosCall DOS_CLOSE_FILE
jnc @@s3
; if DOS fails to close the file, something is seriously wrong
DosCall DOS_TERMINATE_EXE, 1
@@s3: cmp [datetime.combined.signature], sigtext
jne @@invalid ; signature does not match?
mov cx, (SIZE datetime)/2 ; number of words
xor dx, dx
mov si, offset datetime
@@cl: lodsw
add dx, ax
loop @@cl
jz @@valid ; all words have to add to zero
@@invalid:
ErrExit msgerrcorr
@@valid:
mov cx, [datetime.combined.year]
mov dx, [datetime.combined.monthday]
DosCall DOS_SET_DATE
mov cx, [datetime.combined.hourminute]
mov dx, [datetime.combined.secondfrac]
DosCall DOS_SET_TIME
FillDatePlaceholders
mov dx, offset succmsg
DosCall DOS_WRITE_STRING
DosCall DOS_TERMINATE_EXE, 0
INCLUDE "decimal.inc"
END _start