Skip to content

Commit d22b2af

Browse files
committed
Merge branch 'v0.9-dev'
# Conflicts: # src/cc64/scanner.fth # tests/unit/Makefile # tests/unit/build-run-test.sh # tests/unit/scanner-test.fth # tests/unit/scanner-test.golden
2 parents 0e62182 + 8bf6608 commit d22b2af

File tree

185 files changed

+6518
-656
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

185 files changed

+6518
-656
lines changed

C-lang-subset.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ accordingly.
2222
- No implicit `int f(int i)` function declaration.
2323
All functions must be declared or defined before first calling them.
2424
- No real preprocessor.
25-
- - `#define` just defines a constant on the compiler level. There's no
25+
- `#define` just defines a constant on the compiler level. There's no
2626
text substitution as such.
27-
- - Accordingly no macros with parameters. No #undef. No #ifdef/#ifndef.
28-
- - `#include` works as expected, with max 4 levels of include files.
29-
- - `#pragma cc64` defines the memory layout for the code generator and is
27+
- Accordingly no macros with parameters. No #undef. No #ifdef/#ifndef.
28+
- `#include` works as expected, with max 4 levels of include files.
29+
- `#pragma cc64` defines the memory layout for the code generator and is
3030
described in [runtime libraries](Runtime-libs.md).
3131

3232

Makefile

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ c16: cc64-c16-t64 $(c16dir_files) cc64-c16files.zip cc64-c16files.d64
6868

6969
x16: $(x16dir_files) cc64-x16files.zip cc64-x16files-sdcard.zip
7070

71-
cc64-c64-t64: $(cc64_c64_t64_files)
71+
cc64-c64-t64: $(cc64_c64_t64_files) autostart-c64/cc64prof.T64
7272

7373
cc64-c16-t64: $(cc64_c16_t64_files)
7474

@@ -84,10 +84,6 @@ cc64-x16files.zip: $(x16dir_files) COPYING
8484
rm -f $@
8585
zip -r $@ $^
8686

