From a35b8eaf60bc75810264083a5f0f22f744dac24b Mon Sep 17 00:00:00 2001 From: slederer Date: Sun, 6 Oct 2024 22:55:35 +0200 Subject: [PATCH] Bugfix int range in sasm, create Makefile, portability fixes --- .gitignore | 7 +++++++ README.md | 13 +++++++++++- lib/coreloader.s | 2 +- pcomp/Makefile | 47 ++++++++++++++++++++++++++++++++++++++++++++ pcomp/make.bat | 2 ++ pcomp/platform+.pas | 2 +- pcomp/sasm.pas | 5 ++++- tridoraemu/README.md | 5 +++-- 8 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 pcomp/Makefile diff --git a/.gitignore b/.gitignore index 2096fdb..8c4319b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ pcomp/*.s progs/*.s +lib/stdlib.s tests/*.s examples/*.s !runtime.s @@ -22,6 +23,12 @@ sine.pas graph1.pas graph2.pas chase.pas +pcomp/libgen +pcomp/lsymgen +pcomp/pcomp +pcomp/sasm +pcomp/sdis +tridoraemu/tridoraemu **/tridoracpu.cache/ **/tridoracpu.hw/ **/tridoracpu.ip_user_files/ diff --git a/README.md b/README.md index 152a2ec..efc7d1c 100644 --- a/README.md +++ b/README.md @@ -65,14 +65,25 @@ Everything is open source, so you can read, understand and modify the whole syst - file system is very primitive: only contiguous blocks, no subdirectories - simple shell reminiscent of TP3.0, edit, compile, run programs +## Building the Compiler +- you need to have _FPC_ and _Python3_ installed +- on Linux, you need _make_ installed +- in the **pcomp** directory, run **make** (or **make.bat** on Windows) +- on Linux, you can also run **make nativeprogs** and **make examples** + +## Getting the ROM image +- there are two formats for the ROM image, one for the emulator (**rommon.prog**) and one for building the FPGA bitstream (**rom.mem**) +- to get the **rommon.prog** file, either copy it from the _tridoraemu_ package file or build it +- to build **rom.mem** and **rommon.prog**, find both files in the **lib** directory after running **make nativeprogs** (or **make.bat**) in the **pcomp** directory (see above) + ## Building the FPGA bitstream - install Vivado (known to work with 2020.1, known NOT to work with 2024.1) - install the package for your board in Vivado (Tools -> Vivado Store -> Boards) +- copy the ROM image (**rom.mem**) into the **tridoracpu** directory (see above) - start Vivado and open the project file **tridoracpu.xpr** in the **tridoracpu** directory - run synthesis, implementation and bitstream generation (Flow -> Generate Bitstream) - program your device (Flow -> Open Hardware Manager), the bitstream file should be in **tridoracpu/tridoracpu.runs/impl_1** - the bitstream file for (temporarily) programming your device is named **top.bit**, the file for flashing your device is named **top.bin** - ## Documentation - [Instruction Reference](doc/tridoracpu.md) - [Memory Layout](doc/mem.md) diff --git a/lib/coreloader.s b/lib/coreloader.s index 542b667..46a63bf 100644 --- a/lib/coreloader.s +++ b/lib/coreloader.s @@ -276,4 +276,4 @@ SHELL_ERR: FOUND_MSG: .BYTE " shell.prog ",0 -%include corelib.s +%include "corelib.s" diff --git a/pcomp/Makefile b/pcomp/Makefile new file mode 100644 index 0000000..3f6473d --- /dev/null +++ b/pcomp/Makefile @@ -0,0 +1,47 @@ +PCOMP=./pcomp +SASM=./sasm +LSYMGEN=./lsymgen +LIBGEN=./libgen + +.SUFFIXES: +.SUFFIXES: .pas .o + +.pas: + fpc -Mobjfpc -gl $< + +all: pcomp sasm sdis libgen lsymgen + +libs: pcomp sasm lsymgen libgen + $(SASM) ../lib/coreloader.s + $(LSYMGEN) ../lib/coreloader.sym + $(PCOMP) -n ../lib/stdlib.pas + $(LIBGEN) ../lib/stdlib.s + $(LIBGEN) ../lib/runtime.s + $(LIBGEN) ../lib/float32.s + +nativecomp: pcomp sasm libs + $(PCOMP) sasm.pas + $(PCOMP) pcomp.pas + $(PCOMP) lsymgen.pas + $(PCOMP) libgen.pas + +nativeprogs: nativecomp + $(PCOMP) ../progs/shell.pas + $(PCOMP) ../progs/editor.pas + $(PCOMP) ../progs/reclaim.pas + $(PCOMP) ../progs/dumpdir.pas + $(PCOMP) ../progs/partmgr.pas + $(PCOMP) ../progs/xfer.pas + $(SASM) ../lib/rommon.s + $(SASM) -A ../lib/rommon.s ../lib/rom.mem +examples: nativecomp + $(PCOMP) ../tests/readtest.pas + $(PCOMP) ../tests/readchartest.pas + $(PCOMP) ../tests/timetest.pas + $(PCOMP) ../tests/test133.pas + -$(PCOMP) ../examples/chase.pas + $(PCOMP) ../tests/cchangetest.pas + $(PCOMP) ../tests/tree.pas + +clean: + rm -f pcomp sasm sdis libgen lsymgen *.o *.s diff --git a/pcomp/make.bat b/pcomp/make.bat index 22157a6..40e8eee 100644 --- a/pcomp/make.bat +++ b/pcomp/make.bat @@ -26,6 +26,8 @@ py pcomp.py ..\progs\reclaim.pas py pcomp.py ..\progs\dumpdir.pas py pcomp.py ..\progs\partmgr.pas py pcomp.py ..\progs\xfer.pas +sasm ..\lib\rommon.s +sasm -A ..\lib\rommon.s ..\lib\rom.mem rem exit /b diff --git a/pcomp/platform+.pas b/pcomp/platform+.pas index 73c04c5..f4ab281 100644 --- a/pcomp/platform+.pas +++ b/pcomp/platform+.pas @@ -2,7 +2,7 @@ procedure initPlatform; begin outputPrefix := ''; - includePrefix := '..\lib\'; + includePrefix := '../lib/'; end; procedure newString(var s:StringRef;len:integer); diff --git a/pcomp/sasm.pas b/pcomp/sasm.pas index 4d15987..8d63792 100644 --- a/pcomp/sasm.pas +++ b/pcomp/sasm.pas @@ -1185,7 +1185,10 @@ begin intValue := getSymbolValue(value) else intValue := convertNumber(value); - emitWord(intValue + current^.offset); + + if intValue <> Unresolved then + intValue := intValue + current^.offset; + emitWord(intValue); current := current^.prev; end; diff --git a/tridoraemu/README.md b/tridoraemu/README.md index 0ec332b..f49b534 100644 --- a/tridoraemu/README.md +++ b/tridoraemu/README.md @@ -5,9 +5,10 @@ - written in Golang ## Getting started -From the command line, run the *tridoraemu* or *tridoraemu.exe* program inside the *tridoraemu* directory (see below for details). +Download this zipfile: [tridoraemu.zip](https://git.insignificance.de/api/packages/slederer/generic/tridoraemu/0.0.1/tridoraemu.zip). +It contains the sources, the ROM image, an SD-card image and a precompiled windows binary. -A precompiled binary for Windows is provided. +From the command line, run the *tridoraemu* or *tridoraemu.exe* program inside the *tridoraemu* directory (see below for details). To build the program yourself, you need to have the Go language installed on your system. Building has been tested on Windows and Linux.