Minecoprocessors Mod 1.16.5, — Guide
Programming & Assembly Language
The mod uses a custom assembly language. Each line of code represents one instruction.
Registers
Registers are internal memory slots used to store and manipulate data.
| Register | Type | Description |
|---|---|---|
| A, B, C, D | General Purpose | Used for variables and arithmetic. |
| ports | Configuration | A bitmask used to set ports as Input (0) or Output (1). |
| PF, PB, PL, PR, PT, PD | I/O | Front, Back, Left, Right, Top, and Down ports. |
Port Bitmask (ports)
The ports register uses a 4-bit or 6-bit binary value to define port direction. The bit order is typically:
[Bottom][Top][Right][Left][Back][Front]
Example: mov ports, 0010b sets the Back port as an output/active port for monitoring.
Instruction Set
| Instruction | Syntax | Description |
|---|---|---|
| MOV | mov dest, src |
Copies the value from source to destination. |
| ADD | add dest, src |
Adds source to destination. |
| SUB | sub dest, src |
Subtracts source from destination. |
| MUL / DIV | mul dest, src |
Multiplies or divides destination by source. |
| CMP | cmp val1, val2 |
Compares two values and sets internal flags. |
| INC / DEC | inc reg / dec reg |
Increases or decreases a register by 1. |
| JMP | jmp label |
Jumps to a specific label in the code. |
| JZ / JNZ | jz label |
Jump if Zero / Jump if Not Zero. |
| CALL / RET | call label |
Calls a subroutine and returns. |
| NOP | nop |
No Operation (waits for 1 tick). |
| SLEEP | sleep |
Pauses execution until an external signal is received. |
Mechanics & Logic
Timing
The mod operates on the principle of 1 Instruction = 1 Redstone Tick. This makes it easy to calculate delays. For example, a loop that runs 10 times with 2 instructions inside will take exactly 20 redstone ticks (2 seconds) to complete.
Number Formats
The assembler supports four number formats for flexibility:
* Decimal: 10
* Hexadecimal: 0x0A
* Octal: 0o12
* Binary: 1010b
Flags
The processor tracks the state of the last operation using flags: * Z (Zero): Set if the result was 0. * C (Carry): Set if an arithmetic operation overflowed. * F (Fault): Set if an error occurred (e.g., division by zero). * S (Sleep): Set when the processor is in a low-power sleep state.
Example: Pulse Extender
This program waits for a signal on the back port and then powers the front port for approximately 80 redstone ticks.
mov ports, 0010b; Configure ports
start:
cmp pb, 1; Check if Back Port is powered
jnz start; If not, loop back to start
mov pf, 1; Turn on Front Port
mov c, 40; Set counter to 40
loop:
dec c; Decrease counter
jnz loop; Loop until counter is 0
mov pf, 0; Turn off Front Port
jmp start; Return to waiting state
Explanation: The delay is longer than 40 ticks because the dec and jnz instructions each take 1 tick per iteration, totaling 2 ticks per loop cycle.