87-
$(recompile_dir).zip: $(recompile_srcs) $(recompile_forths) COPYING
88-
rm -f $@
89-
zip -r $@ $^
90-
9187
cc64-c64files.d64: $(c64dir_files) tmp/copying
9288
rm -f $@
9389
c1541 -format cc64-c64,cc d64 $@
@@ -190,10 +186,10 @@ clean:
190186
rm -f c64files/*.fth c16files/*.fth x16files/*.fth
191187
rm -f c64files/*.log c16files/*.log x16files/*.log
192188
rm -f x16files.img recompile-readme
193-
rm -f [cx][16][64]files/notdone
194-
rm -f emulator/sdcard.img tmp/* cc64-doc.zip
195-
rm -rf release
189+
rm -f [cx][16][64]files/notdone cc64-doc.zip
190+
rm -rf release tmp/*
196191
rm -rf $(recompile_dir) $(recompile_dir).zip
192+
$(MAKE) -C emulator clean
197193
$(MAKE) -C tests/e2e clean
198194
$(MAKE) -C tests/integration clean
199195
$(MAKE) -C tests/peddi clean
@@ -210,10 +206,14 @@ veryclean: clean
210206
rm -f autostart-c64/*.T64 autostart-c16/*.T64
211207
rm -f runtime/*
212208

209+
# Convenience rule for interactive debugging/developing:
210+
# Provide all Forth sources in c64files/ in PETSCII format.
211+
petscii64: $(cc64srcs_c64) $(peddisrcs_c64)
212+
213213

214214
test64: autostart-c64/cc64.T64
215-
$(MAKE) -C tests/e2e fasttests64
216215
$(MAKE) -C tests/unit tests
216+
$(MAKE) -C tests/e2e fasttests64
217217
$(MAKE) -C tests/integration tests
218218

219219
alltests: sut
@@ -234,33 +234,41 @@ slowtests: sut
234234
$(MAKE) -C tests/integration tests
235235
$(MAKE) -C tests/peddi tests
236236

237-
sut: autostart-c64/cc64.T64 autostart-c16/cc64.T64 x16files/cc64
238-
237+
sut: autostart-c64/cc64.T64 autostart-c16/cc64.T64 x16files/cc64 \
238+
autostart-c64/cc64pe.T64 autostart-c16/cc64pe.T64 \
239+
autostart-c64/peddi.T64 autostart-c16/peddi.T64 \
240+
autostart-c64/cc64prof.T64
239241

240242
# cc64 build rules
241243

242244
%files/cc64: $(cc64srcs_c64) $(cc64srcs_c16) \
243-
build/build-cc64.sh emulator/run-in-vice.sh \
245+
emulator/build-binary.sh emulator/run-in-vice.sh \
244246
autostart-%/vf-build-base.T64
245-
build/build-cc64.sh $*
247+
emulator/build-binary.sh $* cc64
246248

247249
%files/cc64pe: \
248250
$(cc64srcs_c64) $(cc64srcs_c16) \
249251
$(peddisrcs_c64) $(peddisrcs_c16) \
250-
build/build-cc64pe.sh emulator/run-in-vice.sh \
252+
emulator/build-binary.sh emulator/run-in-vice.sh \
251253
autostart-%/vf-build-base.T64
252-
build/build-cc64pe.sh $*
254+
emulator/build-binary.sh $* cc64pe
253255

254256
%files/peddi: $(peddisrcs_c64) $(peddisrcs_c16) \
255-
build/build-peddi.sh emulator/run-in-vice.sh \
257+
emulator/build-binary.sh emulator/run-in-vice.sh \
256258
autostart-%/vf-build-base.T64
257-
build/build-peddi.sh $*
259+
emulator/build-binary.sh $* peddi
258260

259261

260262
x16files/cc64: $(cc64srcs_x16) \
261-
build/build-cc64.sh emulator/run-in-x16emu.sh \
262-
x16files/vf-build-base emulator/sdcard.img
263-
build/build-cc64.sh x16
263+
emulator/build-binary.sh emulator/run-in-x16emu.sh \
264+
x16files/vf-build-base
265+
emulator/build-binary.sh x16 cc64
266+
267+
268+
c64files/cc64prof: $(cc64srcs_c64) \
269+
emulator/build-binary.sh emulator/run-in-vice.sh \
270+
autostart-c64/vf-build-base.T64
271+
emulator/build-binary.sh c64 cc64prof
264272

265273

266274
# build base rule
@@ -281,28 +289,28 @@ $(recompile_dir)/%: forth/%
281289
# Runtime module rules
282290

283291
runtime/rt-c64-0801.o runtime/rt-c64-0801.h: \
284-
src/runtime/rt-c64-0801.a build/generate_pragma_cc64.awk
292+
src/runtime/rt-c64-0801.a src/runtime/generate_pragma_cc64.awk
285293
test -d tmp || mkdir tmp
286294
acme -f cbm -l tmp/rt-c64-0801.sym -o runtime/rt-c64-0801.o \
287295
src/runtime/rt-c64-0801.a
288-
awk -f build/generate_pragma_cc64.awk -F '$$' tmp/rt-c64-0801.sym \
289-
> runtime/rt-c64-0801.h
296+
awk -f src/runtime/generate_pragma_cc64.awk -F '$$' \
297+
tmp/rt-c64-0801.sym > runtime/rt-c64-0801.h
290298

291299
runtime/rt-c16-1001.o runtime/rt-c16-1001.h: \
292-
src/runtime/rt-c16-1001.a build/generate_pragma_cc64.awk
300+
src/runtime/rt-c16-1001.a src/runtime/generate_pragma_cc64.awk
293301
test -d tmp || mkdir tmp
294302
acme -f cbm -l tmp/rt-c16-1001.sym -o runtime/rt-c16-1001.o \
295303
src/runtime/rt-c16-1001.a
296-
awk -f build/generate_pragma_cc64.awk -F '$$' tmp/rt-c16-1001.sym \
297-
> runtime/rt-c16-1001.h
304+
awk -f src/runtime/generate_pragma_cc64.awk -F '$$' \
305+
tmp/rt-c16-1001.sym > runtime/rt-c16-1001.h
298306

299307
runtime/rt-x16-0801.o runtime/rt-x16-0801.h: \
300-
src/runtime/rt-x16-0801.a build/generate_pragma_cc64.awk
308+
src/runtime/rt-x16-0801.a src/runtime/generate_pragma_cc64.awk
301309
test -d tmp || mkdir tmp
302310
acme -f cbm -l tmp/rt-x16-0801.sym -o runtime/rt-x16-0801.o \
303311
src/runtime/rt-x16-0801.a
304-
awk -f build/generate_pragma_cc64.awk -F '$$' tmp/rt-x16-0801.sym \
305-
> runtime/rt-x16-0801.h
312+
awk -f src/runtime/generate_pragma_cc64.awk -F '$$' \
313+
tmp/rt-x16-0801.sym > runtime/rt-x16-0801.h
306314

307315
runtime/rt-c64-0801.i:
308316
awk 'BEGIN{ printf("\x00\x90");}' > $@
@@ -390,12 +398,6 @@ autostart-x16/%.T64: x16files/%
390398
bin2t64 $< $@
391399

392400

393-
# X16 emulator rules
394-
395-
emulator/sdcard.img: emulator/sdcard.sfdisk emulator/mk-sdcard.sh
396-
emulator/mk-sdcard.sh emulator/sdcard.sfdisk $@
397-
398-
399401
# Generic rules to populate c64files/, c16files/, x16files/
400402

401403
c64files/%.fth: src/*/%.fth

