Monitor DUMP prints bytes with the standard hex editor layout
This commit is contained in:
parent
43f04da6f1
commit
d0afda5c4e
@ -76,7 +76,9 @@ monitor_help:
|
|||||||
call Print
|
call Print
|
||||||
jp monitor_main_loop
|
jp monitor_main_loop
|
||||||
|
|
||||||
monitor_dump: ; Test with DUMP 0x00A0 (contains text)
|
; Asks the user for a memory position and shows the following 64 bytes of memory
|
||||||
|
; @uses a, b, c, d, e, h, l
|
||||||
|
monitor_dump:
|
||||||
ld bc, MON_COMMAND_DUMP + 1 ; autocomplete command
|
ld bc, MON_COMMAND_DUMP + 1 ; autocomplete command
|
||||||
call Print
|
call Print
|
||||||
; Now read the address from the user
|
; Now read the address from the user
|
||||||
@ -86,36 +88,76 @@ monitor_dump: ; Test with DUMP 0x00A0 (contains text)
|
|||||||
; now start displaying bytes from memory
|
; now start displaying bytes from memory
|
||||||
ld e, MON_DUMP_BYTES_LINES ; the number of lines to display
|
ld e, MON_DUMP_BYTES_LINES ; the number of lines to display
|
||||||
monitor_dump_show_bytes_loop:
|
monitor_dump_show_bytes_loop:
|
||||||
ld d, MON_DUMP_BYTES_PER_LINE ; the number of bytes per line to display
|
ld d, MON_DUMP_BYTES_PER_LINE*2 ; the number of bytes per line to display (*2 as we display two times the same byte: once hex and once ascii)
|
||||||
; Print current address
|
; Print current address
|
||||||
ld a, h
|
ld a, h
|
||||||
call monitor_printHexByte
|
call monitor_printHexByte
|
||||||
ld a, l
|
ld a, l
|
||||||
call monitor_printHexByte
|
call monitor_printHexByte
|
||||||
; print two spaces
|
; print four spaces
|
||||||
ld a, 32
|
ld a, 32
|
||||||
call Printc
|
call Printc
|
||||||
call Printc
|
call Printc
|
||||||
monitor_dump_show_bytes_line_loop:
|
call Printc
|
||||||
; print character at mem position
|
call Printc
|
||||||
ld a, (hl)
|
monitor_dump_show_bytes_line_loop: ; counts down from 15 to 0
|
||||||
; print hex byte
|
ld a, d
|
||||||
call monitor_printHexByte
|
sub MON_DUMP_BYTES_PER_LINE + 1
|
||||||
; print space
|
jp m, monitor_dump_show_bytes_line_loop_ascii ; jp if
|
||||||
ld a, 32
|
; if position is 8 to 15, print hex value at mem position
|
||||||
call Printc
|
ld a, (hl)
|
||||||
; print ascii
|
; print hex byte
|
||||||
ld a, (hl)
|
call monitor_printHexByte
|
||||||
call monitor_printAsciiByte
|
; print space
|
||||||
; print two spaces
|
ld a, 32
|
||||||
ld a, 32
|
call Printc
|
||||||
call Printc
|
; if position is 4, print a second space (to group nibbles)
|
||||||
call Printc
|
ld a, d
|
||||||
; move to next mem position
|
cp MON_DUMP_BYTES_PER_LINE / 2 + MON_DUMP_BYTES_PER_LINE + 1
|
||||||
inc hl
|
jp nz, no_second_space
|
||||||
; decrement counter: if non zero continue loop
|
; print second space
|
||||||
dec d
|
ld a, 32
|
||||||
jp nz, monitor_dump_show_bytes_line_loop
|
call Printc
|
||||||
|
no_second_space:
|
||||||
|
; move to next mem position
|
||||||
|
inc hl
|
||||||
|
; decrement "nth byte on the line" counter
|
||||||
|
dec d
|
||||||
|
jp monitor_dump_show_bytes_line_loop
|
||||||
|
; if position is 0 to 7, print ascii
|
||||||
|
monitor_dump_show_bytes_line_loop_ascii:
|
||||||
|
; is this the first ascii char printed in this line?
|
||||||
|
ld a, d
|
||||||
|
cp MON_DUMP_BYTES_PER_LINE
|
||||||
|
jp nz, no_mempos_decr ; no need to decrement, already done
|
||||||
|
; do this only once: printing hex values we advanced the counter by 8 positions. Bring it back.
|
||||||
|
ld bc, MON_DUMP_BYTES_PER_LINE
|
||||||
|
sbc hl, bc
|
||||||
|
; print 3 spaces to separate hex from ascii
|
||||||
|
ld a, 32
|
||||||
|
call Printc
|
||||||
|
call Printc
|
||||||
|
call Printc
|
||||||
|
no_mempos_decr:
|
||||||
|
; print ascii
|
||||||
|
ld a, (hl)
|
||||||
|
call monitor_printAsciiByte
|
||||||
|
; print space
|
||||||
|
ld a, 32
|
||||||
|
call Printc
|
||||||
|
; if position is 12 (8+4), print a second space (to group nibbles)
|
||||||
|
ld a, d
|
||||||
|
cp MON_DUMP_BYTES_PER_LINE / 2 + 1
|
||||||
|
jp nz, no_second_space2
|
||||||
|
; print second space
|
||||||
|
ld a, 32
|
||||||
|
call Printc
|
||||||
|
no_second_space2:
|
||||||
|
; move to next mem position
|
||||||
|
inc hl
|
||||||
|
; decrement counter: if non zero continue loop
|
||||||
|
dec d
|
||||||
|
jp nz, monitor_dump_show_bytes_line_loop
|
||||||
; print newline
|
; print newline
|
||||||
ld a, 10
|
ld a, 10
|
||||||
call Printc
|
call Printc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user