public void MapBranchAddress(IDictionary <int, AddressableInstruction> instructionDictionary, IDictionary <String, AddressableInstruction> labeledInstructionDictionary) { if (this.AutoBranchNext) { // Auto branch instructions just need to branch to the next instruction in the source code. int nextInstructionSourceAddress = this.Address.SourceAddress + this.SourceLength; ExecutableInstruction destinationInstruction = instructionDictionary[nextInstructionSourceAddress] as ExecutableInstruction; this.MapBranchAddress(destinationInstruction); } else { if (this.BranchAddress.IsLabelledAddress) { // If the branch is a label, resolve the labeled instruction... ExecutableInstruction destinationInstruction = labeledInstructionDictionary[this.BranchAddress.AddressLabel] as ExecutableInstruction; this.MapBranchAddress(destinationInstruction); } else if (this.BranchAddress.SourceAddress != -1) { // ...Otherwise, resolve the destination from the branch source address. ExecutableInstruction destinationInstruction = instructionDictionary[this.BranchAddress.SourceAddress] as ExecutableInstruction; this.MapBranchAddress(destinationInstruction); } } }
private void MapBranchAddress(ExecutableInstruction destinationInstruction) { this.BranchDestination = destinationInstruction; }