monitor: Add set.SZ command

This commit is contained in:
Ry 2022-05-01 18:03:04 -07:00
parent 6516128ba3
commit d08dfd527d
3 changed files with 91 additions and 0 deletions

View File

@ -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"

View File

@ -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

74
monitor/commands/set.asm Normal file
View File

@ -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