diff --git a/README.md b/README.md index 7232252..1d1171e 100644 --- a/README.md +++ b/README.md @@ -15,11 +15,12 @@ uVM is simply an experiment in developing a working virtual machine with it's ow ## Usage -`uvm [-v] [-h] -f .uc` +`uvm [-v] [-h] [-d ] -f .uc` * `-v`: Enable verbose logging mode * `-h`: Show usage * `-f .uc`: Load the uvm bytecode file for processing +* `-d `: The maximum stack depth in words ## Testing @@ -53,6 +54,7 @@ uVM possesses the standard issue instruction set you might expect in a simple VM | 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 | +| halt | 8 | Halts the VM | As I learn more about VM development this instruction set will likely become much more robust. @@ -61,6 +63,8 @@ As I learn more about VM development this instruction set will likely become muc - [] Tests for good paths for all instructions - [] Tests for uncompilable code +- [] Tests for maximum stack size reached +- [] Tests to make sure the maximum stack depth is always greater than 0 - [] Logging out current stack position, etc when verbose mode is enabled - [] If verbose mode isn't enabled it shows the ascii loading while processing - [] Come up with a way to allow the user to echo to the screen diff --git a/include/cpu.h b/include/cpu.h new file mode 100644 index 0000000..e601ccb --- /dev/null +++ b/include/cpu.h @@ -0,0 +1,36 @@ +// 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 . +// + +#ifndef CPU_H_ +#define CPU_H_ + +class CPU { + private: + int sp; // Stack pointer + int ip; // Instruction pointer + int fp; // Frame pointer + + // Stack goes here + + public: + CPU(); // The CPU should be initialized with the code and stuff + fetch(); + decode(); + execute(); + run(); // Runs the loaded code...this should have something in args +}; + +#endif // CPU_H_ diff --git a/include/opcodes.h b/include/opcodes.h index 788d6e5..16be48f 100644 --- a/include/opcodes.h +++ b/include/opcodes.h @@ -13,7 +13,6 @@ // You should have received a copy of the GNU General Public License // along with UVM. If not, see . // -// #ifndef OPCODES_H_ diff --git a/include/decoder.h b/src/cpu.cc similarity index 90% rename from include/decoder.h rename to src/cpu.cc index bcc6a0a..7ff3f4b 100644 --- a/include/decoder.h +++ b/src/cpu.cc @@ -13,13 +13,3 @@ // You should have received a copy of the GNU General Public License // along with UVM. If not, see . // -// - - -#ifndef DECODER_H_ -#define DECODER_H_ - - - - -#endif // DECODER_H_