Pmars Redcode 94
Pmars Redcode 94
Pmars Redcode 94
Simulator: pMARS
Version: 0.8.0
Standard: ICWS'94 draft (extended)
Language elements not currently in the draft are labeled with *, those
added in this version of pMARS are labeled with +.
________________________________________
Opcodes:
________________________________________
Pseudo opcodes:
________________________________________
Modifiers:
# immediate
$ direct
@ indirect using B-field
< predecrement indirect using B-field
> postincrement indirect using B-field
* (*) indirect using A-field
{ (*) predecrement indirect using A-field
} (*) postincrement indirect using A-field
________________________________________
Directives:
________________________________________
Predefined variables (*):
________________________________________
Expression operators:
Arithmetic:
+ addition or unary plus
- subtraction or unary minus
/ division
% modulo (remainder of division)
Comparison (*):
== equality
!= inequality
< less than
> greater than
<= less than or equal
>= greater than or equal
Logical (*):
&& and
|| or
! unary negation
Assignment (*):
= (to register variables a..z)
Comparison and logical operators return 1 for true and 0 for false.
Parentheses can be used to override this precedence order:
1) ! - + (unary)
2) * / %
3) - + (binary)
4) == != < > <= >=
5) &&
6) ||
7) =
________________________________________
Redcode grammar:
num :: [0-9] ;
number :: num number | num ;
alpha :: [a-zA-Z] | "_" ;
alphanum :: alpha | num ;
alphanums :: alphanum alphanums | e ;
this_string :: (^\n)* ;
comment :: ";" this_string "\n" | e ;
Note:
----
1. Normal statements are statements in the following form:
opcode [address mode] operand [, [address mode] operand] [comment]
More details about the grammar are given in the '88 or '94 proposal.
Case sensitivity
----------------
Opcode and pseudo-opcode names are case insensitive; labels are case
sensitive.
Label declaration
-----------------
Labels are declared in three ways:
o Using EQU. When a label name that first appears (has not been declared)
is declared with EQU, all subsequent occurences of that label name
will be replaced by the strings following the EQU.
The following equates label THIS with "num + 1". THIS equ num + 1.
If the string substituting the label contains other labels, those labels
are also replaced by their substituting string. Recursive reference of
labels are flagged as error.
More than one statement can be declared as a label name. To achieve this,
declare a blank label with EQU following the statement that declares
as part of equation of a named EQU label. Thus, the declaration of the
following:
core_clear equ spl 0
equ mov 2, <-1
equ jmp -1
causes three statements are declared as strings of label core_clear.
This declaration:
base
index for 3
mov base, base + index - 1
rof
translates into:
0000 mov 0, 0
0001 mov 0, 1
0002 mov 0, 2
FOR 5
imp mov imp, imp + 5
ROF
N FOR 5
imp&N mov imp&N, imp&N + 1
ROF
prime01 equ 2
prime02 equ 3
prime03 equ 5
prime04 equ 7
prime05 equ 11
N FOR 5
dat prime&N
ROF
If labels that are not stringized are declared inside FOR/ROF statements,
the result is duplicating declaration. Although in the future it might be
allowed, it is well-advised that such labels are to be declared outside of
the FOR/ROF block.
If FOR statements are declared as strings of a label name using EQU such as:
THIS EQU N FOR 3
EQU mov 0, 3
EQU ROF
The expansion of such is feasible providing that both the FOR and ROF are
present in the same label name.
THIS
mov 0, 3
THAT
or