Skip to content

mayankshouche/simplevm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 

Repository files navigation

simplevm

This is a simple toy VM built in C. Idea and starting point are from https://en.wikibooks.org/wiki/Creating_a_Virtual_Machine/Register_VM_in_C.

How to use:

gcc -o main main.cpp

./main filename.bin

Ensure the bin file is assembled properly to assure proper operation.

Assembly/Machine Language Reference:

Opcodes:

  1. halt: 0x000

    halts operation of the system.

  2. loadi: 0x1 <4-bit register number> <8-bit immediate>

    loads the 8-bit immediate value into the register specified by the second-most-signficant-byte. registers are numbered 0-3.

  3. add: 0x2 <4-bit dest. register> <4-bit source register 1> <4-bit source register 2>

    adds the values in the two source registers and places the result in the destination register.

  4. addi: 0x3 <4-bit dest. register> <4-bit source register> <4-bit immediate>

    adds the immediate value to the source register and stores the result in the destination register.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages