Skip to content

Commit

Permalink
Added enumerations
Browse files Browse the repository at this point in the history
  • Loading branch information
gareththegeek committed Sep 11, 2018
1 parent 796be36 commit b29d87a
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 29 deletions.
118 changes: 118 additions & 0 deletions docs/developer/enumerations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Enumerations

The following enumerations are used by the corewar library's API.

## Token Categories

Semantic meaning of tokens produced by the [Parser](./parser).

|Value|Meaning|
|---|---|
|0|Label|
|1|Opcode|
|2|Preprocessor|
|3|Modifier|
|4|Mode|
|5|Number|
|6|Comma|
|7|Maths|
|8|EOL|
|9|Comment|
|10|Unknown|

## Message Type

Message types which can be returned by the [Parser](./parser)

|Value|Meaning|
|---|---|
|0|Error|
|1|Warning|
|2|Info|

## Standard

Standard refers to the Corewar [Standard](../redcode/#standards) used.

|Value|Meaning|
|---|---|
|0|ICWS86|
|1|ICWS88|
|2|ICWS94draft|

## Opcode

Opcode refers to the [opcode](../redcode/opcodes) the instruction represents.

|Value|Meaning|
|---|---|
|0|DAT|
|1|MOV|
|2|ADD|
|3|SUB|
|4|MUL|
|5|DIV|
|6|MOD|
|7|JMP|
|8|JMZ|
|9|JMN|
|10|DJN|
|11|CMP|
|12|SEQ|
|13|SNE|
|14|SLT|
|15|SPL|
|16|NOP|

## Modifier

The [Modifier](../redcode/modifiers) for the instruction's operand.

|Value|Meaning|
|---|---|
|0|A|
|1|B|
|2|AB|
|3|BA|
|4|F|
|5|X|
|6|I|

## Mode

The [Addressing Mode](../redcode/addressing_modes) of the instruction's operand.

|Value|Meaning|
|---|---|
|0|Immediate (#)|
|1|Direct ($)|
|2|A Indirect (*)|
|3|B Indirect (@)|
|4|A Pre Decrement ({)|
|5|B Pre Decrement (<)|
|6|A Post Increment (})|
|7|B Post Increment (>)|

## Enumeration

|Value|Meaning|
|---|---|
|||

## Enumeration

|Value|Meaning|
|---|---|
|||

## Enumeration

|Value|Meaning|
|---|---|
|||

## Enumeration

|Value|Meaning|
|---|---|
|||
28 changes: 2 additions & 26 deletions docs/developer/parser.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,7 @@ The `IParseResult` has the following structure:
}
```

#### Token Categories

The token category number is an enumerated type with the following possible values:

|Value|Meaning|
|---|---|
|0|Label|
|1|Opcode|
|2|Preprocessor|
|3|Modifier|
|4|Mode|
|5|Number|
|6|Comma|
|7|Maths|
|8|EOL|
|9|Comment|
|10|Unknown|

The message type number is an enumerated type with the following possible values:

|Value|Meaning|
|---|---|
|0|Error|
|1|Warning|
|2|Info|
[Token Category](./enumerations#token-category) and [Message Type](./enumerations#message-type) are [enumerations](./enumerations).

### serialise(tokens: IToken[]): string

Expand All @@ -82,4 +58,4 @@ The `serialise` function takes a single parameter which is an array of tokens wi

The lexeme contains the original text which produced the token.

A list of valid values for category can be found [here](#token-categories).
A list of valid values for category can be found [here](./enumerations#token-categories).
43 changes: 40 additions & 3 deletions docs/developer/simulator.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,47 @@ The Simulator API allows warriors parsed using the [Parser](./parser) to be load

### initialiseSimulator(options: IOptions, parseResults: IParseResult[], messageProvider: IPublishProvider)

Setup the simulator for a specific standard and parseResult (parsed redcode).
IParseResults are produced as output from the Parser module.
Setup the simulator for specific [options](#options) and [parseResult](./parser#parseredcode-string-iparseresult) (parsed redcode).
`IParseResults` are produced as output from the [Parser](./parser) module.
Additional, data can be associated with a warrior when it is loaded into core by adding a data property to the parseResults given to the initialise function.
Allows a pubsub provider to be specified to receive Events (see below).
A pubsub provider can be specified to receive [Messages](#messages).

#### Options

The following options object can be provided to `initialiseSimulator`. See [Match Settings](../corewar/match_settings) for more info.

All attributes are optional and will be defaulted as described.

```
{
coresize?: number, // default 8000
maximumCycles?: number, // default 80000
initialInstruction?: { // default DAT.F $0, $0
address: number,
opcode: number,
modifier: number,
aOperand: {
mode: ModeType,
address: number
},
bOperand: {
mode: ModeType,
address: number
}
},
instructionLimit?: number, // default 100
maxTasks?: number, // default 8000
minSeparation?: number, // default 100
standard?: number, // default ICWS94draft
readDistance?: number,
writeDistance?: number
}
```

[Standard](./enumerations#standard), [Opcode](./enumerations#opcode) and [Modifier](./enumerations#modifier) are [enumerations](./enumerations)

**`readDistance` and `writeDistance` are not implemented within the current version of corewar.io **

### step(steps?: number): boolean

Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ pages:
- Parser: developer/parser.md
- Simulator: developer/simulator.md
- Matches: developer/matches.md
- Enumerations: developer/enumerations.md
theme: readthedocs

0 comments on commit b29d87a

Please sign in to comment.