Skip to content
/ bm Public
forked from catull/bm

Simple Virtual Machine with its own Bytecode and Assembly language.

License

Notifications You must be signed in to change notification settings

Geilolo/bm

 
 

Repository files navigation

BM

birch

Simple Virtual Machine with its own Bytecode and Assembly language.

Build

We are using nobuild build system which requires a bootstrapping step with any relatively standard complaint C compiler.

On Linux/MacOS/FreeBSD/literally any OS on the planet Earth except Windows with MSVC:

$ cc -o nobuild nobuild.c
$ ./nobuild help

If you still want to use MSVC on Windows run vcvarsall.bat and from within the development environment of MSVC:

> cl.exe nobuild.c
> nobuild.exe help

Building the libbm Library

$ ./nobuild lib

The static library will be put into ./build/library/

Building the Toolchain

$ ./nobuild tools

The binaries of the toolchain will be placed in ./build/toolchain/.

Building and Running Examples

$ ./nobuild examples

The examples will be placed in ./build/examples/.

To run the examples use basm executable from the toolchain:

$ ./build/toolchain/bme ./build/examples/hello.bm
$ ./build/toolchain/bme ./build/examples/fib.bm
$ ./build/toolchain/bme ./build/examples/e.bm
$ ./build/toolchain/bme ./build/examples/pi.bm

Adding More Examples

nobuild examples automatically builds all the ./examples/*.basm files. So if you want to add a new example to the build just add *.basm file to ./examples/.

Running and Recoding Tests

TBD

Toolchain

basm

Assembly language for the Virtual Machine. For examples see ./examples/ folder.

bme

BM emulator. Used to run programs generated by basm.

bdb

BM debuger. Used to step debug programs generated by basm.

debasm

Disassembler for the binary files generated by basm

bmr

BM recorder. Used to record the output of binary files generated by basm and comparing those output to the expected ones. We use this tool for Integration Testing.

basm2nasm

An experimental tool that translates BM files generated by basm to an assembly files in NASM dialect for x86_64 Linux.

expr2dot

Accepts BASM TTE as a command line argument and dumps its AST in dot format that you can render later with graphviz later.

$ ./build/toolchain/expr2dot "f(a) + g(b) + 69 > 420" | dot -Tsvg > ast.svg
$ iexplore.exe ast.svg

Editor Support

Emacs

Emacs mode available in ./tools/basm-mode.el. Until the language stabilized and we upload the mode on MELPA you need to install this mode manually.

Add the following lines to your .emacs file:

(add-to-list 'load-path "/path/to/basm-mode/")
(require 'basm-mode)

Vim

Copy ./tools/basm.vim in .vim/syntax/basm.vim. Add the following line to your .vimrc file:

autocmd BufRead,BufNewFile *.basm set filetype=basm

About

Simple Virtual Machine with its own Bytecode and Assembly language.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 97.3%
  • Emacs Lisp 1.2%
  • Other 1.5%