Skip to content

Commit

Permalink
Fix exception that should be an error message (#9)
Browse files Browse the repository at this point in the history
When combining an existing instruction mnemonic with one or two
existing register names, but the combination wasn't a valid instruction,
a "ProcessCpuInstruction: something went wrong: a fixed instruction
argument was not processed as such" exception was thrown.
Now a regular "invalid instruction" error is generated instead.
  • Loading branch information
Konamiman authored Apr 1, 2024
1 parent c0dc416 commit 400abae
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Assembler/AssemblySourceProcessor.CpuInstructions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,17 @@ static string RemoveSpacesAroundParenthesis(string argument)
return line;
}

// There's at least one variable argument.
// There's (or there should be) at least one variable argument.

var firstArgumentType = GetCpuInstructionArgumentPattern(firstArgument);
var secondArgumentType = GetCpuInstructionArgumentPattern(secondArgument);

if(firstArgumentType is CpuParsedArgType.Fixed && secondArgumentType is CpuParsedArgType.Fixed or CpuParsedArgType.None) {
AddError(AssemblyErrorCode.InvalidCpuInstruction, $"Invalid {currentCpu} instruction: {instructionSearchKey}");
walker.DiscardRemaining();
return new CpuInstructionLine() { IsInvalid = true };
}

bool isInstructionWithTwoVariableArguments = false;
var isLD = string.Equals("LD", opcode, StringComparison.OrdinalIgnoreCase);
if(isZ280) {
Expand Down

0 comments on commit 400abae

Please sign in to comment.