Formatting updates.

This commit is contained in:
Anachronaut
2024-11-20 17:45:23 -05:00
committed by GitHub
parent 3bb42eaba4
commit 4eedc20b04
+57 -56
View File
@@ -4,6 +4,7 @@ SplitBit is a small 8 bit CPU.
It is a Harvard Architecture machine with a separate 64k memory space for its Program and another for its Data. It is a Harvard Architecture machine with a separate 64k memory space for its Program and another for its Data.
It has seven registers: It has seven registers:
- The A and B Registers are each a general purpose 8 bit register. - The A and B Registers are each a general purpose 8 bit register.
- A and B are the operand registers for the ALU. - A and B are the operand registers for the ALU.
- A and B together form a 16-bit circular shift register, AB, in the context of the bit shift instructions, SHL and SHR. - A and B together form a 16-bit circular shift register, AB, in the context of the bit shift instructions, SHL and SHR.
@@ -35,33 +36,33 @@ It has seven registers:
## List of Instructions: ## List of Instructions:
### Arithmetic and Logic Operations: 9 Instructions ### Arithmetic and Logic Operations: 9 Instructions
Hex Code | Mnemonic | Description | Hex Code | Mnemonic | Description |
-- | -- | -- | -- | ---- | -- |
00 | ADD | Adds A, B, and the Carry Flag, the result is stored in Q. | 00 | ADD | Adds A, B, and the Carry Flag, the result is stored in Q. |
01 | SUB | Subtracts B and the Carry Flag from A, the result is stored in Q. | 01 | SUB | Subtracts B and the Carry Flag from A, the result is stored in Q. |
02 | AND | Bitwise and of A and B, the result is stored in Q. | 02 | AND | Bitwise and of A and B, the result is stored in Q. |
03 | OR | Bitwise or of A and B, the result is stored in Q. | 03 | OR | Bitwise or of A and B, the result is stored in Q. |
04 | XOR | Bitwise xor of A and B, the result is stored in Q. | 04 | XOR | Bitwise xor of A and B, the result is stored in Q. |
05 | NOTA | Bitwise inversion of A, the result is stored in Q. | 05 | NOTA | Bitwise inversion of A, the result is stored in Q. |
06 | NOTB | Bitwise inversion of B, the result is stored in Q. | 06 | NOTB | Bitwise inversion of B, the result is stored in Q. |
07 | SHL | A and B form a circular shift register. Rotate this register left. | 07 | SHL | A and B form a circular shift register. Rotate this register left. |
08 | SHR | A and B form a circular shift register. Rotate this register right. | 08 | SHR | A and B form a circular shift register. Rotate this register right. |
### Branch and Subroutine Operations: 7 Instructions ### Branch and Subroutine Operations: 7 Instructions
Hex Code | Mnemonic | Description | Hex Code | Mnemonic | Description |
-- | -- | -- | -- | ---- | -- |
10 | BRI | Branch Immediately. Loads the immediate next two bytes of Program Memory into the Program Counter, first the most significant byte, then the least. | 10 | BRI | Branch Immediately. Loads the immediate next two bytes of Program Memory into the Program Counter, first the most significant byte, then the least. |
11 | BRQ | Branch on Q. If Q is zero, loads the immediate next two bytes of Program Memory into the Program Counter. | 11 | BRQ | Branch on Q. If Q is zero, loads the immediate next two bytes of Program Memory into the Program Counter. |
12 | BRA | Branch on A. If A is zero, loads the immediate next two bytes of Program Memory into the Program Counter. | 12 | BRA | Branch on A. If A is zero, loads the immediate next two bytes of Program Memory into the Program Counter. |
13 | BRB | Branch on B. If B is zero, loads the immediate next two bytes of Program Memory into the Program Counter. | 13 | BRB | Branch on B. If B is zero, loads the immediate next two bytes of Program Memory into the Program Counter. |
14 | BRC | Branch if Carry is set. | 14 | BRC | Branch if Carry is set. |
17 | CALL | Call subroutine. Stores all the registers to the Stack, A, B, and the Program Counter, then performs an immediate branch. | 17 | CALL | Call subroutine. Stores all the registers to the Stack, A, B, and the Program Counter, then performs an immediate branch. |
1F | RET | Restores the saved registers from the Stack, then immediately branches to the Return Address by setting the Program Counter to the next instruction after the last CALL. | 1F | RET | Restores the saved registers from the Stack, then immediately branches to the Return Address by setting the Program Counter to the next instruction after the last CALL. |
### Register Operations: 9 Instructions ### Register Operations: 9 Instructions
| Hex Code | Mnemonic | Description | | Hex Code | Mnemonic | Description |
| -------- | -------- | ------------------- | | -- | ---- | -- |
| 20 | RSTA | Resets A to 0. | | 20 | RSTA | Resets A to 0. |
| 21 | RSTB | Resets B to 0. | | 21 | RSTB | Resets B to 0. |
| 22 | INCA | Adds 1 to A. | | 22 | INCA | Adds 1 to A. |
@@ -73,53 +74,53 @@ Hex Code | Mnemonic | Description
| 28 | CCF | Clears the Carry Flag. | | 28 | CCF | Clears the Carry Flag. |
### Stack Operations: 7 Instructions ### Stack Operations: 7 Instructions
Hex Code | Mnemonic | Description | Hex Code | Mnemonic | Description |
-- | -- | -- | -- | ---- | -- |
30 | PSHQ | Stores Q into Data Memory at the location referenced by the Stack Pointer then decrements the Stack Pointer. | 30 | PSHQ | Stores Q into Data Memory at the location referenced by the Stack Pointer then decrements the Stack Pointer. |
31 | PSHA | Stores A into Data Memory at the location referenced by the Stack Pointer then decrements the Stack Pointer. | 31 | PSHA | Stores A into Data Memory at the location referenced by the Stack Pointer then decrements the Stack Pointer. |
32 | PSHB | Stores B into Data Memory at the location referenced by the Stack Pointer then decrements the Stack Pointer. | 32 | PSHB | Stores B into Data Memory at the location referenced by the Stack Pointer then decrements the Stack Pointer. |
33 | PSHD | Stores the Data Pointer to the stack, with the low byte on top. Increments the Stack Pointer by two. | 33 | PSHD | Stores the Data Pointer to the stack, with the low byte on top. Increments the Stack Pointer by two. |
34 | POPA | Reads the location referenced by the Stack Pointer from Data Memory into A then increments the Stack Pointer. | 34 | POPA | Reads the location referenced by the Stack Pointer from Data Memory into A then increments the Stack Pointer. |
35 | POPB | Reads the location referenced by the Stack Pointer from Data Memory into B then increments the Stack Pointer. | 35 | POPB | Reads the location referenced by the Stack Pointer from Data Memory into B then increments the Stack Pointer. |
36 | POPD | Restores the Data Pointer from the stack, increments the Stack Pointer by two. | 36 | POPD | Restores the Data Pointer from the stack, increments the Stack Pointer by two. |
### Data Operations: 10 Instructions ### Data Operations: 10 Instructions
Hex Code | Mnemonic | Description | Hex Code | Mnemonic | Description |
-- | -- | -- | -- | ---- | -- |
40 | INCD | Increments the Data Pointer. | 40 | INCD | Increments the Data Pointer. |
41 | DECD | Decrements the Data Pointer. | 41 | DECD | Decrements the Data Pointer. |
42 | LDA | Loads the byte referenced from Data Memory by the Data Pointer into A. | 42 | LDA | Loads the byte referenced from Data Memory by the Data Pointer into A. |
43 | LDB | Loads the byte referenced from Data Memory by the Data Pointer into B. | 43 | LDB | Loads the byte referenced from Data Memory by the Data Pointer into B. |
44 | STQ | Stores Q into the byte referenced by the Data Pointer in Data Memory. | 44 | STQ | Stores Q into the byte referenced by the Data Pointer in Data Memory. |
45 | STA | Stores A into the byte referenced by the Data Pointer in Data Memory. | 45 | STA | Stores A into the byte referenced by the Data Pointer in Data Memory. |
46 | STB | Stores B into the byte referenced by the Data Pointer in Data Memory. | 46 | STB | Stores B into the byte referenced by the Data Pointer in Data Memory. |
47 | SETD | Loads the next two bytes of Program Memory into the Data Pointer. | 47 | SETD | Loads the next two bytes of Program Memory into the Data Pointer. |
48 | DPUP | Offset Data Pointer up by the value of the immediate next byte of Program Memory. | 48 | DPUP | Offset Data Pointer up by the value of the immediate next byte of Program Memory. |
49 | DPDN | Offset Data Pointer down by the value of the immediate next byte of Program Memory. | 49 | DPDN | Offset Data Pointer down by the value of the immediate next byte of Program Memory. |
### Output Operations: 3 Instructions ### Output Operations: 3 Instructions
Hex Code | Mnemonic | Description | Hex Code | Mnemonic | Description |
-- | -- | -- | -- | ---- | -- |
D0 | OUTQ | Writes the value of Q to an Output specified by the next byte of Program Memory. | D0 | OUTQ | Writes the value of Q to an Output specified by the next byte of Program Memory. |
D1 | OUTA | Writes the value of A to an Output specified by the next byte of Program Memory. | D1 | OUTA | Writes the value of A to an Output specified by the next byte of Program Memory. |
D2 | OUTB | Writes the value of B to an Output specified by the next byte of Program Memory. | D2 | OUTB | Writes the value of B to an Output specified by the next byte of Program Memory. |
### Input Operations: 2 Instructions ### Input Operations: 2 Instructions
Hex Code | Mnemonic | Description | Hex Code | Mnemonic | Description |
-- | -- | -- | -- | ---- | -- |
E0 | INA | Writes the value of an Input to A. The input port is specified the next byte of Program Memory. | E0 | INA | Writes the value of an Input to A. The input port is specified the next byte of Program Memory. |
E1 | INB | Writes the value of an Input to B. The input port is specified the next byte of Program Memory. | E1 | INB | Writes the value of an Input to B. The input port is specified the next byte of Program Memory. |
### Special Operations: 2 Instructions ### Special Operations: 2 Instructions
Hex Code | Mnemonic | Description | Hex Code | Mnemonic | Description |
-- | -- | -- | -- | ---- | -- |
F0 | NOP | Perform no Operation, increment the Program Counter. | F0 | NOP | Perform no Operation, increment the Program Counter. |
FF | HALT | Stops CPU Execution. | FF | HALT | Stops CPU Execution. |
## Input and Output In the Emulator: ## Input and Output In the Emulator:
The current implementation has Input 0 and Output 0 hooked to stdout and stdin respectively, allowing programs to read to and from the console. The current implementation has Input 0 and Output 0 hooked to stdin and stdout respectively, allowing programs to read to and from the console.
### Example Program: Hello World ### Example Program: Hello World
``` ```