2022-10-15 01:53:41 +02:00
|
|
|
; dir command
|
|
|
|
|
2023-02-02 00:08:22 +01:00
|
|
|
shell_dir_command_string: data.strz "dir"
|
2022-10-15 01:53:41 +02:00
|
|
|
|
|
|
|
shell_dir_command:
|
2023-02-05 01:37:34 +01:00
|
|
|
mov r0, shell_dir_command_header_string
|
|
|
|
call print_str_to_terminal
|
|
|
|
|
2023-03-05 08:35:54 +01:00
|
|
|
call get_current_disk_id
|
|
|
|
mov r1, r0
|
2022-10-15 01:53:41 +02:00
|
|
|
mov r0, shell_dir_command_list_buffer
|
|
|
|
call ryfs_get_file_list
|
2023-01-30 23:15:51 +01:00
|
|
|
cmp r0, 0
|
|
|
|
ifz ret
|
2022-10-15 01:53:41 +02:00
|
|
|
|
|
|
|
mov r31, r0
|
|
|
|
mov r3, 0
|
|
|
|
shell_dir_command_loop:
|
|
|
|
; copy one file name from the list buffer to the file buffer
|
|
|
|
mov r0, shell_dir_command_list_buffer
|
|
|
|
add r0, r3
|
|
|
|
mov r1, shell_dir_command_file_buffer
|
2023-02-05 01:37:34 +01:00
|
|
|
mov r2, 8
|
2022-10-15 01:53:41 +02:00
|
|
|
call copy_memory_bytes
|
2023-02-05 01:37:34 +01:00
|
|
|
add r1, 8
|
2022-10-15 01:53:41 +02:00
|
|
|
mov.8 [r1], 0
|
|
|
|
|
2023-02-05 01:37:34 +01:00
|
|
|
; copy file type from the list buffer to the type buffer
|
|
|
|
mov r0, shell_dir_command_list_buffer
|
|
|
|
add r0, r3
|
|
|
|
add r0, 8
|
|
|
|
mov r1, shell_dir_command_type_buffer
|
|
|
|
mov r2, 3
|
|
|
|
call copy_memory_bytes
|
|
|
|
add r1, 3
|
|
|
|
mov.8 [r1], 0
|
|
|
|
|
|
|
|
; print the file name to the terminal
|
2022-10-15 01:53:41 +02:00
|
|
|
mov r0, shell_dir_command_file_buffer
|
|
|
|
call print_str_to_terminal
|
|
|
|
|
2023-02-05 01:37:34 +01:00
|
|
|
; space
|
|
|
|
mov r0, ' '
|
|
|
|
call print_character_to_terminal
|
|
|
|
|
|
|
|
; print the file type to the terminal
|
|
|
|
mov r0, shell_dir_command_type_buffer
|
|
|
|
call print_str_to_terminal
|
|
|
|
|
2023-02-05 02:34:20 +01:00
|
|
|
; two spaces
|
|
|
|
mov r0, ' '
|
|
|
|
call print_character_to_terminal
|
|
|
|
call print_character_to_terminal
|
|
|
|
|
|
|
|
; get and print the file size
|
2023-03-16 01:53:45 +01:00
|
|
|
; call ryfs_open instead of open because this uses the internal filename style
|
2023-03-05 08:35:54 +01:00
|
|
|
call get_current_disk_id
|
|
|
|
mov r1, r0
|
2023-02-05 02:34:20 +01:00
|
|
|
mov r0, shell_dir_command_list_buffer
|
|
|
|
add r0, r3
|
|
|
|
mov r2, shell_dir_command_temp_file_struct
|
2023-03-16 01:53:45 +01:00
|
|
|
call ryfs_open
|
2023-02-05 02:34:20 +01:00
|
|
|
cmp r0, 0
|
|
|
|
ifz jmp shell_dir_command_failed_to_open_file
|
|
|
|
mov r0, shell_dir_command_temp_file_struct
|
|
|
|
call ryfs_get_size
|
|
|
|
call print_decimal_to_terminal
|
|
|
|
shell_dir_command_failed_to_open_file:
|
2022-10-15 01:53:41 +02:00
|
|
|
; new line
|
|
|
|
mov r0, 10
|
|
|
|
call print_character_to_terminal
|
|
|
|
|
|
|
|
; point to next file name in the buffer
|
|
|
|
add r3, 11
|
|
|
|
loop shell_dir_command_loop
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
shell_dir_command_list_buffer: data.fill 0, 341
|
2023-02-05 01:37:34 +01:00
|
|
|
shell_dir_command_file_buffer: data.fill 0, 9
|
|
|
|
shell_dir_command_type_buffer: data.fill 0, 4
|
2023-02-05 02:34:20 +01:00
|
|
|
shell_dir_command_temp_file_struct: data.fill 0, 8
|
2023-02-05 01:37:34 +01:00
|
|
|
shell_dir_command_header_string:
|
|
|
|
data.8 SET_COLOR data.8 0x20 data.8 1 ; set the color to green
|
2023-02-05 02:34:20 +01:00
|
|
|
data.str "file type size" data.8 10
|
2023-02-05 01:37:34 +01:00
|
|
|
data.8 SET_COLOR data.8 0x70 data.8 1 ; set the color to white
|
|
|
|
data.8 0
|