Giter Site home page Giter Site logo

baby_vm's Introduction

baby_vm

baby_vm is a virtual machine (VM) that implements one-instruction set computer (OISC).

baby_vm is still under construction. The to-dos are listed below:

TO-DO

Features

Execution

  • Add return value address
  • add capability to display return value

Add compiler in racket

  • define bnf of the input language
    • refer to simple math-lan in 311
  • design intermediate languages
  • design compiler

General

  • add Dockerfile and complete the How to run section
  • abstraction for memory address - added decode layer to turn relative index to memory data region address
  • add support for flags
  • implement stack memory support
  • implement heap memory support
  • implement syscall assmebly support
  • keep updating the documentation

Testing

  • supply simple assembly program file for testing
  • Add test suite to test machine functionality
  • convert simple c program to one-line instruction assembly code
    • maybe simple additions
  • test converted assembly code
  • [?] add testing input example to print "hello world" - ? this requires IO capacity?

General information

Inspired by this tutorial for writing your own vm, I got the idea of writing a simple baby vm that only runs one instruction and see how far I can get.

The one instruction that runs on baby_vm is SUBLEQ

    Instruction subleq a, b, c
        Mem[b] = Mem[b] - Mem[a]
        if (Mem[b] ≤ 0)
            goto c

A simple ISA around SUBLEQ was also deigned for baby_vm to interpret the assmebly files.

baby_vm has its own memory and hardware models.

All design deatils are documented in /doc/DOCUMENTATION.md.

This project is for fun and educational purpose, not meant to be useful. :)

How to run

By the time this is publish, I should have dockerize baby_vm. So the following steps should get baby_vm up and running:

  1. make sure docker is installed.
  • docker --version will show if docker is installed.
  1. from the project directory, build docker
  • cd baby_vm/
  • docker build --no-cache -t baby_vm .
  1. run docker
  • docker run -it --tty baby_vm:latest
  1. baby_vm will propmt you to enter the assmebly files that you want to run, there are some example files supplied in baby_vm/examples/, enter the file name with path relative to the project directory. for example:
  • examples/test.txt
  • if you want to run your own assembly file (please refer to doc/DOCUMENTATION.md for ISA), make sure enter the file name with the path relative to the project directory.
  1. watch baby_vm run :)

Anything else?

contributions welcome :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.