#define BEGIN \ do{ \ chip8* c8 = usrdat; \ assert(c8); #define END }while(0) #define X_C8_ILL \ BEGIN \ \ c8->running = false; \ report(ERR, "Illegal instruction (%04X) @ %04X\n", instr, offset); \ END #define X_C8_CLS X_C8_ILL #define X_C8_RET X_C8_ILL #define X_C8_SYS X_C8_ILL #define X_C8_JP \ BEGIN \ c8->pc = nnn - 2; \ END #define X_C8_CALL X_C8_ILL #define X_C8_LDI X_C8_ILL #define X_C8_JPV X_C8_ILL #define X_C8_SEB \ BEGIN \ if(c8->V[x] == kk) c8->pc += 2; \ END #define X_C8_SNEB X_C8_ILL #define X_C8_LD \ BEGIN \ c8->V[x] = kk; \ END #define X_C8_ADDB \ BEGIN \ int tmp = (int)c8->V[x] + (int)kk; \ c8->V[x] = tmp & 0xFF; \ END #define X_C8_RND X_C8_ILL #define X_C8_SKP X_C8_ILL #define X_C8_SKNP X_C8_ILL #define X_C8_MVDT X_C8_ILL #define X_C8_LDK X_C8_ILL #define X_C8_LDDT X_C8_ILL #define X_C8_LDST X_C8_ILL #define X_C8_ADDI X_C8_ILL #define X_C8_HEX X_C8_ILL #define X_C8_BCD X_C8_ILL #define X_C8_SAVE X_C8_ILL #define X_C8_RESTORE X_C8_ILL #define X_C8_SE X_C8_ILL #define X_C8_MOVE X_C8_ILL #define X_C8_OR X_C8_ILL #define X_C8_AND X_C8_ILL #define X_C8_XOR X_C8_ILL #define X_C8_ADD \ BEGIN \ int tmp = (int)c8->V[x] + (int)c8->V[y]; \ c8->V[0xf] = (tmp > 255); \ c8->V[x] = tmp & 0xFF; \ END #define X_C8_SUB X_C8_ILL #define X_C8_SHR X_C8_ILL #define X_C8_SUBN X_C8_ILL #define X_C8_SHL X_C8_ILL #define X_C8_SNE X_C8_ILL #define X_C8_DRW X_C8_ILL c8_decode_generate(exec) #undef BEGIN #undef END #include "undef.c"