-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimesave.asm
57 lines (50 loc) · 1.22 KB
/
timesave.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
; TIMESAVE: save date/time to file
; see comments for related code in TIMEREST.ASM
IDEAL
MODEL tiny
DATASEG
INCLUDE "common.inc"
msgerrwrite DB "Error writing to file"
endl
succmsg:
MSuccMsg <"Time saved as">
CODESEG
P8086
ORG 100h
_start: DosCall DOS_GET_DATE
mov [datetime.combined.year], cx
mov [datetime.combined.monthday], dx
DosCall DOS_GET_TIME
mov [datetime.combined.hourminute], cx
mov [datetime.combined.secondfrac], dx
mov cx, (SIZE datetime)/2
xor dx, dx ; start with zero...
mov si, offset datetime
@@cl: lodsw
sub dx, ax ; ...and subtract all words from it
loop @@cl
mov [datetime.combined.checksum], dx
DispatchFilename
xor cx, cx
test [isdefpath], 1
jz @@show
mov cl, DOS_ATTR_HIDDEN ; keep it hidden
@@show: DosCall DOS_CREATE_FILE
jnc s1
OpenErrExit
s1: mov bx, ax
mov cx, SIZE datetime
mov dx, offset datetime
DosCall DOS_WRITE_TO_HANDLE
; HACK: structure is short enough, so no partial writes are assumed
jnc @@s2
ErrExit msgerrwrite
@@s2: DosCall DOS_CLOSE_FILE
jnc @@s3
DosCall DOS_TERMINATE_EXE, 1
@@s3: FillDatePlaceholders
mov dx, offset succmsg
DosCall DOS_WRITE_STRING
DosCall DOS_TERMINATE_EXE, 0
INCLUDE "decimal.inc"
END _start