monitor: Add jump and list commands
This commit is contained in:
parent
9dc92e506e
commit
3247a29d2a
|
@ -14,6 +14,16 @@ monitor_shell_parse_command:
|
||||||
call compare_string
|
call compare_string
|
||||||
ifz jmp monitor_shell_help_command
|
ifz jmp monitor_shell_help_command
|
||||||
|
|
||||||
|
; jump
|
||||||
|
mov r1, monitor_shell_jump_command_string
|
||||||
|
call compare_string
|
||||||
|
ifz jmp monitor_shell_jump_command
|
||||||
|
|
||||||
|
; list
|
||||||
|
mov r1, monitor_shell_list_command_string
|
||||||
|
call compare_string
|
||||||
|
ifz jmp monitor_shell_list_command
|
||||||
|
|
||||||
; set.8
|
; set.8
|
||||||
mov r1, monitor_shell_set8_command_string
|
mov r1, monitor_shell_set8_command_string
|
||||||
call compare_string
|
call compare_string
|
||||||
|
@ -40,4 +50,6 @@ monitor_shell_invalid_command_string: data.str "invalid command" data.8 10 data.
|
||||||
; all commands
|
; all commands
|
||||||
#include "monitor/commands/exit.asm"
|
#include "monitor/commands/exit.asm"
|
||||||
#include "monitor/commands/help.asm"
|
#include "monitor/commands/help.asm"
|
||||||
|
#include "monitor/commands/jump.asm"
|
||||||
|
#include "monitor/commands/list.asm"
|
||||||
#include "monitor/commands/set.asm"
|
#include "monitor/commands/set.asm"
|
||||||
|
|
|
@ -12,5 +12,7 @@ monitor_shell_help_text:
|
||||||
data.str "------- | -----------" data.8 10
|
data.str "------- | -----------" data.8 10
|
||||||
data.str "exit | exit the monitor" data.8 10
|
data.str "exit | exit the monitor" data.8 10
|
||||||
data.str "help | display this help text" data.8 10
|
data.str "help | display this help text" data.8 10
|
||||||
|
data.str "jump | jump to address $0" data.8 10
|
||||||
|
data.str "list | list memory contents starting at address $0" data.8 10
|
||||||
data.str "set.SZ | set [$0] to $1; equivalent to `mov.SZ [$0], $1`" data.8 10
|
data.str "set.SZ | set [$0] to $1; equivalent to `mov.SZ [$0], $1`" data.8 10
|
||||||
data.8 0
|
data.8 0
|
||||||
|
|
14
monitor/commands/jump.asm
Normal file
14
monitor/commands/jump.asm
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
; jump command
|
||||||
|
|
||||||
|
monitor_shell_jump_command_string: data.str "jump" data.8 0
|
||||||
|
|
||||||
|
monitor_shell_jump_command:
|
||||||
|
call monitor_shell_parse_arguments
|
||||||
|
mov r1, 16
|
||||||
|
call string_to_int
|
||||||
|
|
||||||
|
; r0: address
|
||||||
|
|
||||||
|
call r0
|
||||||
|
|
||||||
|
ret
|
69
monitor/commands/list.asm
Normal file
69
monitor/commands/list.asm
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
; list command
|
||||||
|
|
||||||
|
monitor_shell_list_command_string: data.str "list" data.8 0
|
||||||
|
|
||||||
|
monitor_shell_list_command:
|
||||||
|
mov r0, monitor_shell_list_text
|
||||||
|
call print_string_to_monitor
|
||||||
|
|
||||||
|
call monitor_shell_parse_arguments
|
||||||
|
mov r1, 16
|
||||||
|
call string_to_int
|
||||||
|
|
||||||
|
; r0: starting address
|
||||||
|
|
||||||
|
mov r10, r0
|
||||||
|
mov r31, 16 ; line counter
|
||||||
|
monitor_shell_list_command_line_loop:
|
||||||
|
mov r30, 16 ; byte counter, 16 bytes per line
|
||||||
|
; print current address
|
||||||
|
mov r0, r10
|
||||||
|
call print_hex_word_to_monitor
|
||||||
|
mov r0, ' '
|
||||||
|
call print_character_to_monitor
|
||||||
|
mov r0, '|'
|
||||||
|
call print_character_to_monitor
|
||||||
|
mov r0, ' '
|
||||||
|
call print_character_to_monitor
|
||||||
|
monitor_shell_list_command_byte_loop:
|
||||||
|
movz.8 r0, [r10]
|
||||||
|
call print_hex_byte_to_monitor
|
||||||
|
mov r0, ' '
|
||||||
|
call print_character_to_monitor
|
||||||
|
inc r10
|
||||||
|
dec r30
|
||||||
|
ifnz jmp monitor_shell_list_command_byte_loop
|
||||||
|
|
||||||
|
mov r0, '|'
|
||||||
|
call print_character_to_monitor
|
||||||
|
mov r0, ' '
|
||||||
|
call print_character_to_monitor
|
||||||
|
|
||||||
|
mov r29, 16
|
||||||
|
sub r10, 16
|
||||||
|
monitor_shell_list_command_ascii_loop:
|
||||||
|
movz.8 r0, [r10]
|
||||||
|
cmp r0, ' '
|
||||||
|
iflt jmp monitor_shell_list_command_ascii_loop_skip_char
|
||||||
|
cmp r0, '~'
|
||||||
|
ifgt jmp monitor_shell_list_command_ascii_loop_skip_char
|
||||||
|
|
||||||
|
call print_character_to_monitor
|
||||||
|
inc r10
|
||||||
|
dec r29
|
||||||
|
ifnz jmp monitor_shell_list_command_ascii_loop
|
||||||
|
jmp monitor_shell_list_command_ascii_loop_done
|
||||||
|
monitor_shell_list_command_ascii_loop_skip_char:
|
||||||
|
mov r0, '.'
|
||||||
|
call print_character_to_monitor
|
||||||
|
inc r10
|
||||||
|
dec r29
|
||||||
|
ifnz jmp monitor_shell_list_command_ascii_loop
|
||||||
|
monitor_shell_list_command_ascii_loop_done:
|
||||||
|
mov r0, 10
|
||||||
|
call print_character_to_monitor
|
||||||
|
loop monitor_shell_list_command_line_loop
|
||||||
|
|
||||||
|
ret
|
||||||
|
|
||||||
|
monitor_shell_list_text: data.str "address | x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF | ASCII" data.8 10 data.8 0
|
|
@ -19,6 +19,66 @@ print_string_to_monitor_loop:
|
||||||
pop r0
|
pop r0
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; print a hex word to the monitor
|
||||||
|
; inputs:
|
||||||
|
; r0: value
|
||||||
|
; outputs:
|
||||||
|
print_hex_word_to_monitor:
|
||||||
|
push r10
|
||||||
|
push r11
|
||||||
|
push r12
|
||||||
|
push r31
|
||||||
|
|
||||||
|
mov r10, r0
|
||||||
|
mov r31, 8
|
||||||
|
print_hex_word_to_monitor_loop:
|
||||||
|
rol r10, 4
|
||||||
|
movz.16 r11, r10
|
||||||
|
and r11, 0x0F
|
||||||
|
mov r12, draw_hex_generic_characters
|
||||||
|
add r12, r11
|
||||||
|
movz.8 r0, [r12]
|
||||||
|
call print_character_to_monitor
|
||||||
|
add r1, r6
|
||||||
|
loop print_hex_word_to_monitor_loop
|
||||||
|
call redraw_monitor_console_line
|
||||||
|
|
||||||
|
pop r31
|
||||||
|
pop r12
|
||||||
|
pop r11
|
||||||
|
pop r10
|
||||||
|
ret
|
||||||
|
|
||||||
|
; print a hex byte to the monitor
|
||||||
|
; inputs:
|
||||||
|
; r0: value
|
||||||
|
; outputs:
|
||||||
|
print_hex_byte_to_monitor:
|
||||||
|
push r10
|
||||||
|
push r11
|
||||||
|
push r12
|
||||||
|
push r31
|
||||||
|
|
||||||
|
movz.8 r10, r0
|
||||||
|
mov r31, 2
|
||||||
|
print_hex_byte_to_monitor_loop:
|
||||||
|
rol.8 r10, 4
|
||||||
|
movz.16 r11, r10
|
||||||
|
and r11, 0x0F
|
||||||
|
mov r12, draw_hex_generic_characters
|
||||||
|
add r12, r11
|
||||||
|
movz.8 r0, [r12]
|
||||||
|
call print_character_to_monitor
|
||||||
|
add r1, r6
|
||||||
|
loop print_hex_byte_to_monitor_loop
|
||||||
|
call redraw_monitor_console_line
|
||||||
|
|
||||||
|
pop r31
|
||||||
|
pop r12
|
||||||
|
pop r11
|
||||||
|
pop r10
|
||||||
|
ret
|
||||||
|
|
||||||
; print a single character to the monitor
|
; print a single character to the monitor
|
||||||
; inputs:
|
; inputs:
|
||||||
; r0: character
|
; r0: character
|
||||||
|
|
Loading…
Reference in New Issue
Block a user