Skip to content

Latest commit

 

History

History
63 lines (50 loc) · 3.13 KB

File metadata and controls

63 lines (50 loc) · 3.13 KB

Download and start

Currently, there is no setup and no automatic attachment of libraries, so a few steps are necessary. First, download the entire project: https://github.com/tquester/ZXBasicCompiler/archive/refs/heads/main.zip

You will also need:

To view, edit, and test the compiled code:

  • Visual Studio code Visual Studio Code - Code Editing. Redefined
  • DeZog maziac/DeZog: Visual Studio Code Debugger for Z80/ZX Spectrum.

To modify the compiler itself, a Java IDE is recommended, for example

Writing a BASIC program

Now use your ZX Spectrum emulator to write a BASIC program and save it to a virtual tape (.tap).

Start the compiler

The compiler is located in the directory Article2\Assembler Edit the file compile.bat

set assembler=E:/Emulator/z80/dev/sjasmplus-1.20.2.win/sjasmplus.exe
java -jar ..\..\zxcompiler.jar %1 %2 %3 %4 %5 %6 %7 -out compiledBasic.asm
%assembler% main.asm

The path to sjasmplus must be entered in the first line.

Now start the compiler with

 compile bandname.tap basicname -o -s

First, the file compiledBasic.asm is created, then the assembler is called with main.asm, which then creates the tape that can be loaded directly into the emulator.

Compiler options

Option Beschreibung
-o Optimierung. Der Optimierer entfernt einige Anweisungen und fasst andere zusammen
-o1 Optimierung. Der ursprüngliche Code bleibt als Kommantar erhalten (für Compiler-Entwickler)
-s Fügt eine Prüfung auf Break nach jeder Anweisung ein. Man kann das Programm wie in BASIC mit Shift Leertaste unterbrechen
-s1 Wie -1 aber die Anweisung wird nur vor GOTO, RETURN, GOSUB und NEXT eingefügt. Kleiner und schneller aber man kann nicht an jeder Stelle unterbrechen
-l Teilt dem ZX Spectrum bei jeder kompilierten Zeile mit, welche BASIC-Zeile es war. Wenn Sie ein Fehler bekommen, etwa weil außerhalb des Bildschirms gezeichnet wurde, sehen Sie die Zeilennummer und Statement-Nummer des Befehls
-out Angabe der Ausgabedatei
-v Zeigt während des Kompilierens den Assemblercode (für Compiler-Entwickler)

Start in DEZOG

Das Verzeichnis enthält alle nötigen Dateien um das Projekt mit DeZog und Visual Studio zu öffnen. Normalerweise kann man das kompilierte Programm nicht in Dezog debuggen, weil der Debugger vor dem Booten des ZX Spectrum startet. Im Code befindet sich eine abgeänderte Startsquenz welche man aktivieren muss. Öffnen Sie dazu main.asm und geben bei DEBUGBASIC eine 1 ein. DEBUG schaltet ein paar weitere Funktionen dazu, z.B. PRINTFPSTACK um den Calculator-Stack auszugeben

DEBUG                       equ 1			; Enables debug mode. Used to test so new functions.
DEBUGBASIC                  equ 1			; Initializes the ZX Spectrum using a copy of the startup, then starts the compiled BASIC program.
											; Rom routines are allowed