Debugging is now working.

This commit is contained in:
Felix Queißner 2016-05-28 00:40:05 +02:00
parent 5bcf363b6b
commit 6f3bf47570
3 changed files with 25 additions and 2 deletions

View file

@ -107,6 +107,7 @@ namespace SuperVM.Assembler
}
var instruction = mnemonics[mnemonic];
instruction.Argument = argument;
foreach (var annotation in annotations)
{
@ -207,6 +208,10 @@ namespace SuperVM.Assembler
code[patch.Key] =
(code[patch.Key] & 0xFFFFFFFF) |
((ulong)position << 32);
var i = instructions[patch.Key];
i.Argument = (uint)position;
instructions[patch.Key] = i;
}
}

View file

@ -110,6 +110,9 @@
</ScrollViewer>
</Grid>
</TabItem>
<TabItem Header="Output">
<TextBox VerticalContentAlignment="Top" Text="{Binding Path=Output}"/>
</TabItem>
</TabControl>
</Grid>
<TabControl>

View file

@ -21,6 +21,7 @@ namespace SuperVM.VisualDebugger
{
Memory = new Memory(1024),
};
this.process.SysCall += Process_SysCall;
this.Source = "\tpush 12\n\tpush 30\n\tadd\n\tdrop";
@ -28,12 +29,24 @@ namespace SuperVM.VisualDebugger
this.Reset();
this.StepCommand = new RelayCommand(this.Step);
this.ResetCommand = new RelayCommand(this.Reset);
this.RecompileCommand = new RelayCommand(this.Recompile);
}
private void Process_SysCall(object sender, Process.CommandExecutionEnvironment e)
{
switch(e.Additional)
{
case 1:
{
this.Output += Encoding.ASCII.GetString(new[] { (byte)e.Input0 });
this.OnPropertyChanged(nameof(Output));
break;
}
}
}
public void Recompile()
{
this.assembly = Assembler.Assembler.Assemble(this.Source);
@ -71,7 +84,7 @@ namespace SuperVM.VisualDebugger
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public int CurrentSourceLine => this.assembly.OriginalLine[this.CodePointer] - 1;
public int CurrentSourceLine => (this.CodePointer < this.assembly.OriginalLine.Count) ? (this.assembly.OriginalLine[this.CodePointer] - 1) : -1;
public int StackPointer
{
@ -110,6 +123,8 @@ namespace SuperVM.VisualDebugger
public string Source { get; set; }
public string Output { get; set; }
public ICommand StepCommand { get; private set; }
public ICommand ResetCommand { get; private set; }