Assorted bug fixes. Added INIA and INIB instructions.
This commit is contained in:
+10
-6
@@ -150,12 +150,14 @@ uint8_t executeOperation(uint8_t Instruction, CPURegisters *cpu) {
|
|||||||
cpu->B = cpu->Data[cpu->DataPointer];
|
cpu->B = cpu->Data[cpu->DataPointer];
|
||||||
break;
|
break;
|
||||||
case 0x28:
|
case 0x28:
|
||||||
// INCD - Add 1 to the Data Pointer.
|
// INIA - Initialize A Immediately from Program Memory.
|
||||||
cpu->DataPointer++;
|
cpu->ProgramCounter++;
|
||||||
|
cpu->A = cpu->Data[cpu->ProgramCounter];
|
||||||
break;
|
break;
|
||||||
case 0x29:
|
case 0x29:
|
||||||
// DECD - Subtract 1 from the Data Pointer.
|
// INIB - Initialize A Immediately from Program Memory.
|
||||||
cpu->DataPointer--;
|
cpu->ProgramCounter++;
|
||||||
|
cpu->B = cpu->Data[cpu->ProgramCounter];
|
||||||
break;
|
break;
|
||||||
//
|
//
|
||||||
// 3x - Stack Operations:
|
// 3x - Stack Operations:
|
||||||
@@ -193,19 +195,21 @@ uint8_t executeOperation(uint8_t Instruction, CPURegisters *cpu) {
|
|||||||
break;
|
break;
|
||||||
case 0x35:
|
case 0x35:
|
||||||
// POPA - Pop Data to A.
|
// POPA - Pop Data to A.
|
||||||
cpu->A = cpu->Data[cpu->StackPointer];
|
|
||||||
cpu->StackPointer++;
|
cpu->StackPointer++;
|
||||||
|
cpu->A = cpu->Data[cpu->StackPointer];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 0x36:
|
case 0x36:
|
||||||
// POPB - Pop Data to B.
|
// POPB - Pop Data to B.
|
||||||
cpu->B = cpu->Data[cpu->StackPointer];
|
|
||||||
cpu->StackPointer++;
|
cpu->StackPointer++;
|
||||||
|
cpu->B = cpu->Data[cpu->StackPointer];
|
||||||
break;
|
break;
|
||||||
case 0x37:
|
case 0x37:
|
||||||
// POPP - Pop Data to the Program Counter
|
// POPP - Pop Data to the Program Counter
|
||||||
cpu->ProgramCounter = (uint16_t)cpu->Data[cpu->StackPointer] << 8;
|
cpu->ProgramCounter = (uint16_t)cpu->Data[cpu->StackPointer] << 8;
|
||||||
cpu->StackPointer++;
|
cpu->StackPointer++;
|
||||||
cpu->ProgramCounter = cpu->ProgramCounter | (uint16_t)cpu->Data[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++;
|
cpu->StackPointer++;
|
||||||
break;
|
break;
|
||||||
case 0x38:
|
case 0x38:
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ int main (int argc, char *argv[]) {
|
|||||||
if (debugEnable) {
|
if (debugEnable) {
|
||||||
getchar();
|
getchar();
|
||||||
printRegisters(&cpu, Program, Data);
|
printRegisters(&cpu, Program, Data);
|
||||||
|
printf("Cycle: %u\n", cycleCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("Execution halted after %u cycles.\n", cycleCount);
|
printf("Execution halted after %u cycles.\n", cycleCount);
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ Hex Code | Mnemonic | Description
|
|||||||
| 23 | INCB | Adds 1 to B. |
|
| 23 | INCB | Adds 1 to B. |
|
||||||
| 24 | DECA | Subtracts 1 from A. |
|
| 24 | DECA | Subtracts 1 from A. |
|
||||||
| 25 | DECB | Subtracts 1 from B. |
|
| 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
|
### Stack Operations: 9 Instructions
|
||||||
Hex Code | Mnemonic | Description
|
Hex Code | Mnemonic | Description
|
||||||
|
|||||||
Reference in New Issue
Block a user