Skip to content
This repository has been archived by the owner on May 13, 2023. It is now read-only.
/ brookshear-vm Public archive

A brookshear virtual machine written in Go

Notifications You must be signed in to change notification settings

ViRb3/brookshear-vm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Brookshear VM

 _                     _        _                            _   ____  ___
| |                   | |      | |                          | | | |  \/  |
| |__  _ __ ___   ___ | | _____| |__   ___  __ _ _ __ ______| | | | .  . |
| '_ \| '__/ _ \ / _ \| |/ / __| '_ \ / _ \/ _` | '__|______| | | | |\/| |
| |_) | | | (_) | (_) |   <\__ \ | | |  __/ (_| | |         \ \_/ / |  | |
|_.__/|_|  \___/ \___/|_|\_\___/_| |_|\___|\__,_|_|          \___/\_|  |_/

A brookshear virtual machine with support for step-by-step emulation, compilation, and decompilation.

Features

  • Run assembly code or binary bytecode
  • Various verbosity levels allow detail-rich, step-by-step debugging
  • Compile assembly instructions to bytecode in a binary file
  • Decompile bytecode from a binary file to assembly instructions
  • Extra instruction (opcode 0xD) for relative (offset) branch

Download

Check Releases

Help

  • For general help run with argument -h or --help
  • For help on the extra instructions run the command extendedHelp

Relative branch if equal

Examples:

Bytecode | Instruction  | Comment
-----------------------------------------------------------------------
D104     | jmpeq +4, r1 | ; branch forward by 4 bytes (2 instructions)
D312     | jmpeq -2, r3 | ; branch backward by 2 bytes (1 instruction)

It accepts a single nibble as offset, and can be either positive (+4) or negative (-2). When compiling, the instruction is encoded as follows:

D - opcode                  D
R - destination register  [0-F]
O - branch direction      [0-1] : 0 for +/forward, 1 for -/backward
X - offset                [0-F]