|
40 | 40 |
|
41 | 41 | INSTRUCTION = ( |
42 | 42 | "\nEnter\n" |
43 | | - f" {BLU}s{DEF}tep [count=1] make count of steps\n" |
44 | | - f" {BLU}c{DEF}ontinue continue until breakpoint or halt\n" |
45 | | - f" {BLU}b{DEF}reakpoint [addr] set/unset breakpoint at addr\n" |
46 | | - f" {BLU}m{DEF}emory <begin> <end> view random access memory\n" |
47 | | - f" {BLU}rs{DEF}tep [count=1] make count of steps in reverse direction\n" |
48 | | - f" {BLU}rc{DEF}ontinue continue until breakpoint or cycle=0 in reverse direction\n" |
| 43 | + f" {BLU}s{DEF}tep [count=1] make count of steps\n" |
| 44 | + f" {BLU}c{DEF}ontinue continue until breakpoint or halt\n" |
| 45 | + f" {BLU}b{DEF}reakpoint [addr] set/unset breakpoint at addr\n" |
| 46 | + f" {BLU}m{DEF}emory <begin> <end> view random access memory\n" |
| 47 | + f" {BLU}rs{DEF}tep [count=1] make count of steps in reverse direction\n" |
| 48 | + f" {BLU}rc{DEF}ontinue continue until breakpoint or cycle=0 in reverse direction\n" |
49 | 49 | f" {BLU}q{DEF}uit\n" |
50 | 50 | ) |
51 | 51 |
|
|
65 | 65 | debug_cmd = stepc | rstepc | continuec | rcontinuec | memoryc | quitc | breakc |
66 | 66 |
|
67 | 67 |
|
| 68 | +def tabulate(data: list[tuple[str, str, str]]) -> str: |
| 69 | + elem_width = max(len(x) for _, x, _ in data) |
| 70 | + return "\n".join( |
| 71 | + f" {style}{elem.ljust(elem_width)} {descr}{DEF}{NUND}{BDEF}" |
| 72 | + for style, elem, descr in data |
| 73 | + ) |
| 74 | + |
| 75 | + |
68 | 76 | class Ide: |
69 | 77 | cpu: Cpu |
70 | 78 | max_register_hex: Final[int] |
@@ -403,15 +411,22 @@ def run(self) -> int: |
403 | 411 | ) |
404 | 412 | raise ValueError(msg) |
405 | 413 |
|
| 414 | + addr = Cell(0, bits=self.cpu.ram.address_bits) |
406 | 415 | cell = Cell(0, bits=self.cpu.ram.word_bits) |
407 | 416 | printf( |
408 | 417 | "Welcome to interactive debug mode\n" |
409 | 418 | "Legend:\n" |
410 | | - f" {cell.hex()} usual memory cell\n" |
411 | | - f" {UND}{cell.hex()} next command{NUND}\n" |
412 | | - f" {GRE}{cell.hex()} updated by last command{DEF}\n" |
413 | | - f" {YEL}{cell.hex()} dirty unset memory{DEF}\n" |
414 | | - f" {BSEL}{cell.hex()} breakpoint{BDEF}\n" |
| 419 | + + tabulate( |
| 420 | + [ |
| 421 | + ("", f"{addr}:", "address in ram"), |
| 422 | + ("", cell.hex(), "filled memory cell"), |
| 423 | + (UND, cell.hex(), "next command"), |
| 424 | + (GRE, cell.hex(), "updated by last command"), |
| 425 | + (YEL, cell.hex(), "dirty unsed memory"), |
| 426 | + (BSEL, cell.hex(), "breakpoint"), |
| 427 | + ] |
| 428 | + ) |
| 429 | + + "\n" |
415 | 430 | ) |
416 | 431 | self.dump_state() |
417 | 432 |
|
|
0 commit comments