Skip to content

Commit

Permalink
Format code blocks as redcode!
Browse files Browse the repository at this point in the history
  • Loading branch information
gareththegeek committed Jul 2, 2018
1 parent 6f69dea commit 9b21907
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
14 changes: 7 additions & 7 deletions docs/redcode/addressing_modes.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Operands with the immediate (`#`) addressing mode are always evaluated as an add

For example, the follow example works just like the classic `imp` despite having a non-zero `A` operand. This can also make the imp more resilient as it will continue to function perfectly even if the `A` number is modified.

```
```redcode
mov.i #123, $1
```

Expand All @@ -33,7 +33,7 @@ The direct (`$`) addressing mode provides a relative address from the executing

This is used in the classic `imp`.

```
```redcode
mov.i $0, $1
```

Expand All @@ -49,7 +49,7 @@ Note the intermediate instruction's address is resolved relative to this interme

Let's look at an example.

```
```redcode
mov.i *1, $2
dat 2, 0 ; <- 2 is used as a pointer
dat 0, 0 ; <- this instruction will be overwritten
Expand Down Expand Up @@ -82,14 +82,14 @@ After this it executes `mov 2, @2` to copy the `dat` bomb to the address pointed

The A Pre-decrement Indirect (`{`) addressing mode works in the same way as the [A Indirect](`*`) addressing mode detailed above with the addition that it **first** decrements the `A` number **before** using it as a pointer.

```
```redcode
mov.i {1, $1
dat $0, $0
```

The above example will first decrement the `A` number of the `dat` instruction before using the `dat` instruction's `A` number as a pointer.

```
```redcode
mov.i {1, $1
dat $-1, $0
```
Expand All @@ -100,7 +100,7 @@ After decrementing, the `A` number of the `dat` instruction will be `-1` and the

The A Post-increment Indirect (`}`) addressing mode works in the same way as the [A Indirect](`*`) addressing mode detailed above with the addition that it increments the `A` number **after** using it as a pointer.

```
```redcode
mov.i }1, $1
dat $0, $0
```
Expand All @@ -109,7 +109,7 @@ The above example will first use the `A` number of the `dat` instruction as a po

After this has happened, the `dat` instruction's `A` number will be incremented to `1`.

```
```redcode
mov.i }1, $1
dat $1, $0
```
Expand Down
8 changes: 4 additions & 4 deletions docs/redcode/execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Understanding how instructions are evaluated and executed is vitally important t

Consider the following redcode:

```
```redcode
0000: mov.i >0, $0
0001: dat.f $0, $0
```
Expand All @@ -75,7 +75,7 @@ When imaging how this first instruction will execute, your reasoning might be:

Naively, you might therefore expect the core to look like this after the first instruction is executed:

```
```redcode
0000: mov.i >0, $1
0001: mov.i >0, $1
```
Expand All @@ -96,7 +96,7 @@ Next, during the [decode](#decode) stage, the `A` operand will be evaluated. The

Following this the post-increment is applied to the `B` operand so the instruction in core looks like this:

```
```redcode
0000: mov.i >0, $1
0001: dat.f $0, $0
```
Expand All @@ -113,7 +113,7 @@ Now the instruction in the `Instruction Register` is executed. It copies the ins

The resulting core looks like this:

```
```redcode
0000: mov.i >0, $1
0001: mov.i >0, $0
```
Expand Down
4 changes: 2 additions & 2 deletions docs/redcode/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ Redcode resembles assembly language, with each instruction being composed of an

For example

```
```redcode
mov 0, 1
```

Here the [opcode](opcodes) is `mov` and the [operands](operands) are `0` and `1`.

In order to load your warrior into the game, the recode must be processed by a [Parser](parser). The Parsed output of the above instruction looks like this:

```
```redcode
MOV.I $0, $1
```

Expand Down
12 changes: 6 additions & 6 deletions docs/redcode/opcodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ Note that termination of the warrior's process happens after the [operand](opera

For example if a warrior were to execute the first instruction of the following code block

```
```redcode
DAT.F 1, <1 ; <--this instruction is executed
DAT.F 1, 1
```

The second instruction's B operand would still be decremented, giving:

```
```redcode
DAT.F 1, <1
DAT.F 1, 0 ; <--this instruction was modified
```
Expand Down Expand Up @@ -157,7 +157,7 @@ We can also see that [.f](modifiers#f), [.x](modifiers#x) and [.i](modifiers#i)

Note that when comparing both A and B operands with zero, the jump will **not** be taken if **either** operand is non-zero.

```
```redcode
dat 0, 1 ; <- won't jump if compared with jmz.f
dat 1, 0 ; <- won't jump if compared with jmz.f
dat 1, 1 ; <- won't jump if compared with jmz.f
Expand All @@ -172,7 +172,7 @@ The `jmn` instruction works in the same way as the [jmz](opcodes#jmz-jump-if-zer

Note that when comparing both A and B operands with zero, the jump will **not** be taken if **either** operand is zero.

```
```redcode
dat 0, 1 ; <- won't jump if compared with jmn.f
dat 1, 0 ; <- won't jump if compared with jmn.f
dat 1, 1 ; <- will jump if compared with jmn.f
Expand All @@ -187,7 +187,7 @@ The `djn` instruction works in a similar way to the [jmn](opcodes#jmn-jump-if-no

Unlike the `jmn` intruction, the `djn` instruction **will** perform the jump if **either** operand is zero when using the [.f](modifiers#f), [.x](modifiers#x) and [.i](modifiers#i) modifiers.

```
```redcode
dat 0, 1 ; <- will jump if compared with djn.f
dat 1, 0 ; <- will jump if compared with djn.f
dat 1, 1 ; <- will jump if compared with djn.f
Expand Down Expand Up @@ -244,7 +244,7 @@ The newly created process is added to the process queue **after** the currently

Consider the following example:

```
```redcode
a: spl c
b: jmp 0
c: jmp 0
Expand Down
2 changes: 1 addition & 1 deletion docs/redcode/operands.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Each redcode instruction contains two operands. An operand is composed of an [addressing mode](addressing_modes) and a number. The first operand is known as the `A` operand and the second as the `B` operand.

```
```redcode
mov.i $1, #2
```
In the above example, the A operand is `$1` and the B operand is `#2`.
Expand Down

0 comments on commit 9b21907

Please sign in to comment.