Skip to content

Commit

Permalink
sh: Add copy command
Browse files Browse the repository at this point in the history
  • Loading branch information
ry755 committed May 5, 2024
1 parent d0290b7 commit 72a5282
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 3 deletions.
6 changes: 6 additions & 0 deletions applications/sh/commands/commands.asm
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ shell_parse_command:
call compare_string
ifz jmp shell_cmpreg_command

; copy
mov r1, shell_copy_command_string
call compare_string
ifz jmp shell_copy_command

; del
mov r1, shell_del_command_string
call compare_string
Expand Down Expand Up @@ -197,6 +202,7 @@ shell_invalid_command_string: data.str "invalid command or FXF binary" data.8 10
#include "commands/call.asm"
#include "commands/clear.asm"
#include "commands/cmp.asm"
#include "commands/copy.asm"
#include "commands/del.asm"
#include "commands/dir.asm"
#include "commands/disk.asm"
Expand Down
59 changes: 59 additions & 0 deletions applications/sh/commands/copy.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
; copy command

shell_copy_command_string: data.strz "copy"

shell_copy_command:
call shell_parse_arguments

cmp r0, 0
ifz ret
cmp r1, 0
ifz ret

mov r4, r1

call copy_get_disk_id
mov r2, shell_type_command_file_struct
call open
cmp r0, 0
ifz jmp shell_copy_command_file_not_found

mov r0, shell_type_command_file_struct
call get_size
mov r3, r0
mov r0, r4
call copy_get_disk_id
mov r2, shell_copy_command_file_struct
call create

mov r0, shell_type_command_file_struct
call get_size

mov r0, shell_type_command_file_struct
mov r1, shell_copy_command_file_struct
call copy

ret

copy_get_disk_id:
cmp.8 [r0+1], ':'
ifnz jmp copy_get_disk_id_1
movz.8 r1, [r0]
sub r1, '0'
inc r0, 2
ret
copy_get_disk_id_1:
push r0
call get_current_disk_id
mov r1, r0
pop r0
ret

shell_copy_command_file_not_found:
mov r0, shell_copy_command_file_not_found_string
call print_str_to_terminal

ret

shell_copy_command_file_struct: data.fill 0, 32
shell_copy_command_file_not_found_string: data.strz "source file not found"
6 changes: 3 additions & 3 deletions applications/sh/commands/help.asm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ shell_help_text:
data.str "command | description" data.8 10
data.str "------- | -----------" data.8 10
data.str "clear | clear the terminal contents" data.8 10
data.str "copy | copy file $0 to file $1" data.8 10
data.str "del | delete file $0" data.8 10
data.str "dir | show contents of selected disk" data.8 10
data.str "disk | select disk $0" data.8 10
Expand All @@ -31,8 +32,7 @@ shell_help_text:
data.8 10
data.str "type the name of an FXF binary to launch" data.8 10
data.str "it as a new task; the shell will suspend" data.8 10
data.str "until the launched task ends" data.8 10
data.8 10
data.str "until the launched task ends." data.8 10
data.str "prefix the name of an FXF binary with *" data.8 10
data.str "to launch it without suspending" data.8 10
data.str "to launch it without suspending." data.8 10
data.8 0

0 comments on commit 72a5282

Please sign in to comment.