Runtime-libs.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,21 @@ in hex, and one string parameter, a file base name. It has the following form:
8585
*statics-start*, *statics-end*, *rt-basename*
8686

8787
- *cc-sp*:
88-
- - a zero page address pair used as stack pointer for C local variables
88+
- a zero page address pair used as stack pointer for C local variables
8989
- *zp*:
90-
- - a second zero page address pair that the compiled code may use
90+
- a second zero page address pair that the compiled code may use
9191
- *rt-start*:
92-
- - the first code address of the runtime module
92+
- the first code address of the runtime module
9393
- *rt-jumplist*:
94-
- - the address of the runtime modules jump list (see below)
94+
- the address of the runtime modules jump list (see below)
9595
- *rt-end*:
96-
- - the first free code address after the end of the runtime module
96+
- the first free code address after the end of the runtime module
9797
- *statics-start*:
98-
- - the lowest address of the runtime module's static vars
98+
- the lowest address of the runtime module's static vars
9999
- *statics-end*:
100-
- - the hightest address + 1 of the runtime module's static vars
100+
- the hightest address + 1 of the runtime module's static vars
101101
- *rt-basename*:
102-
- - the base filename of the runtime module. *basename*.o is then the
102+
- the base filename of the runtime module. *basename*.o is then the
103103
code, *basename*.i the initialzation values of the module's static vars. (Of
104104
course *basename*.h is the header file containing the module's symbol
105105
definitions and the #pragma cc64 directive.)
@@ -125,17 +125,17 @@ statics_last .word 0
125125
The first part of the jumplist is a list of 4 addresses:
126126

127127
- `rt_jumplist`
128-
- - This address (equal to main_addr, of course) is #pragma cc64's 4th param
128+
- This address (equal to main_addr, of course) is #pragma cc64's 4th param
129129
and the runtime module's anchor for the compiler.
130130
- `main_adr`
131-
- - Here the main()-function's address is inserted by the compiler. The
131+
- Here the main()-function's address is inserted by the compiler. The
132132
runtime module's initialization calls main() with a jmp (main.adr).
133133
- `code_last`
134-
- - Here the last address + 1 of the generated code is inserted by the compiler.
134+
- Here the last address + 1 of the generated code is inserted by the compiler.
135135
- `statics_first`
136-
- - Here the first address of the generated code is inserted by the compiler.
136+
- Here the first address of the generated code is inserted by the compiler.
137137
- `statics_last`
138-
- - Here the last address + 1 of the generated code is inserted by the compiler.
138+
- Here the last address + 1 of the generated code is inserted by the compiler.
139139

140140
As described above, statics are allocated from the end of the used memory
141141
downwards. The statics' initialization values are placed by the
@@ -147,10 +147,10 @@ In case of no static variables, init_first will be equal to init_last.
147147
After the addresses follows a list of 6 jmp instructions:
148148

