@@ -174,13 +174,13 @@ public void ResetRegs()
174174 state . stdout = "" ;
175175 }
176176
177- public void Run ( bool verbose = false )
177+ public void Run ( bool verbose = false , bool showaddress = false )
178178 {
179179 ResetRegs ( ) ;
180- RunUntil ( state . memoryUsed , verbose ) ;
180+ RunUntil ( state . memoryUsed , verbose , showaddress ) ;
181181 }
182182
183- internal bool RunUntil ( int stop_pc_at , bool verbose = false )
183+ internal bool RunUntil ( int stop_pc_at , bool verbose = false , bool showaddress = false )
184184 {
185185
186186 if ( state . memoryUsed == 0 )
@@ -208,7 +208,7 @@ internal bool RunUntil(int stop_pc_at, bool verbose = false)
208208 S8Instruction s8 = new S8Instruction ( opcode , param ) ;
209209 state . pc += 2 ;
210210
211- if ( ! ExecuteInstruction ( s8 , verbose ) )
211+ if ( ! ExecuteInstruction ( s8 , verbose , showaddress ) )
212212 {
213213 state . crashed = true ;
214214 }
@@ -226,9 +226,9 @@ public bool Step(int steps=1)
226226 }
227227
228228
229- public bool ExecuteInstruction ( S8Instruction instr , bool verbose = false )
229+ public bool ExecuteInstruction ( S8Instruction instr , bool verbose = false , bool showaddress = false )
230230 {
231- if ( verbose ) VerboseLogLine ( instr ) ;
231+ if ( verbose ) VerboseLogLine ( instr , showaddress ) ;
232232 // HALT
233233 if ( instr . operationClass == 0x0 ) return false ;
234234
@@ -379,12 +379,12 @@ public bool ExecuteInstruction(S8Instruction instr, bool verbose = false)
379379 }
380380
381381 public byte [ ] prevRegs = new byte [ 16 ] ;
382- private void VerboseLogLine ( S8Instruction instr )
382+ private void VerboseLogLine ( S8Instruction instr , bool showaddress )
383383 {
384384 var regs = GetChangedRegs ( ) ;
385385 if ( ! string . IsNullOrEmpty ( regs ) ) Console . WriteLine ( regs ) ;
386- instr . DecodeInstruction ( ) ;
387- Console . WriteLine ( instr . DecodedInstruction ) ;
386+ instr . DecodeInstruction ( ) ;
387+ Console . WriteLine ( instr . Instruction2Text ( state . pc , showaddress ) ) ;
388388 prevRegs = ( byte [ ] ) state . regs . Clone ( ) ;
389389 }
390390
@@ -394,7 +394,7 @@ private string GetChangedRegs()
394394 for ( int i = 0 ; i < 15 ; i ++ )
395395 {
396396 if ( prevRegs [ i ] != state . regs [ i ] )
397- changed += $ "[r{ i } : { prevRegs [ i ] } -> { state . regs [ i ] } ]";
397+ changed += $ "[r{ i } : 0x { prevRegs [ i ] : X2 } -> 0x { state . regs [ i ] : X2 } ]"; // #TODO Make it hex -> "X2"
398398 }
399399 return changed ;
400400 }
0 commit comments