Skip to content

Commit ac078e5

Browse files
committed
Show the frame pointer in the debugger prompt
1 parent 8682699 commit ac078e5

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

src/stackvm.cr

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ module StackVM
99
include Utils
1010

1111
debug_program = Array(UInt8 | UInt16 | UInt32 | UInt64){
12-
LOADI, DWORD, 0xff_u32,
13-
LOADI, DWORD, 0xff_u32,
14-
RPOP, R0 | M_C,
15-
RPOP, R0 | M_C | M_H,
12+
LOADI, QWORD, 0xff_u64,
13+
LOADI, QWORD, 0xff_u64,
14+
RPOP, R0,
15+
RPOP, R1,
16+
RPUSH, R0,
17+
RPUSH, R1,
1618
HALT
1719
}
1820

src/stackvm/machine/debugger.cr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ module StackVM::Machine::Utils
2020
loop do
2121
ip = @machine.regs[Reg::IP]
2222
address = render_hex @machine.regs[Reg::IP], 8, :red
23+
frame_pointer = render_hex @machine.regs[Reg::FP], 8, :green
2324

24-
command = Readline.readline "[#{address}]> ", true
25+
command = Readline.readline "[#{frame_pointer}:#{address}]> ", true
2526

2627
case command
2728
when "h", "help"

0 commit comments

Comments
 (0)