149149
- `jmp (zp)`
150-
- - This it is used to emulate `jsr (zp)`. zp is the second zero
150+
- This it is used to emulate `jsr (zp)`. zp is the second zero
151151
page pointer used by the compiler.
152152
- `jmp switch`
153-
- - Code generated for switch statements consists of loading into a/x
153+
- Code generated for switch statements consists of loading into a/x
154154
the 16 bit value to match to case statements and a jsr to this address.
155155
Following the calling jsr-instruction will be an array of pairs of 16 bit
156156
values, one pair per case statement. The second value in each pair is the case
@@ -163,15 +163,15 @@ It then compares a/x to the 2nd value of each pair, jumps to the pair's first
163163
address in case of match, and in case of no match jumps behind the terminating
164164
0 at the end of the list.
165165
- jmp mult
166-
- - Multiplies (signed) the content of a/x with the integer in zp/zp+1,
166+
- Multiplies (signed) the content of a/x with the integer in zp/zp+1,
167167
leaving the result in a/x.
168168
- jmp divmod
169-
- - Divides (signed) zp/zp+1 by a/x, leaving the result in a/x and the
169+
- Divides (signed) zp/zp+1 by a/x, leaving the result in a/x and the
170170
remainder in zp/zp+1.
171171
- jmp shl
172-
- - Arithmetically shifts left a/x by y bits.
172+
- Arithmetically shifts left a/x by y bits.
173173
- jmp shr
174-
- - Arithmetically shifts right a/x by y bits.
174+
- Arithmetically shifts right a/x by y bits.
175175

176176
The jumplist may be positioned anywhere in the library.
177177

Usage.md

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -107,72 +107,72 @@ can be given either in decimal or, with a preceeding $, in hex.
107107
### Main commands
108108

109109
- `help`
110-
- - shows a list of all commands
110+
- shows a list of all commands
111111
- `cc` _file.c_
112-
- - compiles _file.c_, producing
113-
- - - a binary executable _file_ if _file.c_ contains a `main()` function
114-
- - - an extended runtime library consisting of _file.h_, _file.i_, _file.o_
112+
- compiles _file.c_, producing
113+
- a binary executable _file_ if _file.c_ contains a `main()` function
114+
- an extended runtime library consisting of _file.h_, _file.i_, _file.o_
115115
otherwise
116116
- `ed` _file_
117-
- - opens _file_ in the text editor
117+
- opens _file_ in the text editor
118118
- `cat` _file_
119-
- - displays the content of _file_ on the screen
119+
- displays the content of _file_ on the screen
120120
- `bye`
121-
- - exits cc64
121+
- exits cc64
122122

123123
### Disk commands
124124

125125
- `dos`
126-
- - reads and prints the error channel of the cc64's configured main disk drive
126+
- reads and prints the error channel of the cc64's configured main disk drive
127127
(see `device?` and `device` below)
128128
- `dos` _xxx_
129-
- - sends the command _xxx_ to cc64's configured main disk drive
129+
- sends the command _xxx_ to cc64's configured main disk drive
130130
- `dir`
131-
- - lists the directory of cc64's configured main disk drive
131+
- lists the directory of cc64's configured main disk drive
132132
- `device?`
133-
- - shows the device number of the disk drive cc64 uses for source files and
133+
- shows the device number of the disk drive cc64 uses for source files and
134134
compilation outputs, and the device number of the auxiliary disk drive where
135135
cc64 places temporary files during compile. By default these are the same,
136136
and there's only a reason to change that if space on the main drive becomes
137137
an issue. Note: Currently the `dos` command only works on the main drive.
138138
- _n_ `device`
139-
- - configures cc64 to use device _n_ as main disk drive
139+
- configures cc64 to use device _n_ as main disk drive
140140
- _n_ `auxdev`
141-
- - configures cc64 to use device _n_ as auxiliary disk drive for temp files
141+
- configures cc64 to use device _n_ as auxiliary disk drive for temp files
142142

143143
### Memory commands
144144

