# wlvm Virtual machine with associated language written in Rust ![Build & Test](https://github.com/Wafelack/wlvm/workflows/Build%20&%20Test/badge.svg) ## Installation `cargo install wlvm` (https://crates.io/crates/wlvm) ## Build ``` git clone https://github.com/wafelack/wlvm cd wlvm/ cargo build cargo test ``` ## Usage ### Run repl `wlvm` ### Run program `wlvm run $program` ### Dump program's memory and registers `wlvm dump $program` ## Details
Virtual Machine datasheet ## Registers There are 6 multi purposes registers, marked from a to f. There are 4 special registers : - sp : The stack pointer - ip : The instruction pointer - st : The stack top value - eq : The result of the last test performed ## Instruction Set ### Stack instructions - psh \ : Pushes an integer onto the stack - pop : Pops the stack ### Arithmetic operations - add \ \ : Adds the content of register_b to register_a - sub \ \ : Substracts the content of register_b to register_a - mul \ \ : Multiplies the content of register_b to register_a - div \ \ : Divides the content of register_a by register_b ### Memory operations - mov \ \ : Copies content of register_b in register_a - jmp \ : Jump to \ if Eq register is true ### Boole algebra operations - tee \ \ : Test if register_a == register_b - tne \ \ : Test if register_a != register_b - tll \ \ : Test if register_a < register_b - tmm \ \ : Test if register_a > register_b - tel \ \ : Test if register_a <= register_b - tem \ \ : Test if register_a >= register_b ### Other - dmp : Dumps the stack and the registers - drg \ : Prints the content of the specified register - prt \ : Prints the character corresponding to register value - hlt : Stops the program