https://github.com/alexrasch/wannabevm
https://github.com/alexrasch/wannabevm
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/alexrasch/wannabevm
- Owner: AlexRasch
- Created: 2023-07-30T13:33:08.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-05T23:02:09.000Z (almost 3 years ago)
- Last Synced: 2025-02-23T14:47:04.856Z (over 1 year ago)
- Language: C#
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WannaBeVM

WannaBeVM is a simple virtual machine (VM) written in C#. It interprets a bytecode representation of basic mathematical operations.
## Usage
To use WannaBeVM, you can call it like this:
```csharp
byte[] bytecode = new byte[]
{
1, 10, // Push 10 onto the stack
1, 5, // Push 5 onto the stack
2, // Add the top two numbers (10 + 5 = 15)
1, 3, // Push 3 onto the stack
4, // Multiply the top two numbers (15 * 3 = 45)
5, // Divide the top two numbers (45 / 3 = 15)
6 // Return the output (15)
};
VirtualMachine vm = new VirtualMachine();
int result = vm.Interpret(bytecode);
Console.WriteLine("Result: " + result); // Output: Result: 15
```