diff --git a/Source/Core/Core/DSP/DSPAssembler.cpp b/Source/Core/Core/DSP/DSPAssembler.cpp index 87dc10543f..e7d989fcbe 100644 --- a/Source/Core/Core/DSP/DSPAssembler.cpp +++ b/Source/Core/Core/DSP/DSPAssembler.cpp @@ -462,7 +462,7 @@ static u16 get_mask_shifted_down(u16 mask) return mask; } -bool DSPAssembler::VerifyParams(const opc_t* opc, param_t* par, size_t count, bool ext) +bool DSPAssembler::VerifyParams(const opc_t* opc, param_t* par, size_t count, OpcodeType type) { for (size_t i = 0; i < count; i++) { @@ -491,7 +491,7 @@ bool DSPAssembler::VerifyParams(const opc_t* opc, param_t* par, size_t count, bo if ((int)par[i].val < value || (int)par[i].val > value + get_mask_shifted_down(opc->params[i].mask)) { - if (ext) + if (type == OpcodeType::Extension) fprintf(stderr, "(ext) "); fprintf(stderr, "%s (param %zu)", cur_line.c_str(), current_param); @@ -501,7 +501,7 @@ bool DSPAssembler::VerifyParams(const opc_t* opc, param_t* par, size_t count, bo case P_PRG: if ((int)par[i].val < 0 || (int)par[i].val > 0x3) { - if (ext) + if (type == OpcodeType::Extension) fprintf(stderr, "(ext) "); fprintf(stderr, "%s (param %zu)", cur_line.c_str(), current_param); @@ -511,7 +511,7 @@ bool DSPAssembler::VerifyParams(const opc_t* opc, param_t* par, size_t count, bo case P_ACC: if ((int)par[i].val < 0x20 || (int)par[i].val > 0x21) { - if (ext) + if (type == OpcodeType::Extension) fprintf(stderr, "(ext) "); if (par[i].val >= 0x1e && par[i].val <= 0x1f) @@ -519,7 +519,8 @@ bool DSPAssembler::VerifyParams(const opc_t* opc, param_t* par, size_t count, bo fprintf(stderr, "%i : %s ", code_line, cur_line.c_str()); fprintf(stderr, "WARNING: $ACM%d register used instead of $ACC%d register Line: %d " "Param: %zu Ext: %d\n", - (par[i].val & 1), (par[i].val & 1), code_line, current_param, ext); + (par[i].val & 1), (par[i].val & 1), code_line, current_param, + static_cast(type)); } else if (par[i].val >= 0x1c && par[i].val <= 0x1d) { @@ -537,7 +538,7 @@ bool DSPAssembler::VerifyParams(const opc_t* opc, param_t* par, size_t count, bo case P_ACCM: if ((int)par[i].val < 0x1e || (int)par[i].val > 0x1f) { - if (ext) + if (type == OpcodeType::Extension) fprintf(stderr, "(ext) "); if (par[i].val >= 0x1c && par[i].val <= 0x1d) @@ -564,7 +565,7 @@ bool DSPAssembler::VerifyParams(const opc_t* opc, param_t* par, size_t count, bo case P_ACCL: if ((int)par[i].val < 0x1c || (int)par[i].val > 0x1d) { - if (ext) + if (type == OpcodeType::Extension) fprintf(stderr, "(ext) "); if (par[i].val >= 0x1e && par[i].val <= 0x1f) @@ -602,22 +603,22 @@ bool DSPAssembler::VerifyParams(const opc_t* opc, param_t* par, size_t count, bo switch (par[i].type & (P_REG | 7)) { case P_REG: - if (ext) + if (type == OpcodeType::Extension) fprintf(stderr, "(ext) "); ShowError(ERR_EXPECTED_PARAM_REG); break; case P_MEM: - if (ext) + if (type == OpcodeType::Extension) fprintf(stderr, "(ext) "); ShowError(ERR_EXPECTED_PARAM_MEM); break; case P_VAL: - if (ext) + if (type == OpcodeType::Extension) fprintf(stderr, "(ext) "); ShowError(ERR_EXPECTED_PARAM_VAL); break; case P_IMM: - if (ext) + if (type == OpcodeType::Extension) fprintf(stderr, "(ext) "); ShowError(ERR_EXPECTED_PARAM_IMM); break; @@ -975,7 +976,7 @@ bool DSPAssembler::AssembleFile(const std::string& file_path, int pass) opcode_size = opc->size; - VerifyParams(opc, params, params_count); + VerifyParams(opc, params, params_count, OpcodeType::Primary); const opc_t* opc_ext = nullptr; // Check for opcode extensions. @@ -984,10 +985,12 @@ bool DSPAssembler::AssembleFile(const std::string& file_path, int pass) if (opcode_ext) { opc_ext = FindOpcode(opcode_ext, params_count_ext, OpcodeType::Extension); - VerifyParams(opc_ext, params_ext, params_count_ext, true); + VerifyParams(opc_ext, params_ext, params_count_ext, OpcodeType::Extension); } else if (params_count_ext) + { ShowError(ERR_EXT_PAR_NOT_EXT); + } } else { diff --git a/Source/Core/Core/DSP/DSPAssembler.h b/Source/Core/Core/DSP/DSPAssembler.h index cd3ee98198..183a4ef7ae 100644 --- a/Source/Core/Core/DSP/DSPAssembler.h +++ b/Source/Core/Core/DSP/DSPAssembler.h @@ -98,7 +98,7 @@ private: char* FindBrackets(char* src, char* dst); const opc_t* FindOpcode(std::string name, size_t par_count, OpcodeType type); - bool VerifyParams(const opc_t* opc, param_t* par, size_t count, bool ext = false); + bool VerifyParams(const opc_t* opc, param_t* par, size_t count, OpcodeType type); void BuildCode(const opc_t* opc, param_t* par, u32 par_count, u16* outbuf); std::vector m_output_buffer;