145145
- `mem`
146-
- - displays the compiler's memory setup
146+
- displays the compiler's memory setup
147147
- _nnn_ `set-himem`
148-
- - sets the upper limit of the compiler's memory to _nnn_. Default value is
148+
- sets the upper limit of the compiler's memory to _nnn_. Default value is
149149
$cbd0. The memory $cbd0-$cfff is needed by [c-charset](#c-charset) which cc64
150150
recognizes and activates if it is installed. If a c-chargen rom generated by
151151
[c-char-rom-gen](#c-char-rom-gen) is used, e.g. in an emulator, or if no C
152152
charset (which provides the characters \^_{|}~) is desired, then himem can be
153153
set to $d000.
154154
- _nnn_ `set-heap`
155-
- - sets the heap to _nnn_ elements. One heap element is needed for each forward
155+
- sets the heap to _nnn_ elements. One heap element is needed for each forward
156156
function reference, i.e. for each function that is called before it is defined.
157157
A prototype, i.e. a declaraion, must exist before a function can be called.
158158
- _nnn_ `set-hash`
159-
- - sets the hash table size for global symbols. Needs at least one element per
159+
- sets the hash table size for global symbols. Needs at least one element per
160160
compiled global symbol and should be sized reasonably generous for hasing to
161161
be efficient. I'm sorry to say I don't have data yet, though.
162162
- _nnn_ `set-symtab`
163-
- - sets the symbol table size in bytes. This is used both for local and
163+
- sets the symbol table size in bytes. This is used both for local and
164164
global symbols and must be increased if a symbol table overflow error occurs.
165165
- _nnn_ `set-code`
166-
- - sets the size of the code buffer in bytes. The compiled code for each
166+
- sets the size of the code buffer in bytes. The compiled code for each
167167
individual compiled function must fit completely into this buffer. Otherwise,
168168
a function too long error is thrown.
169-
- - The remaining memory aka staticbuffer is used to buffer initialization values
169+
- The remaining memory aka staticbuffer is used to buffer initialization values
170170
of static variables. Its size isn't critical as it is flushed to file when full;
171171
it just needs to be positive.
172-
- - Not available on the X16 where a fixed code buffer of 8 kB lives in
172+
- Not available on the X16 where a fixed code buffer of 8 kB lives in
173173
banked RAM.
174174
- _nnn_ _mmm_ `set-stacks`
175-
- - sets the size of data stack (_nnn_ bytes) and return stack (_mmm_ bytes)
175+
- sets the size of data stack (_nnn_ bytes) and return stack (_mmm_ bytes)
176176
and resets the system. Note that the sizes shown by `mem` will be _nnn_ minus 6
177177
and _mmm_ plus 6.
178178
The stack sizes determine the maximum depth of arithmetic expressions and the
@@ -183,9 +183,19 @@ are, and alas again I don't have any data to guide by yet.
183183
Should the compiler behave strangely on some deeply nested code, it should
184184
be reloaded freshly from disk, and the stack sizes set to higher values.
185185
- `saveall` _name_
186-
- - saves the complete compiler together with its actual memory settings to a
186+
f- saves the complete compiler together with its actual memory settings to a
187187
new file _name_
188188

189+
### Misc commands
190+
191+
- `1 list!`
192+
- `0 list!`
193+
- switches listing the C source while compiling on respectively off. Default is off. Listing can cause ~25% increase in pass1 compile time.
194+
- `list?`
195+
- shows whether listing is currently on or off.
196+
- `exec` _file_
197+
- reads _file_ and executes the commands therein. This can be used e.g. to script compile operations.
198+
189199

190200
## Peddi
191201

@@ -194,7 +204,7 @@ There's no limit in line length (exept memory).
194204
Memory overflow is signalled by a double flash of the screen border.
195205
Peddi is called with
196206

197-
`ed filename`
207+
`ed` _file_
198208

199209
Inside the editor, there are these key bindings:
200210
```
@@ -370,3 +380,11 @@ run, will the ROM charset into RAM (at $c000), patch the needed characters,
370380
and then save the RAM $c000-$cfff to disk in a file named `c-chargen` which
371381
then can be used by an emulator as chargen or programmed into an (E)EPROM and
372382
used in a real C64.
383+
384+
## Keyboard
385+
386+
There are two custom keyboard maps for VICE available in the
387+
[emulator/](https://github.com/pzembrod/cc64/tree/master/emulator) directory that I use under Linux to map the C characters \^_{|}~ symbolically to the respective keys on the host keymap, one for the
388+
[C64](https://github.com/pzembrod/cc64/blob/master/emulator/x11_sym_c64_vf_de.vkm) and one for the [C16](https://github.com/pzembrod/cc64/blob/master/emulator/x11_sym_c16_vf_de.vkm). The options I use are visible [here](https://github.com/pzembrod/cc64/blob/master/emulator/which-vice.sh), and I should add the disclaimer that I use German keyboard layouts, though I believe this should not matter since the key mapping used is symbolic, not positional.
389+
390+
For x16emu I currently actually don't know how to type those keys in PETSCII mode. The right thing to do is likely anyway to compile an ISO version of cc64 - which is on my road map.

0 commit comments

Comments
 (0)