Corewar: Suggestions for New Instructions ----------------------------------------- "The tendency of advanced programmers to try to add complicated instructions to the REDCODE instruction set must be thwarted." - The Core Wars Standard (21 May 1986) Since A. K. Dewdney first introduced Corewar in 1984, a number of additional instructions have been suggested. Collected here are 140 of these ideas. The current Corewar standard (CWS'94) defines 18 instructions. Imagine playing Corewar if all of the below had been implemented! ACT activate sleeping processes (works with SLP) BLK sleep the executing process until p-space location A is non-zero BNC negate increment added to instruction pointer (same as FLP and INV) BRK break-point opcode (not a pseudo-opcode!) CCO copy opcode and addressing modes (same as MOP and OVL) CLK cloak instruction A. appears as DAT 0,0 until after it is next executed CLP reset all p-space locations to 0 CLT skip if A < B (same as SLT) CMN skip if A <> B (same as CNE, JNE, SKN and SNE) CNE skip if A <> B (same as CMN, JNE, SKN and SNE) CON DAT equivalent which MOV can't replace, instead use OVL or ZER CPB skip if b-field of A = b-field of B CPW skip if A = B (same as CMP, JEQ, SEQ) DJZ decrements B. jump to A if B = 0 DMP copy a-field and b-field of A to a-field and b-field of B DRN decrements B. if B <> 0 jump to A, reversing flow of execution EAT subvert process executing at B EGO remove next A processes from process queue ENS subvert process executing ENS ERR when the process executing ERR next executes a DAT, jump to location A EXC exchange the contents of A and B (same as SWP and XCH) EXC execute instruction at B, update B, transfer control to A if no error FLP jump to A if a randomly generated number is below B FLP negate increment added to instruction pointer (same as BNC and INV) FRK split to A, creating a process which shares parent's time slice FRZ suspend execution of executing program's other processes (same as SSP) GET move location A in other core to B GSB push currently executing address onto stack then jump to A (JSR) HLF set A to A/2 HLT terminate executing process (equivalent to DAT) IJN increments B. jump to A if B <> 0 IJZ increments B. jump to A if B = 0 INT process executing INT jumps to A when p-space loc B becomes non-zero INV negate increment added to instruction pointer (same as BNC and FLP) JEQ skip if A = B (same as CMP, CPW, SEQ) JLC jump to A if less than B cycles until a tie is declared JLC jump to A if opponent has less than B processes JMC jump to A if process count > B JMG jump to A if B > 0 (equivalent to JMN?) JMT process executing JMT jumps to A after executing for another B cycles JMX jump to A if location B has been executed JNE skip if A <> B (same as CMN, CNE, SKN and SNE) JNL jump to A if location B is not in a process queue JNP jump to A if no process is scheduled to execute at B JNZ jump to A if B <> 0 (same as JMN) JOB warrior must execute JOB instruction at least every N cycles JOI the current process is suspended until a child process terminates JOT jump to location A in other core JSI jump to A and set instruction pointer increment to B JSR push currently executing address onto stack then jump to A (GSB) JST jump to A and set the a-field of B to point to the location after JST JWN jump to A if B was last modified by program executing JWN LDS input A from stream LRR store the result from the last round in A, 0 = loss, 1 = tie, 2 = win LST exchange opcodes A and B on the internal opcode list MAX if A > B then copy A to B MIN set A to CORESIZE-A (same as NEG) MIN if A < B then copy A to B MON move A to location B if location B contains non-zero A & B fields MOP copy opcode and addressing modes (same as CCO and OVL) MOT move A to location B in other core (same as PUT) MOZ move A to location B if location B contains zero A & B fields MSR sets location B to the process count of program A MSS Mars system call (similar to SYS) MTD replace opcodes at A and B with opcode below on internal opcode list MTS replace opcode at A with opcode B places down internal opcode list MVB move b-field of A to b-field of B MVE move A to B and overwrite the MVE instruction with DAT 0,0 MVN move A to B if B <> 0 MVW move A to B (same as MOV) MVZ move A to B if B = 0 NEG set A to CORESIZE-A (same as MIN) OEQ skip if opcodes A and B equal (same as OMP) OMP skip if opcodes A and B equal (same as OEQ) ONE skip if opcodes A and B unequal OVL copy opcode and addressing modes (same as CCO and MOP) PCI set increment added to instruction pointer to A (same as SES and SPI) PCT protect location A, preventing the next attempt to modify it PCT protect location A from modification until after it is next executed PIR generate an interrupt to A when opponent in range POP pop A from stack PRC skip if an active process exists between A and B PRI set priority of process executing PRI to A PSH push A onto stack PUT move A to location B in other core (same as MOT) PWD change password to A if current password is B (used with modified SPL) QCN perform quantum control-not on source A and target B QON perform quantum operation A on qubit B REN if B <> 0 jump to A, reversing flow of execution for this process REQ jump to the previous instruction if A = B RET pop location from stack, and jump to location + A REV jump to A, reversing flow of execution for this process REZ if B = 0 jump to A, reversing flow of execution for this process RLS release suspended processes RND store a random number between 0 and A-1 to B RPT if B <> 0, return to this instruction after executing next instruction RST reset the internal opcode list RTI return from interrupt SCR scramble opcode, a-field and b-field of location A, as defined by B SCC skip and clear qubit A if qubit A is clear SCS skip and set qubit A if qubit A is clear SES set increment added to instruction pointer to A (same as PCI and SPI) SGE skip if A >= B SGT skip if A > B SKB marker for SKP SKE skip if b-field of A = b-field of B (same as CPB) SKN skip if A <> B (same as CMN, CNE, JNE and SNE) SKP if A = B move instruction pointer to next SKB in core SKR skip if location A has been executed within the last B cycles SLC skip if opponent has less than A processes SLE skip if A <= B SLP sleep the executing process for A cycles SLP sleep the executing process until ACT is executed at location A SLT (modified) skip if less than A cycles until a tie is declared SPC split to A, creating a process with maximum descendant count of B SPD split to A, new process begins execution after a delay of B cycles SPI set increment added to instruction pointer to A (same as PCI and SES) SPI split to A, new process placed before the current process in queue SPL (modified) split to A if B is equal the the current password SPM split A processes to location B SPN split to A if B <> 0 SPR split to A, spawned process has opposite flow of execution to parent SPT split to A, thread created is unable to create further processes (THD) SPW jump to A, when process terminates, resume execution after SPW SPZ split to A if B = 0 SRG store relative address A as an absolute address in register B SSP suspend execution of executing program's other processes (same as FRZ) SSZ set A to size of stack STR store A to register B STS output A to stream SWP exchange the contents of A and B (same as EXC and XCH) SYS system call (similar to MSS) THD split to A, thread created is unable to create further processes (SPT) TIM process executing TIM terminates after executing for another B cycles TRM terminate executing process and re-allocate it's CPU-slice WCH watch location B and generate an interrupt to A when modified WOP copy value from b-field of A to opcode field of B WRP split to A, new process begins execution B cycles ago XCH exchange the contents of A and B (same as EXC and SWP) ZER place a DAT A at location B