diff --git a/imlac/Debugger/Console.cs b/imlac/Debugger/Console.cs index 64038e2..6093f71 100644 --- a/imlac/Debugger/Console.cs +++ b/imlac/Debugger/Console.cs @@ -63,7 +63,7 @@ namespace imlac.Debugger } } - public void AddSubNode(List words, MethodInfo method, object instance) + public void AddSubNode(List words, DebuggerCommand command) { // We should never hit this case. if (words.Count == 0) @@ -77,13 +77,13 @@ namespace imlac.Debugger if (subNode == null) { // No, it has not -- create one and add it now. - subNode = new DebuggerCommand(instance, words[0], null, null, null); + subNode = new DebuggerCommand(command.Instance, words[0], command.Description, command.Usage, null); this.SubCommands.Add(subNode); if (words.Count == 1) { // This is the last stop -- set the method and be done with it now. - subNode.Methods.Add(method); + subNode.Methods.Add(command.Methods[0]); // early return. return; @@ -98,7 +98,7 @@ namespace imlac.Debugger // If we're on the last word at this point then this is an overloaded command. // Check that we don't have any other commands with this number of arguments. // - int argCount = method.GetParameters().Length; + int argCount = command.Methods[0].GetParameters().Length; foreach (MethodInfo info in subNode.Methods) { if (info.GetParameters().Length == argCount) @@ -110,7 +110,7 @@ namespace imlac.Debugger // // We're ok. Add it to the method list. // - subNode.Methods.Add(method); + subNode.Methods.Add(command.Methods[0]); // and return early. return; @@ -119,7 +119,7 @@ namespace imlac.Debugger // We have more words to go. words.RemoveAt(0); - subNode.AddSubNode(words, method, instance); + subNode.AddSubNode(words, command); } public DebuggerCommand FindSubNodeByName(string name) @@ -656,9 +656,9 @@ namespace imlac.Debugger { string[] commandWords = c.Name.Split(' '); - // This is kind of ugly, we know that at this point every command built above have only + // This is kind of ugly, we know that at this point every command built above has only // one method. When building the tree, overloaded commands may end up with more than one. - _commandRoot.AddSubNode(new List(commandWords), c.Methods[0], c.Instance); + _commandRoot.AddSubNode(new List(commandWords), c); } } diff --git a/imlac/Debugger/DebuggerPrompt.cs b/imlac/Debugger/DebuggerPrompt.cs index 6b6c330..1d2d733 100644 --- a/imlac/Debugger/DebuggerPrompt.cs +++ b/imlac/Debugger/DebuggerPrompt.cs @@ -297,6 +297,13 @@ namespace imlac.Debugger { changed = _input.Trim().ToLower() != matchString.Trim().ToLower(); + // Add a space if the output is different than the input (in which case a completion + // actually took place. + if (changed) + { + matchString += " "; + } + _input = matchString; TextPosition = _input.Length; } @@ -323,6 +330,7 @@ namespace imlac.Debugger } DebuggerCommand match = null; + bool exactMatch = false; // Search for exact matches. If we find one it's guaranteed to be unique // so we can follow that node. @@ -331,6 +339,7 @@ namespace imlac.Debugger if (c.Name.ToLower() == tokens[0].ToLower()) { match = c; + exactMatch = true; break; } } @@ -394,7 +403,7 @@ namespace imlac.Debugger { subMatch = FuzzyMatch(match, tokens, silent); } - else // if (exactMatch) + else { if (!silent && match.SubCommands.Count > 1) { @@ -422,11 +431,27 @@ namespace imlac.Debugger return sb.ToString(); } + else if (!silent && + match.SubCommands.Count == 0 && + exactMatch) + { + // No more completions; this was an exact match, so + // instead print the help for this command if any + // is available. + Console.WriteLine(); + Console.WriteLine(match.Description); + + if (!String.IsNullOrWhiteSpace(match.Usage)) + { + Console.WriteLine("Parameters: {0}", match.Usage); + } + + } } if (subMatch == String.Empty) { - return String.Format("{0} ", match.Name); + return String.Format("{0}", match.Name); } else { diff --git a/imlac/PDS1DisplayProcessor.cs b/imlac/PDS1DisplayProcessor.cs index b1e9068..a58dd5b 100644 --- a/imlac/PDS1DisplayProcessor.cs +++ b/imlac/PDS1DisplayProcessor.cs @@ -726,7 +726,7 @@ namespace imlac { case DisplayOpcode.DLVH: length = 3; - ret = DecodeLongVector(mem); + ret = DisassembleLongVector(mem); break; default: @@ -739,7 +739,7 @@ namespace imlac return ret; } - private string DecodeLongVector(Memory mem) + private string DisassembleLongVector(Memory mem) { // // A Long Vector instruction is 3 words long: diff --git a/imlac/PDS4DisplayProcessor.cs b/imlac/PDS4DisplayProcessor.cs index fc735b7..7f3d02c 100644 --- a/imlac/PDS4DisplayProcessor.cs +++ b/imlac/PDS4DisplayProcessor.cs @@ -406,7 +406,11 @@ namespace imlac // accurate with respect to timing. (Ok, it's not accurate at all.) // TODO: refactor Immediate halfword routines here (share w/short vectors?) _camWord = _mem.Fetch(++_pc); - _camHalf = ImmediateHalf.First; + _camHalf = ImmediateHalf.First; + + // Update the instruction cache with the type of instruction (to aid in debugging). + PDS4DisplayInstruction dbgInst = GetCachedInstruction(_pc, DisplayProcessorMode.CompactAddressing); + if (Trace.TraceOn) Trace.Log(LogType.DisplayProcessor, "Enter Compact Addressing mode, base address {0}", Helpers.ToOctal(_caBase)); @@ -736,6 +740,10 @@ namespace imlac case DisplayProcessorMode.Processor: return DisassembleProcessor(mem, out length); + case DisplayProcessorMode.CompactAddressing: + length = 1; + return DisassembleCompactAddressing(); + case DisplayProcessorMode.Indeterminate: length = 1; return "Indeterminate"; @@ -916,6 +924,13 @@ namespace imlac // TODO: eventually actually precache movement calculations. } + private string DisassembleCompactAddressing() + { + return String.Format("DCAM {0},{1}", + Helpers.ToOctal((ushort)(_word >> 8)), + Helpers.ToOctal((ushort)(_word & 0xff))); + } + protected override string DisassembleExtended(Memory mem, out int length) { string ret = String.Empty; @@ -923,7 +938,7 @@ namespace imlac { case DisplayOpcode.DLVH: length = 2; - ret = DecodeLongVector(mem); + ret = DisassembleLongVector(mem); break; default: @@ -936,7 +951,7 @@ namespace imlac return ret; } - private string DecodeLongVector(Memory mem) + private string DisassembleLongVector(Memory mem) { // // A Long Vector instruction is 3 words long: diff --git a/imlac/System.cs b/imlac/System.cs index c17f7e8..a2018bf 100644 --- a/imlac/System.cs +++ b/imlac/System.cs @@ -573,6 +573,7 @@ namespace imlac Processor, DisplayProcessor, DisplayIncrement, + DisplayCompact, DisplayAuto } @@ -693,6 +694,10 @@ namespace imlac case DisassemblyMode.DisplayIncrement: disassembly = DisplayProcessor.Disassemble(address, DisplayProcessorMode.Increment, out size); break; + + case DisassemblyMode.DisplayCompact: + disassembly = DisplayProcessor.Disassemble(address, DisplayProcessorMode.CompactAddressing, out size); + break; } } catch