Giter Club home page Giter Club logo

alpvm's Introduction

Summary

AlpVM is a simple virtual machine I developed in 2013 just for fun. It wasn't easy to write programs for it in its own machine language. So, I decided to make some high level languages available to it. Now, it is possible to program it in C. To achieve this, I also write an assembler and a linker. For C compiler I used LCC. Assembler, and linker are written in C#. AlpVm is written in C++.

AlpVM

AlpVM has a simple interrupt mechanism and also video, keyboard, and timer devices all of which are controlled by memory mapped I/O. Since it is a simple machine, it has no memory protection support. So the code runs on it can modify itself. Assembler and linker produce executables containing symbols (like an ELF or PE file) so that AlpVM can make relocation to achieve position independent code. Linker also makes relocations when combining object files to produce an executable. Instructions of AlpVM are fixed-sized (16 bytes).

Components

Building

  • AlpVM: Open AlpVM solution and build it with Visual Studio
  • Assembler, Linker, Debugger: Open AlpVM-Assembler solution and build it with Visual Studio
  • LCC: Open Visual Studio x86 Command Promt, cd to lcc path and run build.bat

Building for AlpVM

To run a C code in AlpVM, the code must be built by following these steps:

  • Compile code(s) - run compilec.bat batch file and pass a C file as the argument
  • Assemble - run AlpVM-Assembler.exe with the argument a (assembler) to assemble and create an object file
  • Link - run AlpVM-Assembler.exe with the argument l (linker) to link object files together and create a runnable

Building sample.c

compilec.bat examples\sample.c

This should have created sample.c.asm.

AlpVM-Assembler.exe a sample.o examples\sample.c.asm

This should have created sample.o.

AlpVM-Assembler.exe l sample.alp sample.o

This should have created sample.alp. If it is intended to link multiple object files, they should be passed to the end as arguments. Now, sample.alp can be run in AlpVM.

AlpVM.exe sample.alp

If debug is passed to the end as an argument, AlpVM breaks immediately and waits debugger to connect.

Debugger

AlpVM debugger is a C# Windows Forms application capable of connecting AlpVM via TCP connection. It can read registers and memory of the machine, disassemble the code where execution pointer is and control the machine's state.

Debugger in action

Note that, this is a hobby project so codes here are not expected to be the most efficient.

alpvm's People

Contributors

ozkl avatar

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.