diff --git a/monitor/commands/commands.asm b/monitor/commands/commands.asm index 9a6b4d8..402ffb6 100644 --- a/monitor/commands/commands.asm +++ b/monitor/commands/commands.asm @@ -24,6 +24,11 @@ monitor_shell_parse_command: call compare_string ifz jmp monitor_shell_list_command + ; load + mov r1, monitor_shell_load_command_string + call compare_string + ifz jmp monitor_shell_load_command + ; set.8 mov r1, monitor_shell_set8_command_string call compare_string @@ -53,4 +58,5 @@ monitor_shell_invalid_command_string: data.str "invalid command" data.8 10 data. #include "monitor/commands/help.asm" #include "monitor/commands/jump.asm" #include "monitor/commands/list.asm" + #include "monitor/commands/load.asm" #include "monitor/commands/set.asm" diff --git a/monitor/commands/help.asm b/monitor/commands/help.asm index e603d0c..38d16e3 100644 --- a/monitor/commands/help.asm +++ b/monitor/commands/help.asm @@ -15,5 +15,6 @@ monitor_shell_help_text: 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 "load | load disk $0's sector $1 to buffer at address $2 of size $3 sectors" 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/load.asm b/monitor/commands/load.asm new file mode 100644 index 0000000..e1bb815 --- /dev/null +++ b/monitor/commands/load.asm @@ -0,0 +1,49 @@ +; jump command + +monitor_shell_load_command_string: data.strz "load" + +monitor_shell_load_command: + call monitor_shell_parse_arguments + + ; r0: pointer to disk id string + ; r1: pointer to source sector number string + ; r2: pointer to destination address string + ; r3: pointer to number of sectors string + + push r3 + push r2 + push r1 + mov r1, 16 + call string_to_int + mov r10, r0 + pop r0 + mov r1, 16 + call string_to_int + mov r11, r0 + pop r0 + mov r1, 16 + call string_to_int + mov r12, r0 + pop r0 + mov r1, 16 + call string_to_int + mov r13, r0 + + ; r10: disk id + ; r11: source sector number + ; r12: destination address + ; r13: number of sectors + + mov r31, r13 + cmp r31, 0 + ifz ret + mov r0, r11 + mov r1, r10 + mov r2, r12 +monitor_shell_load_command_loop: + call read_sector + inc r0 + add r2, 512 + loop monitor_shell_load_command_loop + + ret