MacTierra logo

The Instruction set

This is the instruction set implemented in version 1.8.3 of MacTierra. The 4 registers are referred to as ax - dx, and instructions are either explained by C-style code snippets, or a more lengthy description.

Those instructions with a '*' in the 'Flag' column will set the flag if they fail. Conditions for failure are given. Otherwise, the flag is cleared.

InstructionsHex codeFlagAction
nop_0 0x00 No operation. Used as in templates.
nop_1 0x01 No operation. Used as in templates.
or1 0x02 cx ^= 1
sh1 0x03cx <<= 1
zero 0x04cx = 0
if_cz 0x05if (cx == 0) {execute the next instruction} else {skip it}
sub_ab0x06cx = ax - bx
sub_ac0x07ax = ax - cx
inc_a 0x08ax ++
inc_b 0x09 bx ++
dec_c 0x0A cx --
inc_c 0x0B cx ++
push_ax0x0C stack[sp] = ax, sp = (sp + 1) mod stackSize
push_bx 0x0D stack[sp] = bx, sp = (sp + 1) mod stackSize
push_cx 0x0E stack[sp] = cx, sp = (sp + 1) mod stackSize
push_dx 0x0F stack[sp] = dx, sp = (sp + 1) mod stackSize
pop_ax 0x10 sp = (sp + stackSize - 1) mod stackSize, ax = stack[sp]
pop_bx 0x11 sp = (sp + stackSize - 1) mod stackSize, bx = stack[sp]
pop_cx 0x12 sp = (sp + stackSize - 1) mod stackSize, cx = stack[sp]
pop_dx 0x13 sp = (sp + stackSize - 1) mod stackSize, dx = stack[sp]
jmp 0x14* Search for the complement to the template following the jmp instruction, looking both forward and back to a max distance of 1024 instructions. If found, set the instruction pointer to the instruction following the found template complement. On failure, set the flag and set the instruction pointer to the instruction following the the template.
jumpb 0x15* Search for the complement to the template following the jmp instruction, looking backwards to a max distance of 1024 instructions. If found, set the instruction pointer to the instruction following the found template complement. On failure, set the flag and set the instruction pointer to the instruction following the the template.
call 0x16* Search for the complement to the template following the jmp instruction, looking both ways to a max distance of 1024 instructions. If found, push the current instruction pointer onto the stack, and set the instruction pointer to the instruction following the found template complement. If no template follows the call instruction, On failure, set the flag and set the instruction pointer to the instruction following the the template.
ret 0x17Decrement the stack pointer. Set the instruction pointer to the address from the stack.
mov_cd 0x18dx = cx
mov_ab 0x19bx = ax
mov_iab 0x1A* Copy the instruction in the soup pointed to by the address in the bx register to the address in the ax register. Fails and sets the flag if the address pointed to by ax is not free space, the current creature, or its current offspring (if any).
adr 0x1B* Search both ways, up to distance of 1024 instructions, for the complement to the template following the adr instruction. If found, put the address of the instruction following the found template into ax, and set cx to the length of the template. On failure, set the flag.
adrb 0x1C* Search backwards, up to distance of 1024 instructions, for the complement to the template following the adb instruction. If found, put the address of the instruction following the found template into ax, and set cx to the length of the template. On failure, set the flag.
adrf 0x1D* Search forwards, up to distance of 1024 instructions, for the complement to the template following the adb instruction. If found, put the address of the instruction following the found template into ax, and set cx to the length of the template. On failure, set the flag.
mal 0x1E* Allocate a daughter cell, of the size given by the dx register, and a location goverened by the ax register and the current offspring allocation scheme. On allocation, the address of the allocated cell is returned in the ax register of the parent.
Fails if this creature already has an 'embryo' (offspring for which the div instruction has not yet been executed, if the size in dx is less than the current minimum size (12 instructions) or more than some multiple of the parent's size (3 times). Also fails if space could not be allocated for the offspring.
divide 0x1F* Separate from the current offspring, which is then given autonomy, and entered into slicer and reaper queues. Instruction pointer of the daughter is set to its first instruction. Offspring registers are either zeroed, or copied from the parent (depending on the settings).
Fails if there is not current offspring, or if less than some proportion (currently 0.5) of the daughter has been filled by copy (mov_iab) instructions from the parent.

For information about how to compile your own creatures, see the page on assembling.

Table of contents Installation Running Soup settings Preferences Statistics
Assembling Interface How it works c.f. Tierra Bugs and features Legal stuff