Skip to content

Commit

Permalink
tic-tac-toe update
Browse files Browse the repository at this point in the history
  • Loading branch information
Dovgalyuk committed Aug 2, 2023
1 parent ad4a620 commit 9c36c84
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 1 deletion.
50 changes: 50 additions & 0 deletions docs/cheatsheet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
## Registers

Order of registers: ABCDMSLP

## Peripheral addresses

* 0x80 - 0x8f: two 8-bit input switches (first for even addresses and second for odd)
* 0x90 - 0x9f: teletype (input - keyboard, output - printing)

## Instructions set

* 000: A / empty - jump always
* 001: Z - jump if zero (Z=1)
* 010: NS - jump if positive (S=0)
* 011: C - jump if carry (C=1)
* 100: NC - jump if not carry (C=0)
* 101: S - jump if negative (S=1)
* 110: NZ - jump if not zero (Z=0)

```
00010--- -------- HALT
00000--- -------- NOP
00101ddd -----aaa LOAD d, a
00100ddd iiiiiiii LOAD G, Imm
00111sss -----aaa STORE G, P
00110sss iiiiiiii STORE G, Imm
1ccc1111 aaaaaaaa CALL Cond, Imm
1ccc0111 aaaaaaaa JMP Cond, Imm
1ccc0ddd iiiiiiii MOVI Cond, Gd, Imm8
00011ddd -sss---- MOV Gd, Gs
01bbbddd ixxxryyy OP Gd, Gs1, Op2
01111ddd -sssruu0 OP Gd, Gs
```

### Binary ops

0. ADC
1. ADD
2. SBC
3. SUB
4. AND
5. OR
6. XOR

### Unary ops

0. NOT - bitwise not
1. SHR - shift to right
2. ROR - rotate to right
3. RCR - rotate through CY to right
58 changes: 57 additions & 1 deletion docs/games.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ Numbering of the cells:
m = move_left(m);
p = input();
check_win(m, p);
win(m - 1);
win(m - 1); // & 7?
}
m = move_left(p);
p = input();
Expand All @@ -285,6 +285,62 @@ Numbering of the cells:
}
```

```
main:
MOVI A, 8 00: 10000000 00001000
STORE A, 0x90 01: 00110000 10010000
HALT 02: 00010000 00000000
LOAD A, 0x90 03: 00100000 10010000
STORE A, 0x90 04: 00110000 10010000
CALL move_left 05: 10001111 00011100
MOV C, A 06: 00011010 00000000
CALL load 07: 10001111 00101010
CALL check_win 08: 10001111 00100000
TST C, 1 09: 01100000 10100001
JMP NZ, tie 0a: 11100111 00010010
MOV A, C 0b: 00011000 00100000
CALL move_left 0c: 10001111 00011100
MOV C, A 0d: 00011010 00000000
CALL load 0e: 10001111 00101010
CALL check_win 0f: 10001111 00100000
SUB A, C, 1 10: 01011000 10101001
JMP win 11: 10000111 00100101
tie:
MOV A, B 12: 00011000 00010000
CALL move_left 13: 10001111 00011100
CALL load 14: 10001111 00101010
CALL check_win 15: 10001111 00100000
MOV A, B 16: 00011000 00010000
CALL move_left 17: 10001111 00011100
CALL load 18: 10001111 00101010
CALL check_win 19: 10001111 00100000
MOVI A, 9 1a: 10000000 00001001
STORE A, 0x90
HALT 1b: 00010000 00000000
move_left:
SUB A, A, 1 1c: 01011000 10001001
AND A, A, 7 1d: 01100000 10001111
STORE A, 0x90 1e: 00110000 10010000
RET 1f: 00011111 01100000
check_win:
ADD A, A, 4 20: 01001000 10001100
AND A, A, 7 21: 01100000 10001111
CMP A, B 22: 01011000 00000001
JMP NZ, win 23: 11100111 00100101
RET 24: 00011111 01100000
win:
STORE A, 0x90 25: 00110000 10010000
MOVI A, 9 26: 10000000 00001001
STORE A, 0x90 27: 00110000 10010000
STORE A, 0x90 28: 00110000 10010000
HALT 29: 00010000 00000000
load:
HALT 2a: 00010000 00000000
LOAD B, 0x90 2b: 00100001 10010000
STORE B, 0x90 2c: 00110001 10010000
RET 2d: 00011111 01100000
```

### Lonely queen

Trying to move chess queen into the lower left corner by
Expand Down
2 changes: 2 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

[Construction](construction.md)

[Programmer's cheat sheet](cheatsheet.md)

[Sample programs](programs.md)

[Comparison of modern relay computers](computers.md)
Expand Down

0 comments on commit 9c36c84

Please sign in to comment.