From d08dfd527da493bd318205deecbdb74cbc3c952f Mon Sep 17 00:00:00 2001 From: Ry Date: Sun, 1 May 2022 18:03:04 -0700 Subject: [PATCH] monitor: Add set.SZ command --- monitor/commands/commands.asm | 16 ++++++++ monitor/commands/help.asm | 1 + monitor/commands/set.asm | 74 +++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 monitor/commands/set.asm diff --git a/monitor/commands/commands.asm b/monitor/commands/commands.asm index 63df7b9..f267e85 100644 --- a/monitor/commands/commands.asm +++ b/monitor/commands/commands.asm @@ -14,6 +14,21 @@ monitor_shell_parse_command: call compare_string ifz jmp monitor_shell_help_command + ; set.8 + mov r1, monitor_shell_set8_command_string + call compare_string + ifz jmp monitor_shell_set8_command + + ; set.16 + mov r1, monitor_shell_set16_command_string + call compare_string + ifz jmp monitor_shell_set16_command + + ; set.32 + mov r1, monitor_shell_set32_command_string + call compare_string + ifz jmp monitor_shell_set32_command + ; invalid command mov r0, monitor_shell_invalid_command_string call print_string_to_monitor @@ -25,3 +40,4 @@ monitor_shell_invalid_command_string: data.str "invalid command" data.8 10 data. ; all commands #include "monitor/commands/exit.asm" #include "monitor/commands/help.asm" + #include "monitor/commands/set.asm" diff --git a/monitor/commands/help.asm b/monitor/commands/help.asm index 1c93d5a..3fb8597 100644 --- a/monitor/commands/help.asm +++ b/monitor/commands/help.asm @@ -12,4 +12,5 @@ monitor_shell_help_text: data.str "------- | -----------" data.8 10 data.str "exit | exit the monitor" data.8 10 data.str "help | display this help text" data.8 10 + data.str "set.SZ | set [$0] to $1; equivalent to `mov.SZ [$0], $1`" data.8 10 data.8 0 diff --git a/monitor/commands/set.asm b/monitor/commands/set.asm new file mode 100644 index 0000000..cbec782 --- /dev/null +++ b/monitor/commands/set.asm @@ -0,0 +1,74 @@ +; set command + +monitor_shell_set8_command_string: data.str "set.8" data.8 0 +monitor_shell_set16_command_string: data.str "set.16" data.8 0 +monitor_shell_set32_command_string: data.str "set.32" data.8 0 + +monitor_shell_set8_command: + call monitor_shell_parse_arguments + + ; r0: pointer to address string + ; r1: pointer to byte string + + push r1 + mov r1, 16 + call string_to_int + mov r10, r0 + + pop r0 + mov r1, 16 + call string_to_int + mov r11, r0 + + ; r10: address + ; r11: byte + + mov.8 [r10], r11 + + ret + +monitor_shell_set16_command: + call monitor_shell_parse_arguments + + ; r0: pointer to address string + ; r1: pointer to half string + + push r1 + mov r1, 16 + call string_to_int + mov r10, r0 + + pop r0 + mov r1, 16 + call string_to_int + mov r11, r0 + + ; r10: address + ; r11: half + + mov.16 [r10], r11 + + ret + +monitor_shell_set32_command: + call monitor_shell_parse_arguments + + ; r0: pointer to address string + ; r1: pointer to word string + + push r1 + mov r1, 16 + call string_to_int + mov r10, r0 + + pop r0 + mov r1, 16 + call string_to_int + mov r11, r0 + + ; r10: address + ; r11: word + + mov [r10], r11 + + ret