1212namespace VNS {
1313 public partial class MainWindow : MetroWindow {
1414 private readonly MemoryContainer _memoryContainer = new MemoryContainer ( ) ;
15- private static readonly Regex NumberRegex = new Regex ( "[^0-9]+" ) ;
15+ private static readonly Regex NumberRegex = new Regex ( "[^0-9- ]+" ) ;
1616 private static readonly Color BlueColor = Color . FromRgb ( 135 , 206 , 255 ) ;
1717 private string [ ] _codeLines ;
1818 public WindowBindings WindowBindings { get ; set ; }
@@ -170,6 +170,59 @@ public async Task ProcessLine(string line) {
170170 await Task . Delay ( ( int ) DelaySizer . Value ) ;
171171 WindowBindings . AccumulatorBrush = null ;
172172 break ;
173+ case "JMP" :
174+ WindowBindings . AluRegister1 = "" ;
175+ WindowBindings . AluRegister2 = "" ;
176+ WindowBindings . AluRegister1Brush = new SolidColorBrush ( BlueColor ) ;
177+ WindowBindings . AluRegister2Brush = new SolidColorBrush ( BlueColor ) ;
178+ await Task . Delay ( ( int ) DelaySizer . Value ) ;
179+ WindowBindings . AluRegister1Brush = null ;
180+ WindowBindings . AluRegister2Brush = null ;
181+ WindowBindings . AluMethod = "↷" ;
182+ WindowBindings . AluMethodBrush = new SolidColorBrush ( BlueColor ) ;
183+ await Task . Delay ( ( int ) DelaySizer . Value ) ;
184+ WindowBindings . AluMethodBrush = null ;
185+ WindowBindings . CurrentLine = int . Parse ( args [ 0 ] ) ;
186+ break ;
187+ case "BREQ" :
188+ WindowBindings . AluRegister1 = "" ;
189+ WindowBindings . AluRegister2 = "" ;
190+ WindowBindings . AluRegister1Brush = new SolidColorBrush ( BlueColor ) ;
191+ WindowBindings . AluRegister2Brush = new SolidColorBrush ( BlueColor ) ;
192+ await Task . Delay ( ( int ) DelaySizer . Value ) ;
193+ WindowBindings . AluRegister1Brush = null ;
194+ WindowBindings . AluRegister2Brush = null ;
195+ WindowBindings . AluMethod = "=↷" ;
196+ WindowBindings . AluMethodBrush = new SolidColorBrush ( BlueColor ) ;
197+ await Task . Delay ( ( int ) DelaySizer . Value ) ;
198+ WindowBindings . AluMethodBrush = null ;
199+ if ( WindowBindings . Accumulator > 0 ) WindowBindings . CurrentLine = int . Parse ( args [ 0 ] ) ;
200+ break ;
201+ case "CP" :
202+ WindowBindings . AluRegister1 = WindowBindings . Accumulator . ToString ( ) ;
203+ WindowBindings . AluRegister1Brush = new SolidColorBrush ( BlueColor ) ;
204+ await Task . Delay ( ( int ) DelaySizer . Value ) ;
205+ WindowBindings . AluRegister1Brush = null ;
206+ WindowBindings . AluRegister2 = _memoryContainer . GetValue ( args [ 0 ] ) . ToString ( ) ;
207+ WindowBindings . AluRegister2Brush = new SolidColorBrush ( BlueColor ) ;
208+ await Task . Delay ( ( int ) DelaySizer . Value ) ;
209+ WindowBindings . AluRegister2Brush = null ;
210+ WindowBindings . AluMethod = "==" ;
211+ WindowBindings . AluMethodBrush = new SolidColorBrush ( BlueColor ) ;
212+ await Task . Delay ( ( int ) DelaySizer . Value ) ;
213+ WindowBindings . AluMethodBrush = null ;
214+ WindowBindings . Accumulator = WindowBindings . Accumulator == _memoryContainer . GetValue ( args [ 0 ] ) ? 1 : 0 ;
215+ WindowBindings . AccumulatorBrush = new SolidColorBrush ( BlueColor ) ;
216+ await Task . Delay ( ( int ) DelaySizer . Value ) ;
217+ WindowBindings . AccumulatorBrush = null ;
218+ break ;
219+ case "HALT" :
220+ WindowBindings . AluMethod = "❌" ;
221+ WindowBindings . AluMethodBrush = new SolidColorBrush ( BlueColor ) ;
222+ await Task . Delay ( ( int ) DelaySizer . Value ) ;
223+ WindowBindings . AluMethodBrush = null ;
224+ WindowBindings . IsRunning = false ;
225+ break ;
173226 default :
174227 break ;
175228 }
@@ -217,7 +270,7 @@ public async Task Start() {
217270 }
218271 if ( WindowBindings . CurrentLine >= _codeLines . Length ) WindowBindings . CurrentLine = 1 ;
219272 WindowBindings . LinesBrush = new SolidColorBrush ( Colors . LawnGreen ) ;
220- foreach ( var t in _codeLines ) {
273+ while ( WindowBindings . CurrentLine < _codeLines . Length + 1 ) {
221274 if ( ! WindowBindings . IsRunning ) {
222275 WindowBindings . IsRunning = false ;
223276 WindowBindings . LinesBrush = new SolidColorBrush ( Colors . Red ) ;
@@ -231,6 +284,7 @@ public async Task Start() {
231284 WindowBindings . AluRegister1 = "" ;
232285 WindowBindings . AluRegister2 = "" ;
233286 WindowBindings . AluMethod = "" ;
287+ WindowBindings . IsRunning = false ;
234288 return ;
235289 }
236290 await Task . Delay ( ( int ) DelaySizer . Value ) ;
0 commit comments