https://github.com/nzeemin/vilnius-basic-compiler
  
  
    Writing cross compiler from Vilnius BASIC into MACRO11. WIP π§ 
    https://github.com/nzeemin/vilnius-basic-compiler
  
basic basic-compiler basic-programming-language compiler retrocomputing soviet-computer
        Last synced: 7 months ago 
        JSON representation
    
Writing cross compiler from Vilnius BASIC into MACRO11. WIP π§
- Host: GitHub
 - URL: https://github.com/nzeemin/vilnius-basic-compiler
 - Owner: nzeemin
 - License: lgpl-3.0
 - Created: 2023-04-12T16:45:45.000Z (over 2 years ago)
 - Default Branch: main
 - Last Pushed: 2024-08-11T10:33:50.000Z (about 1 year ago)
 - Last Synced: 2025-03-26T02:51:08.352Z (7 months ago)
 - Topics: basic, basic-compiler, basic-programming-language, compiler, retrocomputing, soviet-computer
 - Language: C++
 - Homepage:
 - Size: 381 KB
 - Stars: 11
 - Watchers: 5
 - Forks: 0
 - Open Issues: 0
 - 
            Metadata Files:
            
- Readme: README.md
 - License: LICENSE
 
 
Awesome Lists containing this project
README
          # vilnius-basic-compiler
