commit
					80b801753e
				
				 6 changed files with 185 additions and 0 deletions
			
			
		@ -0,0 +1,43 @@
					 | 
				
			||||
# Prerequisites | 
				
			||||
*.d | 
				
			||||
 | 
				
			||||
# Compiled Object files | 
				
			||||
*.slo | 
				
			||||
*.lo | 
				
			||||
*.o | 
				
			||||
*.obj | 
				
			||||
 | 
				
			||||
# Precompiled Headers | 
				
			||||
*.gch | 
				
			||||
*.pch | 
				
			||||
 | 
				
			||||
# Compiled Dynamic libraries | 
				
			||||
*.so | 
				
			||||
*.dylib | 
				
			||||
*.dll | 
				
			||||
 | 
				
			||||
# Fortran module files | 
				
			||||
*.mod | 
				
			||||
*.smod | 
				
			||||
 | 
				
			||||
# Compiled Static libraries | 
				
			||||
*.lai | 
				
			||||
*.la | 
				
			||||
*.a | 
				
			||||
*.lib | 
				
			||||
 | 
				
			||||
# Executables | 
				
			||||
*.exe | 
				
			||||
*.out | 
				
			||||
*.app | 
				
			||||
 | 
				
			||||
# CMake | 
				
			||||
CMakeCache.txt | 
				
			||||
CMakeFiles | 
				
			||||
CMakeScripts | 
				
			||||
Testing | 
				
			||||
Makefile | 
				
			||||
cmake_install.cmake | 
				
			||||
install_manifest.txt | 
				
			||||
compile_commands.json | 
				
			||||
CTestTestfile.cmake | 
				
			||||
@ -0,0 +1,25 @@
					 | 
				
			||||
cmake_minimum_required (VERSION 3.8) | 
				
			||||
 | 
				
			||||
set (CMAKE_CXX_STANDARD 11) | 
				
			||||
 | 
				
			||||
set (CMAKE_C_COMPILER "clang") | 
				
			||||
set (CMAKE_CXX_COMPILER "clang++") | 
				
			||||
set (CMAKE_C_COMPILER_ID "Clang") | 
				
			||||
set (CMAKE_CXX_COMPILER_ID "Clang") | 
				
			||||
set (CMAKE_VERBOSE_MAKEFILE ON) | 
				
			||||
 | 
				
			||||
project (uvm) | 
				
			||||
 | 
				
			||||
set (uvm_VERSION_MAJOR 0) | 
				
			||||
set (uvm_VERSION_MINOR 1) | 
				
			||||
set (uvm_VERSION_PATCH 0) | 
				
			||||
 | 
				
			||||
set (EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) | 
				
			||||
 | 
				
			||||
file(GLOB uvm "include/*") | 
				
			||||
file(GLOB uvm "src/*") | 
				
			||||
 | 
				
			||||
add_executable(${PROJECT_NAME} ${uvm_SRC} ${uvm_INCLUDE}) | 
				
			||||
target_link_libraries( | 
				
			||||
  ${PROJECT_NAME} | 
				
			||||
) | 
				
			||||
@ -0,0 +1,43 @@
					 | 
				
			||||
# uVM - Micro Virtual Machine | 
				
			||||
 | 
				
			||||
uVM is simply an experiment ins developing a working virtual machine with it's own bytecode. | 
				
			||||
 | 
				
			||||
## Requirements | 
				
			||||
 | 
				
			||||
* CMake version 3.8 or higher | 
				
			||||
* Clang and Clang++ | 
				
			||||
 | 
				
			||||
## Building | 
				
			||||
 | 
				
			||||
1. `git clone` the repository | 
				
			||||
2. `cmake .` | 
				
			||||
3. `make` | 
				
			||||
 | 
				
			||||
## Architecture | 
				
			||||
 | 
				
			||||
uVM is a _stack machine_. That is, it gets all of it's arguments from the stack, and returns the result | 
				
			||||
of the computation back to the stack when it's done. | 
				
			||||
 | 
				
			||||
There are some exceptions to this. In particular the current version of uvm supports a single variable, | 
				
			||||
called `0`, that can be written to using `xpop0` where x is the datatype of the thing getting taken off | 
				
			||||
the stack. | 
				
			||||
 | 
				
			||||
Additionally `0` can be placed on the top of the stack using `xpush0`. | 
				
			||||
 | 
				
			||||
## uVM Instruction Set | 
				
			||||
 | 
				
			||||
uVM possesses the standard issue instruction set you might expect in a simple VM: | 
				
			||||
 | 
				
			||||
| Instruction  | Opcode | Action                                                                         | | 
				
			||||
