-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathzxcc.doc
207 lines (145 loc) · 6.5 KB
/
zxcc.doc
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
zxcc v0.5.7
zxcc is a wrapper for the Hi-Tech C CP/M compiler, allowing it to be
used as a cross-compiler under UNIX. Version 0.5.0 also works with the
build tools necessary to assemble CP/M 3 (MAC, RMAC, LINK, GENCOM).
New in this version:
* Compiles on boxes where sync() does not return int (reported by
multiple users).
* BDOS function 10 takes a pointer to unsigned char, thus allowing
input buffers longer than 128 bytes (Andy Parkins)
Setting up
Firstly, build the compiler. It should not be necessary to rebuild
bios.bin; but if you have to, it assembles using the z80asm assembler
(part of the z80pack emulation package which can be found on the Walnut
Creek CP/M CDROM) or the [1]ZMAC assembler (downloadable from
<http://www.nenie.org/cpcip/index.html#zmac>).
Previous versions of ZXCC could be compiled under DOS using DJGPP; this
may still be possible, but has not been tested since the build system
was changed to use the GNU autotools.
This version of zxcc contains copies of the CPMIO and CPMREDIR
libraries, so you won't need to obtain them separately.
You will need the tools you want to use; either the Hi-Tech C compiler
for CP/M <[2]http://www.hitech.com.au> or Digital Research's tools at
<[3]http://www.cpm.z80.de> Once you have obtained the tools,
documentation and possibly the library source, you need to decide where
to put the files. zxcc uses three directories:
* BINDIR80 (by default, /usr/local/lib/cpm/bin80) holds the compiler
itself. You should copy the compiler .com files (or MAC, RMAC etc.)
and bios.bin to this directory.
* LIBDIR80 (by default, /usr/local/lib/cpm/lib80) holds the C
libraries libc.lib, libf.lib, crtcpm.obj and rrtcpm.obj.
* INCDIR80 (by default, /usr/local/lib/cpm/include80) holds the
compiler .h files.
The locations of these directories are normally set by the configure
script; you can override them by editing zxcc.h and uncommenting the
lines that redefine them.
Once you have installed zxcc and the build tools, try building Hello
World:
#include <stdio.h>
void main()
{
printf("Hello World\n");
}
or for RMAC:
CSEG
LXI D,HELLO
MVI C,9
CALL 5
RST 0
HELLO: DB 'Hello World',13,10,'$'
To compile the first example, type
zxc hello.c
; if all goes well, you should end up with a file called hello.com. You
can test the resulting file by typing
zxcc hello.com
.
To assemble the second example, type
zxcc rmac.com hello
zxcc link.com hello
and run it as above. NOTE: RMAC requires that lines be terminated with
CR/LF. You may need to put a unix2dos command in your makefile before
you invoke RMAC.
Using zxcc
For detailed instructions, see the documentation for Hi-Tech C or the
CP/M tools. zxcc behaves in the same way, but note the following
points:
Program names
The names of the programs have been changed between CP/M and UNIX; for
example, you would type
zxc hello.c
instead of
c hello.c
. The programs to use are:
zxc
The equivalent of C.COM.
zxas
The equivalent of ZAS.COM.
zxlink
The equivalent of LINK.COM.
zxlibr
The equivalent of LIBR.COM.
All these programs work by converting their arguments to a form
suitable for zxcc, and then invoking zxcc.
There are no front-end programs for the CP/M build tools; you will have
to enter arguments to these in the zxcc format given below.
Filenames
Where the documentation allows you to enter a CP/M filename, you should
instead enter a UNIX one. The filename itself (as opposed to any
directories in its path) must obey CP/M 8.3 naming conventions and be
all lowercase.
Where the documentation requires a CP/M driveletter / user number
-I2:C:
you should enter a path complete with trailing slash:
-I/usr/src/linux-80/include/
Technical
zxcc emulates a subset of CP/M 3; hopefully enough to run the Hi-Tech C
compiler. It can be used as a limited general-purpose CP/M 3 emulator
provided the emulated program only uses a restricted subset of system
calls.
zxcc behaves like the emulator com, allowing CP/M programs to be used
transparently from a UNIX prompt. However com:
* Emulates all of CP/M 2, rather than a subset of CP/M 3;
* Is designed for general use, not tailored to Hi-Tech C;
* Is written partly in assembly language and will only run on
68000-based computers;
* Cannot map UNIX directories to CP/M drives;
* Contains some bugs connected with command parsing and file I/O.
Syntax for zxcc is:
zxcc comfile.com arg1 arg2 ...
The comfile is the program to run; zxcc searches the current directory
and BINDIR80 for it.
The arguments are parsed in this way:
* Any argument starting with a - sign is passed to the CP/M program
as-is, minus the leading - sign.
* Any argument starting with a + sign is parsed as a filename (see
below) and then concatenated to the previous argument.
* Any argument starting "+-" is concatenated without being parsed.
* All other arguments are parsed as filenames. The UNIX pathname is
converted to a CP/M driveletter.
For example:
zxcc foo.com --Q -A /dev/null --I +/dev/zero +-, +/foo/bar
would pass these arguments to foo.com:
-Q A d:null -Id:zero,e:bar
The other programs are merely wrappers that convert their command lines
into the form required by zxcc.
Errors
Any errors raised by the zxcc runtime system will be prefixed with
zxcc:. Some errors you may encounter are:
Unsupported BDOS call
Part of CP/M 3 that the program uses has not been emulated. Add
the required functionality to zxbdos.c and recompile.
Z80 encountered invalid trap
The CP/M program being run attempted to call the zxcc runtime
system with an unknown call number. This will happen if the
program was written for my emulator "Joyce".
Acknowledgements
* Hi-Tech C was written by Hi-Tech Software.
* The Z80 emulation engine was written by Ian Collier.
* Thanks to Jacob Nevins, Andy Parkins and others for bug fix
suggestions.
__________________________________________________________________
John Elliott, 28 March 2003
References
1. http://www.nenie.org/cpcip/index.html#zmac
2. http://www.hitech.com.au/
3. http://www.cpm.z80.de/