void ParseRegisters(Registers pRegisters, string pString) { var matches = _regexRegisters.Matches(pString); foreach (Match match in matches) { try { pRegisters[match.Groups["register"].Value] = Convert.Parse(match.Groups["value"].Value, isHex: true); } catch { // ignore } } matches = _regexFlags.Matches(pString); foreach (Match match in matches) { // match.Groups["register"].Value // match.Groups["s"].Value // match.Groups["z"].Value // match.Groups["bit5"].Value // match.Groups["h"].Value // match.Groups["bit3"].Value // match.Groups["n"].Value // match.Groups["c"].Value } }
void Custom_WatchMemory(Request request, string id, string address, string length) { _session.VSCode.Ack(request); var watch = new MemWatch() { ID = id, Address = Convert.Parse(address), Length = Convert.Parse(length) }; _memWatches[id] = watch; Check_MemoryWatch(watch); }
string Evaluate_Variable(Request request, string expression) { var result = "n/a"; var parts = expression.Split(_varSplitChar, StringSplitOptions.RemoveEmptyEntries); var gotAddress = false; var gotLength = false; var gotData = false; var isPointer = false; var isRegister = false; ushort address = 0; var parsedLength = 0; var length = 0; foreach (string part in parts) { var text = part; if (!gotAddress) { if (text.StartsWith("(") && text.EndsWith(")")) { isPointer = true; text = text.Substring(1, text.Length - 2).Trim(); } if (_session.Machine.Registers.IsValidRegister(text)) { address = _session.Machine.Registers[text]; length = 2; gotLength = true; isRegister = true; if (!isPointer) { _tempVar[0] = (byte)(address & 0xFF); if (length == 2) { _tempVar[1] = _tempVar[0]; _tempVar[0] = (byte)(address >> 8); } length = _session.Machine.Registers.SizeOf(text); gotLength = true; gotData = true; } } else { address = Convert.Parse(text); length = 1; gotLength = true; } gotAddress = true; continue; } if (gotAddress && int.TryParse(text, out parsedLength)) { length = Math.Max(0, Math.Min(parsedLength, _tempVar.Length)); gotLength = true; continue; } } if (gotAddress && gotLength && !gotData) { _session.Machine.Memory.Read(address, _tempVar, 0, length); } result = Convert.ToHex(_tempVar, length); if (isPointer && isRegister) { result = $"({address.ToHex()}) {result}"; } return(result); }
public override bool ReadMemoryConfiguration(Memory memory) { var currentPages = SendAndReceiveSingle("get-memory-pages"); var currentPagingState = SendAndReceiveSingle("get-paging-state"); // don't get verbose page list if the simple page lists haven't changed if (_lastGetMemoryPages == currentPages && _lastGetPagingState == currentPagingState) { return(false); } _lastGetMemoryPages = currentPages; _lastGetPagingState = currentPagingState; memory.ClearConfiguration(); memory.PagingEnabled = true; // now get the verbose page lists var lines = SendAndReceive("get-memory-pages verbose", _tempMemoryConfig); int count = 0; string indexStr = null; string typeStr = null; string numberStr = null; string shortnameStr = null; string startAddrStr = null; string endAddrStr = null; foreach (var line in lines) { var match = _regexPages.Match(line); if (!match.Success) { continue; } count += UpdateFromRegexGroup(match.Groups, "index", ref indexStr); count += UpdateFromRegexGroup(match.Groups, "type", ref typeStr); count += UpdateFromRegexGroup(match.Groups, "number", ref numberStr); count += UpdateFromRegexGroup(match.Groups, "shortname", ref shortnameStr); count += UpdateFromRegexGroup(match.Groups, "startaddr", ref startAddrStr); count += UpdateFromRegexGroup(match.Groups, "endaddr", ref endAddrStr); if (count != 6) { continue; } if (typeStr == "System") { typeStr = numberStr; numberStr = "0"; } var number = int.Parse(numberStr); var startAddr = Convert.Parse(startAddrStr); var endAddr = Convert.Parse(endAddrStr); var length = (ushort)(endAddr - startAddr + 1); var bankID = new BankID(typeStr, number, BankID.PartEnum.All); memory.SetAddressBank(startAddr, length, memory.Bank(bankID)); indexStr = typeStr = numberStr = shortnameStr = startAddrStr = endAddrStr = null; count = 0; } return(true); }