Edit Warrior


This window allows the user to edit, compile, and save warrior source code. Source code may be typed in or read from text files. The window is resizable. Also, each of the four panels may be resized individually by dragging the splitter bars that separate them.




·         The Open button lets the user browse for a text file containing warrior source code.

·         The Save button saves the source code into a text file.

·         The Compile button compiles the source code into MARS code, and shows the results:

o        Object Code shows the binary compiled code (numbers shown in hexadecimal)

o        Load File shows the compiled code with readable opcodes and address modes (numbers shown in decimal). An asterisk (*) marks the starting instruction.

o        Errors displays any compilation errors

·         Once a warrior has been compiled, the load file may be saved to a text file. Note: Operands in load files are absolute numbers, and are independent of the core size at the time of compilation. When warriors are loaded into Core, operands are adjusted to fit the core size.

·         The OK button returns the source code to the main window. Note that source code does not need to be compiled before clicking OK.


This is the name that will be used to label this warrior. If the source code contains a line beginning with ;name, the name is taken from that line; otherwise, the name of the source file is used. This default name may be changed.


Source Code Conventions

·         Numbers are decimal integers.

·         Lines beginning with a semicolon are comment lines, and are ignored. Completely blank lines are also ignored. Some specific comment lines are recognized by the compiler (all are optional):

o        ;redcode – Marks the beginning of source code. All prior lines are discarded.

o        ;name <name> – The name of the warrior. This is used as a default identifier when warriors are loaded.

o        ;author <author’s name> - The name of the person who created the warrior.

o        ;assert <expression> – The expression is evaluated; if the result is false (0), a warning message is displayed, but the warrior is not prevented from compiling or battling.

o        ;debug, ;trace, ;break, and ;condition are directives that govern breakpoints.

·         Lines containing valid instructions use the following sequence of elements:

[label] opcode[.modifier] [a-mode]a-operand, [b-mode]b-operand [;comment]

o        Square brackets denote optional elements. A comma must separate the two operands. For some opcodes, the comma and b-operand are optional.

o        Elements may be separated by whitespace (spaces or tabs).

o        Labels are case sensitive, but opcodes and modifiers are not.

o        A label is any combination of letters, numbers, and underscores, beginning with a letter or underscore. When a label is used in an operand, it represents the number of instructions between the current instruction and the instruction that begins with that label. For instance, the two instructions

Dest     DAT      #0,                    #Source

Source  MOV     $Source,           $Dest

                        are equivalent to

DAT      #0,                    #1

MOV     $0,                    $-1

o        A label may appear by itself on a line, in which case it refers to the next line.

o        An opcode is a three-letter code representing the action to be performed by the instruction. The set of allowable opcodes depends on which language standard (ICWS’88 or ICWS’94) is selected on the Settings dialog.

§         ’88 opcodes: DAT, MOV, ADD, SUB, JMP, JMZ, JMN, DJN, CMP, SPL, SLT

§         ’94 opcodes: ’88 opcodes, plus MUL, DIV, MOD, SEQ, SNE, NOP, LDP, STP

o        Pseudo-opcodes are compiler directives. They do not compile into source code, nor do they add to the distance between instructions during label evaluation.

§         Pseudo opcodes: EQU, END, ORG, FOR, ROF, PIN

o        Modifiers are optional characters that specify which field (A or B) is the source and which is the target of an instruction

§         ’88 standards: No modifiers are allowed. All instructions have default behaviors.

§         ’94 standards: Modifiers may be .A, .B, .AB, .BA, .F, .X, or .I

o        A mode character indicates the address mode to be used by the operand that follows it.

§         ’88 modes: # (immediate), $ or not specified (direct), @ (indirect using B-field), or < (pre-decrement indirect using B-field).

§         ’94 modes: ’88 modes, plus > (post-increment indirect using B-field), * (indirect using A-field), { (pre-decrement indirect using A-field), or } (post-increment indirect using A-field).

o        An operand is any expression involving integers, labels, register variables (a-z), parentheses, arithmetic operators (+, -, *, /, %), comparison operators (==, !=, <, >, <=, =>), and logical operators (&&, ||, !). It evaluates to an integer (the ‘/’ operator uses integer division). Comparison and logical operators return 1 for true and 0 for false. Operands may contain whitespace. The following predefined variables may be used to refer to the current parameters:

§         CORESIZE


§         MAXCYCLES

§         MAXLENGTH


§         ROUNDS

§         PSPACESIZE

§         WARRIORS (the number of warriors participating in each battle)

§         CURLINE (the current line in the compiled warrior, starting with 0)

§         RANDOM (a random integer in the range 0..CORESIZE-1)

§         VERSION (the version number of CoreWin, times 100)

Previous   Next   Contents   CoreWin Home