just one more BASIC compiler
- supports classic BASIC language dialect with various extensions
- command-line compiler built for Windows x86, Windows x64, Linux i386, Linux amd64, Linux armhf
- produces a kind of intermediate code that can be compiled into STM8 assembler code
- static and dynamic memory allocation (built-in simple dynamic memory manager)
- some essential peripherals support (GPIO, timer, UART, SPI)
- interrupts handling
- includes STM8 assembler
- licensed under MIT license
Supported STM8 microcontrollers list:
- STM8S003F3P6
- STM8S103F3P6
- STM8S105K4T6
- STM8S105K6T6
- STRING
- INT (16-bit integer)
- WORD (16-bit unsigned integer)
- BYTE (8-bit unsigned integer)
- LONG (32-bit signed integer)
- BREAK
- CONTINUE
- DATA
- DEF
- DIM
- ELSE
- ELSEIF ... THEN
- ERASE
- FOR ... TO ... [STEP]
- GET
- GOTO
- GOSUB
- IF ... THEN
- INPUT
- IOCTL
- LET
- NEXT
- OPTION BASE | EXPLICIT | NOCHECK
- PUT
- READ
- REM
- RESTORE
- RETURN
- TRANSFER
- WHILE ... WEND
- optional line numbers
- optional LET statement
- case-insensitive statement, variable and function names
- one-, two- and three-dimensional arrays
- relational operators can be used with strings
- automatic numeric to string conversion
- functions: ABS, INT, SGN, LEN, ASC, CHR$, STR$, VAL, IIF, IIF$, CBYTE, CINT, CWRD, CLNG
- more functions: MID$, INSTR, LTRIM$, RTRIM$, LEFT$, RIGHT$, LSET$, RSET$, SET$, UCASE$, LCASE$
Use CMake 3.1 tools to build b1c BASIC to intermediate code compiler, c1stm8 intermediate code compiler for STM8 and a1stm8 STM8 assembler. Use one of the next C/C++ toolchains: MinGW-W64 (x86 and x64) under Windows, MSVC 2019 (x86 and x64) under Windows, gcc/g++ (x86, x64 and armhf) under Linux. Other compilers/toolchains are probably compatible too.
First download source files copy to your local computer from GitHub
Commands to get the source files:
git clone https://github.com/basic-1/basic-1c
cd basic-1c
git submodule update --init
To build the compiler under Windows go to build
subdirectories of every project b1c
, c1stmp
and a1stm8
and run corresponding batch file depending on your compiler and target platform, e.g: b1c_win_x64_mingw_rel.bat
, c1stm8_win_x64_mingw_rel.bat
, a1stm8_lnx_x64_gcc_rel.sh
, etc.
Important note: The batch files mentioned above run corresponding <platform_toolchain_name>_env
scripts from ./env
directory if they exist to set compiler-specific environment variables(PATH, INCLUDE, LIB, etc.). So the file names are: win_x86_mingw_env.bat
, win_x64_mingw_env.bat
, lnx_x64_gcc_env.sh
, etc. Create them if necessary before building the project.
BASIC1 compiler includes three executable modules: b1c
- compiler translating BASIC programs to platform independent intermediate code, c1stm8
- intermediate code compiler, producing STM8 assembly language code and a1stm8
assembler. By default b1c
calls intermediate code compiler automatically and c1stm8
compiler calls a1stm8
assembler. Run the executable modules without arguments to see available options.
Samples:
b1c -d -s -m STM8S103F3 samples/blink.bsc
- compile blink.bsc
program for STM8S103F3P6 MCU
b1c.exe -d -s -mu -m STM8S105K4 -o "E:\Temp\\" samples\heap.bsc
- compile heap.bsc
program for STM8S105K4T6 MCU, put output files into "E:\Temp\" directory
b1c
- BASIC1 compiler, takes BASIC program source code and produces intermediate code (files with .b1c extension)
c1stm8
- intermediate code compiler, produces STM8 assembly language code
a1stm8
- STM8 assembler
BASIC1 language reference
BASIC1 language limitations
IOCTL statement commands
BASIC1 program examples
STM8 assembler reference
Assembler program examples
Change log
Download compiler distribution packages for Windows and Linux