Compatibility
Minecraft: Java Edition
Platforms
Supported environments
Links
Tags
Creators
Details
Asm Craft
The mod is made by sally4953.
This mod is licensed under the MIT open-source agreement. You can view its source code through the GitHub repository: https://github.com/sally4953/asmcraft
This mod enables you to write programs in assembly language within Minecraft and run them. At present, the mod just support Minecraft Assembly Language. C++ compiler is still in the process of implementing. But I will try my best to complete the C++ compiler.
For making the assembled application executable, I implemented a virtual machine(VM) in Minecraft. It uses a completely different framework. So, let me show you the specific information:
Virtual Machine Information
Registers
There are 7 registers. The first four are used as variables when calling a function. Another register stores the pointer for program execution (pointing to the address in memory, indicating the current executing statement), and there is one for storing the function return value. The last register is the result of the condition judgment, with only two states.
Memories
There are two memories in the VM. One is to store the application's commands. Its size is 1024 bytes. So every application shouldn't be more than 1024 bytes ( but I think no one can write such application ). The other memory is to store runtime data. Its size is also 1024 bytes. I think 1024-byte memory is enough for the most players (or programmers).
Commands
The VM supports only 22 commands at present. The following table will show you the information.
| Name | Comment | Length(byte) |
|---|---|---|
| nop | Do-nothing command. | 1 |
| ret | Function return command. | 1 |
| mov A, B | Assign B to A. | 5 |
| sub A, B | Subtract B from A. | 5 |
| mul A, B | Multiply A by B. | 5 |
| div A, B | Divide A by B. | 5 |
| jmp A | Direct jump to A. | 3 |
| cjp A | Jump to A if the last register is true. | 3 |
| grt A, B | If A is greater than B, the last register is true (otherwise not true). | 5 |
| lst A, B | If A is less than B, the last register is true (otherwise not true). | 5 |
| equ A, B | If A is equal to B, the last register is true (otherwise not true). | 5 |
| cal A | Call function A (A is the address in memory or a label). | 3 |
| ccl A | Call A if the last register is true (A is the address in memory or a label). | 3 |
| and | Set the last register to true if and only if the values in the first and second registers are both true (otherwise false). | 1 |
| or | Set the last register to true if and only if one of the values in the first and second registers is true (otherwise false). | 1 |
| xor | Set the last register to true if and only if the values in the first and second registers are not the same (true or false). | 1 |
| not | Reverse the last register's value. | 1 |
| inc A | Add one to A. | 3 |
| dec A | Subtract one from A. | 3 |
| neg A | Store the opposite number of A in A. | 3 |
| int A | Interrupt, request the virtual machine to call the function with the number A in memory, wait for completion, and the virtual machine will set the value to the register 5. For the information of the supported interruptions, view the following table. | 2 |
Interruptions
The VM supports only 12 interrupt commands. The following table will show you the interruptions.
| Code | Comment |
|---|---|
| 0 | Exit. |
| 1 | Print a integer above the hotbar. |
| 2 | Print a character above the hotbar. |
| 3 | Set the world time to the register 0's value. |
| 4 | Set the register 5's value to the world time. |
| 5 | Take the register 0 as the seed and generate a random number to the register 5. |
| 6 | Set the player's score to the register 0's value. |
| 7 | Set the register 5's value to the player's score. |
| 8 | Set the player's health to the register 0's value. |
| 9 | Set the register 5's value to ten times the player's health. |
| 10 | Set the X, Y, and Z axis positions of the player to 1/10 of the register 0, register 1, and register 2's values respectively. |
| 11 | If the register 0's value is 0, set the register 5 to ten times the player's X-axis position; if it is 1, set the register 5 to ten times the player's Y-axis position; if it is 2, set the register 5 to ten times the player's Z-axis position; otherwise, R5 remains 0. |
This mod has better support for Chinese. Therefore, if you are not familiar with Chinese, you may need to use a translator.
The above is all the content of this mod. Anyway, enjoy it!