| ------------ | ------ | ------------------------------------------------------------------------------ | | 
				
			||||
| ipush _X_    | 0      | Pushes _integer_ X onto the stack                                              | | 
				
			||||
| ipush0       | 1      | Pushes the _integer_ in `0` onto the stack                                     | | 
				
			||||
| ipop0        | 2      | Pops the top _integer_ of the stack off and into variable 0                    | | 
				
			||||
| icmp         | 3      | Compares the top two items on the stack together and returns a boolean result  | | 
				
			||||
| iadd         | 4      | Adds the top two _integer_ arguments of the stack together                     | | 
				
			||||
| isub         | 5      | Subtracts the top two _integer_ arguments of the stack from each other         | | 
				
			||||
| jmp _LABEL_  | 6      | Unconditional jump to _label_                                                  | | 
				
			||||
| jc _LABEL_   | 7      | Jump if the top of the stack is a 1                                            | | 
				
			||||
 | 
				
			||||
 | 
				
			||||
As I learn more about VM development this instruction set will likely become much more robust. | 
				
			||||
@ -0,0 +1,25 @@
					 | 
				
			||||
//   This file is part of UVM.
 | 
				
			||||
//
 | 
				
			||||
//   UVM is free software: you can redistribute it and/or modify
 | 
				
			||||
//   it under the terms of the GNU General Public License as published by
 | 
				
			||||
//   the Free Software Foundation, either version 3 of the License, or
 | 
				
			||||
//   (at your option) any later version.
 | 
				
			||||
//
 | 
				
			||||
//   UVM is distributed in the hope that it will be useful,
 | 
				
			||||
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||
//   GNU General Public License for more details.
 | 
				
			||||
//
 | 
				
			||||
//   You should have received a copy of the GNU General Public License
 | 
				
			||||
//   along with UVM.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||
//
 | 
				
			||||
//
 | 
				
			||||
 | 
				
			||||
 | 
				
			||||
#ifndef DECODER_H_ | 
				
			||||
#define DECODER_H_ | 
				
			||||
 | 
				
			||||
 | 
				
			||||
 | 
				
			||||
 | 
				
			||||
#endif  // DECODER_H_
 | 
				
			||||
@ -0,0 +1,33 @@
					 | 
				
			||||
//   This file is part of UVM.
 | 
				
			||||
//
 | 
				
			||||
//   UVM is free software: you can redistribute it and/or modify
 | 
				
			||||
//   it under the terms of the GNU General Public License as published by
 | 
				
			||||
//   the Free Software Foundation, either version 3 of the License, or
 | 
				
			||||
//   (at your option) any later version.
 | 
				
			||||
//
 | 
				
			||||
//   UVM is distributed in the hope that it will be useful,
 | 
				
			||||
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||
//   GNU General Public License for more details.
 | 
				
			||||
//
 | 
				
			||||
//   You should have received a copy of the GNU General Public License
 | 
				
			||||
//   along with UVM.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||
//
 | 
				
			||||
//
 | 
				
			||||
 | 
				
			||||
 | 
				
			||||
#ifndef OPCODES_H_ | 
				
			||||
#define OPCODES_H_ | 
				
			||||
 | 
				
			||||
// Instructions
 | 
				
			||||
 | 
				
			||||
#define IPUSH  0x0 | 
				
			||||
#define IPUSH0 0x1 | 
				
			||||
#define IPOP0  0x2 | 
				
			||||
#define CMP    0x3 | 
				
			||||
#define IADD   0x4 | 
				
			||||
#define ISUB   0x5 | 
				
			||||
#define JMP    0x6 | 
				
			||||
#define JC     0x7 | 
				
			||||
 | 
				
			||||
#endif  // OPCODES_H_
 | 
				
			||||
@ -0,0 +1,16 @@
					 | 
				
			||||
//   This file is part of UVM.
 | 
				
			||||
//
 | 
				
			||||
//   UVM is free software: you can redistribute it and/or modify
 | 
				
			||||
//   it under the terms of the GNU General Public License as published by
 | 
				
			||||
//   the Free Software Foundation, either version 3 of the License, or
 | 
				
			||||
//   (at your option) any later version.
 | 
				
			||||
//
 | 
				
			||||
//   UVM is distributed in the hope that it will be useful,
 | 
				
			||||
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||
//   GNU General Public License for more details.
 | 
				
			||||
//
 | 
				
			||||
//   You should have received a copy of the GNU General Public License
 | 
				
			||||
//   along with UVM.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||
//
 | 
				
			||||
//
 | 
				
			||||
					Loading…
					
					
				
		Reference in new issue