This is a C++ based virtual machine for the LC3 assembly language, adapted to work with mcpp the Royal Melbourne Institute of Technology (RMIT) to supplement the COSC2084 (Programming Studio 2) course. The original project by Justin Meiners can be found here. Thank you to Michael Dann for the original adaptation and trap implementations.
This VM supports a few additional TRAPs based on mcpp functionality, including:
CHATto post to Minecraft chatGETPto get player positionSETPto set player positionGETBto get block typeSETBto set block typeGETHto get max height at an x,z coordinate As well as:REGto print out registers to console. By default, it will print asunsigned, but the VM supports flags to print as:-dsigned-xhexadecimal-bbinary
lc3 [-FLAG] <file.obj> where file.obj is a compiled binary. -FLAG is a single letter flag based on the above Additions section.
Designed to install on UNIX-based systems. Run make in the root directory and then sudo make install to make the command globally available.
| TRAP | mcpp function | Description |
|---|---|---|
| CHAT | postToChat(R0) | Outputs a null terminating string starting at the address contained in R0 to the Minecraft chat. |
| GETP | getPlayerPosition() -> R0, R1, R2 | Gets the position of the player. The x, y and z coordinates are output in registers R0, R1 and R2 respectively. |
| SETP | setPlayerPosition(R0, R1, R2) | This function moves the player to the tile (x, y, z) = (R0, R1, R2). |
| GETB | getBlock(R0, R1, R2) -> R3 | This function retrieves the block's ID at tile (x, y, z) = (R0, R1, R2) and returns it to R3. |
| SETB | setBlock(R0, R1, R2, R3) | This function changes the ID of the block at tile (x, y, z) = (R0, R1, R2) to the value stored in R3. |
| GETH | getHeight(R0, R2) -> R1 | This function calculates the y-position of the highest non-air block at (x, z) = (R0, R2) and returns the value to R1. |
| REG | Non-mcpp | Debugging function to print registers to console. See above for alternative print modes. |
Two .asm examples are provided, printing a "Hello World" message in the console and in Minecraft. Run the .obj files to test the code out.