Assorted bug fixes. Added INIA and INIB instructions.

This commit is contained in:
Anachronaut
2024-10-18 16:23:03 -04:00
committed by GitHub
parent 77bffb233a
commit 60450253cd
3 changed files with 15 additions and 6 deletions
+10 -6
View File
@@ -150,12 +150,14 @@ uint8_t executeOperation(uint8_t Instruction, CPURegisters *cpu) {
cpu->B = cpu->Data[cpu->DataPointer];
break;
case 0x28:
// INCD - Add 1 to the Data Pointer.
cpu->DataPointer++;
// INIA - Initialize A Immediately from Program Memory.
cpu->ProgramCounter++;
cpu->A = cpu->Data[cpu->ProgramCounter];
break;
case 0x29:
// DECD - Subtract 1 from the Data Pointer.
cpu->DataPointer--;
// INIB - Initialize A Immediately from Program Memory.
cpu->ProgramCounter++;
cpu->B = cpu->Data[cpu->ProgramCounter];
break;
//
// 3x - Stack Operations:
@@ -193,19 +195,21 @@ uint8_t executeOperation(uint8_t Instruction, CPURegisters *cpu) {
break;
case 0x35:
// POPA - Pop Data to A.
cpu->A = cpu->Data[cpu->StackPointer];
cpu->StackPointer++;
cpu->A = cpu->Data[cpu->StackPointer];
break;
case 0x36:
// POPB - Pop Data to B.
cpu->B = cpu->Data[cpu->StackPointer];
cpu->StackPointer++;
cpu->B = cpu->Data[cpu->StackPointer];
break;
case 0x37:
// POPP - Pop Data to the Program Counter
cpu->ProgramCounter = (uint16_t)cpu->Data[cpu->StackPointer] << 8;
cpu->StackPointer++;
cpu->ProgramCounter = cpu->ProgramCounter | (uint16_t)cpu->Data[cpu->StackPointer];
cpu->ProgramCounter += 3; // Because it needs to skip over the subsequent branch instruction on return.
cpu->StackPointer++;
break;
case 0x38:
+1
View File
@@ -57,6 +57,7 @@ int main (int argc, char *argv[]) {
if (debugEnable) {
getchar();
printRegisters(&cpu, Program, Data);
printf("Cycle: %u\n", cycleCount);
}
}
printf("Execution halted after %u cycles.\n", cycleCount);
+4
View File
@@ -46,6 +46,10 @@ Hex Code | Mnemonic | Description
| 23 | INCB | Adds 1 to B. |
| 24 | DECA | Subtracts 1 from A. |
| 25 | DECB | Subtracts 1 from B. |
| 26 | LDA | Loads Data to A via the Data Pointer. |
| 27 | LDB | Loads Data to B via the Data Pointer.
| 28 | INIA | Loads the next byte of Program Memory to A. |
| 29 | INIB | Loads the next byte of Program Memory to B. |
### Stack Operations: 9 Instructions
Hex Code | Mnemonic | Description