#include "cpu.h" #include static void printBinary(int num) { if (num > 1) { printBinary(num / 2); } printf("%d", num % 2); } int execute_instruction_on_cpu(CPU *cpu, uint32_t instruction) { AddressSpace *addressSpace = cpu->addressSpace; cpu->registers[0] = 0; // x0 is always 0 uint8_t opcode = instruction & 0x7F; uint8_t rd = instruction >> 7 & 0x1F; if (opcode != 0) { printf("\nPC: %d\n", cpu->programCounter); printf("Instruction: "); printBinary(instruction); printf("\nOpcode: 0x%X (", opcode); printBinary(opcode); printf(")\n"); printf("Dest. reg.: x%d\n", rd); } // TODO return 0; }