Skip to content

Commit

Permalink
Separate org and end page
Browse files Browse the repository at this point in the history
  • Loading branch information
gareththegeek committed Jul 4, 2018
1 parent 98481f8 commit 7666e62
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
33 changes: 33 additions & 0 deletions docs/redcode/org.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Org and End Directives

By default, warriors are loaded into core with the first instruction as the starting instruction.

The `org` directive allows a different starting address to be specified. The `org` directive should be written on its own line and followed by an address indicating the start address relative to the first address in the warrior.

By convention, the `org` directive is usually placed at the top of the warrior's code.

```
org 1
dat #4, #0
add.ab -1, -1
```

The above example uses the `org` directive to set the first instruction to the `add` instruction rather than the `dat` instruction.

The `org` directive was introduced in the [ICWS'94](./#standards) standard. Previous standards used the `end` directive instead, which worked in the same way but was placed at the end of the warrior.

```
dat #4, #0
add.ab -1, -1
end 1
```

Note the `end` and `org` directives are semantically equivalent and either can be used.

## Parser Warnings

If both `ORG` or `END` directive is specified, the `ORG` directive will be used to determine the start address.

If multiple `ORG` or `END` directives are detected, the last one will be used (with `ORG` taking precedence over `END`).

Both these situations will generate a parser warning.
34 changes: 0 additions & 34 deletions docs/redcode/parser.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,6 @@ The parser performs the following functions:
* Executes [preprocessor commands](preprocessor)
* Removes white space and [comments](comments)

## Org and End Directives

By default, warriors are loaded into core with the first instruction as the starting instruction.

The `org` directive allows a different starting address to be specified. The `org` directive should be written on its own line and followed by an address indicating the start address relative to the first address in the warrior.

By convention, the `org` directive is usually placed at the top of the warrior's code.

```
org 1
dat #4, #0
add.ab -1, -1
```

The above example uses the `org` directive to set the first instruction to the `add` instruction rather than the `dat` instruction.

The `org` directive was introduced in the [ICWS'94](./#standards) standard. Previous standards used the `end` directive instead, which worked in the same way but was placed at the end of the warrior.

```
dat #4, #0
add.ab -1, -1
end 1
```

Note the `end` and `org` directives are semantically equivalent and either can be used.

## Defaults

All instructions require a [modifier](modifiers) and two [operands](operands) in order to be loaded into the `Simulator`. Each operand must have an [addressing mode](addressing_modes) and a number.
Expand Down Expand Up @@ -68,11 +42,3 @@ Which modifier is inserted as a default is dependant upon the instruction's opco
|`slt`|#|any|`.ab`|
||$@<>{}|any|`.b`|
|`jmp` `jmz` `jmn` `djn` `spl` `nop`|any|any|`.b`|

### ORG (Starting address)

If no `ORG` or `END` directive is specified, the `ORG` directive will be used to determine the start address.

If multiple `ORG` or `END` directives are detected, the last one will be used (with `ORG` taking precedence over `END`).

Both these situations will generate a parser warning.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pages:
- Opcodes: redcode/opcodes.md
- Modifiers: redcode/modifiers.md
- Addressing Modes: redcode/addressing_modes.md
- Org and End: redcode/org.md
- Parser: redcode/parser.md
- Labels: redcode/labels.md
- Preprocessor: redcode/preprocessor.md
Expand Down

0 comments on commit 7666e62

Please sign in to comment.