[](https://www.gnu.org/licenses/lgpl-3.0)
[](https://app.codacy.com/gh/nzeemin/vilnius-basic-compiler/dashboard)
[](https://www.codefactor.io/repository/github/nzeemin/vilnius-basic-compiler)
## Vilnius BASIC Compiler
**BASIC Vilnius** is an implementation of the BASIC programming language for Soviet machines with PDP-11 architecture: DVK, BK, UKNC, Nemiga.
This BASIC is a semi-compiler: it converts the program text into a so-called **threaded code**,
which executes faster than regular interpretation.
The aim of this project is to develop a full-fledged cross-compiler from the BASIC Vilnius language to MACRO assembly code.
In other words, the compiler runs on a PC (Windows, Linux, Mac) and generates a text file with the `.MAC` extension.
Then, under the **RT-11** operating system, the `.MAC` file is compiled using the standard RT-11 MACRO assembler,
resulting in an object file with the `.OBJ` extension. The object file is then linked with other object modules using the LINK program,
including the language's runtime, and optionally, custom assembly procedures.
As a result, an executable file with the `.SAV` extension is produced, which can be executed under the RT-11
on the target machine.
Current state of the project: **prototype**
## ΠΠΎΠΌΠΏΠΈΠ»ΡΡΠΎΡ ΠΠ΅ΠΉΡΠΈΠΊ ΠΠΈΠ»ΡΠ½ΡΡ
**ΠΠ΅ΠΉΡΠΈΠΊ ΠΠΈΠ»ΡΠ½ΡΡ** β ΡΡΠΎ ΡΠ΅Π°Π»ΠΈΠ·Π°ΡΠΈΡ ΡΠ·ΡΠΊΠ° BASIC Π΄Π»Ρ ΡΠΎΠ²Π΅ΡΡΠΊΠΈΡ
 ΠΌΠ°ΡΠΈΠ½ Ρ Π°ΡΡ
ΠΈΡΠ΅ΠΊΡΡΡΠΎΠΉ PDP-11: ΠΠΠ, ΠΠ, Π£ΠΠΠ¦, ΠΠ΅ΠΌΠΈΠ³Π°.
ΠΡΠΎΡ ΠΠ΅ΠΉΡΠΈΠΊ ΡΠ²Π»ΡΠ΅ΡΡΡ ΠΏΠΎΠ»Ρ-ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΎΡΠΎΠΌ: ΠΎΠ½ ΠΏΡΠ΅ΠΎΠ±ΡΠ°Π·ΡΠ΅Ρ ΡΠ΅ΠΊΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ Π² ΡΠ°ΠΊ Π½Π°Π·ΡΠ²Π°Π΅ΠΌΡΠΉ **ΡΠΈΡΡΠΉ ΠΊΠΎΠ΄**,
ΠΊΠΎΡΠΎΡΡΠΉ Π²ΡΠΏΠΎΠ»Π½ΡΠ΅ΡΡΡ Π±ΡΡΡΡΠ΅Π΅, ΡΠ΅ΠΌ ΠΏΡΠΈ ΠΎΠ±ΡΡΠ½ΠΎΠΉ ΠΈΠ½ΡΠ΅ΡΠΏΡΠ΅ΡΠ°ΡΠΈΠΈ.
ΠΠ°Π½Π½ΡΠΉ ΠΏΡΠΎΠ΅ΠΊΡ ΡΡΠ°Π²ΠΈΡ ΡΠ΅Π»ΡΡ Π½Π°ΠΏΠΈΡΠ°Π½ΠΈΠ΅ ΠΏΠΎΠ»Π½ΠΎΡΠ΅Π½Π½ΠΎΠ³ΠΎ ΠΊΡΠΎΡΡ-ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΎΡΠ° Ρ ΡΠ·ΡΠΊΠ° ΠΠ΅ΠΉΡΠΈΠΊ ΠΠΈΠ»ΡΠ½ΡΡ Π² ΠΊΠΎΠ΄ Π΄Π»Ρ Π°ΡΡΠ΅ΠΌΠ±Π»Π΅ΡΠ° MACRO.
Π’ΠΎ Π΅ΡΡΡ, ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΎΡ ΡΠ°Π±ΠΎΡΠ°Π΅Ρ Π½Π° PC (Windows, Linux, Mac), Π³Π΅Π½Π΅ΡΠΈΡΡΠ΅Ρ ΡΠ΅ΠΊΡΡΠΎΠ²ΡΠΉ ΡΠ°ΠΉΠ» Ρ ΡΠ°ΡΡΠΈΡΠ΅Π½ΠΈΠ΅ΠΌ `.MAC`.
ΠΠ°Π»Π΅Π΅, ΠΏΠΎΠ΄ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΎΠ½Π½ΠΎΠΉ ΡΠΈΡΡΠ΅ΠΌΠΎΠΉ **RT-11**, `.MAC` ΡΠ°ΠΉΠ» ΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΡΠ΅ΡΡΡ ΡΡΠ°Π½Π΄Π°ΡΡΠ½ΡΠΌ Π΄Π»Ρ RT-11 Π°ΡΡΠ΅ΠΌΠ±Π»Π΅ΡΠΎΠΌ MACRO,
ΠΏΠΎΠ»ΡΡΠ°Π΅ΡΡΡ ΠΎΠ±ΡΠ΅ΠΊΡΠ½ΡΠΉ ΡΠ°ΠΉΠ» Ρ ΡΠ°ΡΡΠΈΡΠ΅Π½ΠΈΠ΅ΠΌ `.OBJ`. ΠΠ°ΡΠ΅ΠΌ ΠΎΠ±ΡΠ΅ΠΊΡΠ½ΡΠΉ ΡΠ°ΠΉΠ» Π»ΠΈΠ½ΠΊΡΠ΅ΡΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΎΠΉ LINK Ρ Π΄ΡΡΠ³ΠΈΠΌΠΈ
ΠΎΠ±ΡΠ΅ΠΊΡΠ½ΡΠΌΠΈ ΠΌΠΎΠ΄ΡΠ»ΡΠΌΠΈ β ΡΡΠΎ runtime ΡΠ·ΡΠΊΠ°, ΠΏΠ»ΡΡ, Π΅ΡΠ»ΠΈ Π½ΡΠΆΠ½ΠΎ, ΡΠ²ΠΎΠΈ ΡΠΎΠ±ΡΡΠ²Π΅Π½Π½ΡΠ΅ ΠΏΡΠΎΡΠ΅Π΄ΡΡΡ Π½Π° Π°ΡΡΠ΅ΠΌΠ±Π»Π΅ΡΠ΅.
Π ΡΠ΅Π·ΡΠ»ΡΡΠ°ΡΠ΅, Π½Π° Π²ΡΡ
ΠΎΠ΄Π΅ ΠΏΠΎΠ»ΡΡΠ°Π΅ΡΡΡ ΠΈΡΠΏΠΎΠ»Π½ΠΈΠΌΡΠΉ ΡΠ°ΠΉΠ» Ρ ΡΠ°ΡΡΠΈΡΠ΅Π½ΠΈΠ΅ΠΌ `.SAV`, ΠΊΠΎΡΠΎΡΡΠΉ ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ ΠΈΡΠΏΠΎΠ»Π½Π΅Π½ Π² ΡΡΠ΅Π΄Π΅ RT-11
Π½Π° ΡΠ΅Π»Π΅Π²ΠΎΠΉ ΠΌΠ°ΡΠΈΠ½Π΅.
Π’Π΅ΠΊΡΡΠ΅Π΅ ΡΠΎΡΡΠΎΡΠ½ΠΈΠ΅ ΠΏΡΠΎΠ΅ΠΊΡΠ°: **ΠΏΡΠΎΡΠΎΡΠΈΠΏ**
### ΠΡΠΈΠΌΠ΅Ρ
ΠΡΡ
ΠΎΠ΄Π½ΡΠΉ ΡΠ°ΠΉΠ» Π½Π° ΠΠ΅ΠΉΡΠΈΠΊΠ΅:
```basic
10 A%=23.42
20 PRINT A%
```
Π Π΅Π·ΡΠ»ΡΡΠ°Ρ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ:
```assembler
	.MCALL	.EXIT
START:
; 10 A%=23.42
L10:
	MOV	#23., VARA.I	; assignment
; 20 PRINT A%
L20:
	MOV	VARIA, R0
	CALL	WRINT
	CALL	WRCRLF
L65536:
	.EXIT
; VARIABLES
VARIA:	.WORD	0	; A%
	.END	START
```
### ΠΠ΅ΠΊΠΎΡΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΠΈΠΌΡΠ½ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ
ΠΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΠ΅ Π² ΠΠ΅ΠΉΡΠΈΠΊ ΠΠΈΠ»ΡΠ½ΡΡ ΠΎΠΏΠΎΠ·Π½Π°ΡΡΡΡ ΠΏΠΎ ΠΏΠ΅ΡΠ²ΡΠΌ Π΄Π²ΡΠΌ ΡΠΈΠΌΠ²ΠΎΠ»Π°ΠΌ ΠΈΠΌΠ΅Π½ΠΈ + ΡΠΈΠΏ.
ΠΠΌΠ΅Π½Π° ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ
 Π² ΠΊΠΎΠ΄Π΅ Π΄Π»Ρ MACRO ΠΈΠΌΠ΅ΡΡ Π²ΠΈΠ΄: `VAR` + ΡΠΈΠΏ (`I`,`N`,`S`) + ΠΏΠ΅ΡΠ²ΡΠ΅ Π΄Π²Π° ΡΠΈΠΌΠ²ΠΎΠ»Π° ΠΈΠΌΠ΅Π½ΠΈ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΠΎΠΉ.
ΠΡΠΈΠΌΠ΅ΡΡ Π΄Π΅ΠΊΠΎΡΠΈΡΠΎΠ²Π°Π½ΠΈΡ:
```
A%                    VARIA
B ΠΈΠ»ΠΈ B!              VARNB
C$                    VARSC
AA ΠΈΠ»ΠΈ AAA ΠΈΠ»ΠΈ AA1    VARNAA
```