-
Notifications
You must be signed in to change notification settings - Fork 26
/
putunix.mac
103 lines (91 loc) · 1.41 KB
/
putunix.mac
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
; PUT CP/M FILE INTO UNIX UTILITY
; putunix driveletter:cpmfilename.extension unixfilename.extension
;
.Z80
SRCFCB EQU 005CH
SECFCB EQU 006CH
CBIOS EQU 0EA00H
OPNUNX EQU CBIOS+33H
CRTUNX EQU CBIOS+36H
RDUNX EQU CBIOS+39H
WRUNX EQU CBIOS+3CH
CLSUNX EQU CBIOS+3FH
BDOS EQU 5
OPEN EQU 15
CLOSE EQU 16
READ EQU 20
WRITE EQU 21
CREATE EQU 22
SETDMA EQU 26
PRINT EQU 9
CSEG
ENTRY START
START:
LD SP,STACK
;MOVE DESTINATION FCB
LD HL,SECFCB
LD DE,DSTFCB
LD BC,10H
LDIR
LD HL,DSTFCB+16
LD DE,DSTFCB+17
LD (HL),0
LD BC,20H
LDIR
;OPEN SOURCE FILE
LD DE,SRCFCB
LD C,OPEN
CALL BDOS
CP 0FFH
JP Z,ERROR1
;CREATE DESTINATION FILE
LD DE,DSTFCB
CALL CRTUNX
AND A
JP NZ,ERROR2
;SET DMA ADDRESS
LD DE,0080H
LD C,SETDMA
CALL BDOS
;READ ONE, WRITE ONE
LOOP: LD DE,SRCFCB
LD C,READ
CALL BDOS
AND A
JP NZ,CLOSEM
LD DE,DSTFCB
CALL WRUNX
AND A
JP NZ,ERROR4
JP LOOP
;CLOSE UNIX FILE
CLOSEM: LD DE,DSTFCB
CALL CLSUNX
AND A
JP Z,CLSCPM
CLSCPM: LD DE,SRCFCB
LD C,CLOSE
CALL BDOS
JP 0
ERROR1: LD DE,STR1
JP ERROR
STR1: DEFM "ERROR1"
DEFB 13,10,'$'
ERROR2: LD DE,STR2
JP ERROR
STR2: DEFM "ERROR2"
DEFB 13,10,'$'
ERROR3: LD DE,STR3
JP ERROR
STR3: DEFM "ERROR3"
DEFB 13,10,'$'
ERROR4: LD DE,STR4
JP ERROR
STR4: DEFM "ERROR4"
DEFB 13,10,'$'
ERROR: LD C,PRINT
CALL BDOS
JP 0
DSTFCB: DEFS 200
STACK: DEFS 1
END