Skip to content

AlexaBecker/simple-virtual-machine-C

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

An extension of the (split-stack branch) simple VM I did that codyebberson converted to C. I added CALL/RET and make VM a struct. Added more tests.

Branches:

  • master. This is a straight C port of the split-stack branch from Java.
  • computed-goto. A version of the exec() method that uses computed gotos to directly jump from instruction to instruction like a threaded interpreter, thus, avoiding a while loop and switch for the decode part of the fetch-decode-execute cycle. Instead of:
while ( more opcodes ) {
  switch ( code[ip] ) {
  ...

we use goto *dispatch[code[ip]] to instantly jump to the code that interprets the next opcode via an appropriate label within the exec method.

Build and run:

$ cc -o vm src/*.c
$ vm

About

Same as simple-virtual-machine but in C

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 97.7%
  • CMake 2.3%