public static void StepOver() { long prognum = Mem.GetByte(MemPos.prog); long linenum = Mem.GetNum(MemPos.progline, 2); SetBreakpoint(prognum, linenum + 1, true); }
public static void Push() { StackItem item = new StackItem(); item.prog = Mem.GetByte(MemPos.prog); item.progline = Mem.GetNum(MemPos.progline, 2); _gosubstack.Push(item); }
private static void ExecuteAlphaAssignment() { long?targetPos = null; bool isBuffer = false; targetPos = MemPos.GetPosAlpha(_tokens[_tokenNum]); if (!targetPos.HasValue) { targetPos = MemPos.GetPosBufferAlpha(_tokens[_tokenNum]); if (targetPos.HasValue) { isBuffer = true; } } if (!targetPos.HasValue) { throw new SystemException("Cannot parse alpha assignment: Target not found"); } _tokenNum++; if (_tokens[_tokenNum] == "[") { _tokenNum++; // "[" long offset = GetNumericExpression(); if (_tokens[_tokenNum++] != "]") { throw new SystemException("ExecuteAlphaAssignment: No closing \"]\""); } targetPos += offset; } if (_tokens[_tokenNum] != "=") { throw new SystemException("Cannot parse alpha expression: Equals sign expected"); } _tokenNum++; string result = GetAlphaExpression(); if (isBuffer) { long bufferTargetPos = Mem.GetByte(targetPos.Value) + (256 * Mem.GetByte(targetPos.Value + 1)); Mem.SetAlpha(bufferTargetPos, result); if (result == "") { bufferTargetPos += 1; } else { bufferTargetPos += result.Length; } Mem.SetByte(targetPos.Value + 1, bufferTargetPos / 256); Mem.SetByte(targetPos.Value, bufferTargetPos % 256); } else { Mem.SetAlpha(targetPos.Value, result); } }
public static void Run() { long prognum; long linenum; while (true) { // get current program and line prognum = Mem.GetByte(MemPos.prog); linenum = Mem.GetNum(MemPos.progline, 2); // do debug events as needed Debug.RaiseProgLine(prognum, linenum); if (Debug.HasBreakpoint(prognum, linenum)) { Debug.RaiseBreakpoint(prognum, linenum); } // handle current line _lineText = ILCode.GetLine(prognum, linenum); _tokens = _lineText.Split('\t'); _tokenCount = _tokens.GetUpperBound(0) + 1; _tokenNum = 0; if (Functions.IsNumber(_tokens[_tokenNum])) { _tokenNum++; // line number } try { // move to next line in preparation, could be changed by command Mem.SetNum(MemPos.progline, 2, linenum + 1); ExecuteLine(); } catch (Exception ex) { Console.WriteLine(ex.Message); throw; } } }
private static long GetNumericValue() { string currToken = _tokens[_tokenNum++]; if (Functions.IsNumber(currToken)) { return(long.Parse(currToken)); } if (currToken == "FALSE") { return(0); } if (currToken == "TRUE") { return(1); } long?targetPos = null; long?targetSize = null; bool?isTargetByte = null; bool?isBuffer = null; targetPos = MemPos.GetPosByte(currToken); if (targetPos.HasValue) { targetSize = 1; isTargetByte = true; isBuffer = false; } else { targetPos = MemPos.GetPosNumeric(currToken); if (targetPos.HasValue) { targetSize = MemPos.GetSizeNumeric(currToken); isTargetByte = false; isBuffer = false; } else { targetPos = MemPos.GetPosBufferPtr(currToken); if (targetPos.HasValue) { if (_tokens[_tokenNum] == "(") { _tokenNum++; targetSize = GetNumericValue(); _tokenNum++; isTargetByte = false; isBuffer = true; } } } } if (!targetPos.HasValue || !targetSize.HasValue || !isTargetByte.HasValue || !isBuffer.HasValue) { throw new SystemException("GetNumericValue error"); } if (_tokenNum < _tokenCount && _tokens[_tokenNum] == "[") { _tokenNum++; // "[" long offset = GetNumericExpression(); if (_tokens[_tokenNum++] != "]") { throw new SystemException("GetNumericValue: No closing \"]\""); } targetPos += offset; } if (isTargetByte.Value) { return(Mem.GetByte(targetPos.Value)); } if (isBuffer.Value) { return(Mem.GetNumBuffer(targetPos.Value, targetSize.Value)); } return(Mem.GetNum(targetPos.Value, targetSize.Value)); }
public static bool IsStay() { return(Mem.GetByte(MemPos.charval) == 255); }