sh/dir: Show file sizes
This commit is contained in:
parent
6c4790cd5f
commit
8bfd66941d
|
@ -46,6 +46,23 @@ shell_dir_command_loop:
|
||||||
mov r0, shell_dir_command_type_buffer
|
mov r0, shell_dir_command_type_buffer
|
||||||
call print_str_to_terminal
|
call print_str_to_terminal
|
||||||
|
|
||||||
|
; two spaces
|
||||||
|
mov r0, ' '
|
||||||
|
call print_character_to_terminal
|
||||||
|
call print_character_to_terminal
|
||||||
|
|
||||||
|
; get and print the file size
|
||||||
|
mov r0, shell_dir_command_list_buffer
|
||||||
|
add r0, r3
|
||||||
|
movz.8 r1, [shell_current_disk]
|
||||||
|
mov r2, shell_dir_command_temp_file_struct
|
||||||
|
call open
|
||||||
|
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:
|
||||||
; new line
|
; new line
|
||||||
mov r0, 10
|
mov r0, 10
|
||||||
call print_character_to_terminal
|
call print_character_to_terminal
|
||||||
|
@ -59,8 +76,9 @@ shell_dir_command_loop:
|
||||||
shell_dir_command_list_buffer: data.fill 0, 341
|
shell_dir_command_list_buffer: data.fill 0, 341
|
||||||
shell_dir_command_file_buffer: data.fill 0, 9
|
shell_dir_command_file_buffer: data.fill 0, 9
|
||||||
shell_dir_command_type_buffer: data.fill 0, 4
|
shell_dir_command_type_buffer: data.fill 0, 4
|
||||||
|
shell_dir_command_temp_file_struct: data.fill 0, 8
|
||||||
shell_dir_command_header_string:
|
shell_dir_command_header_string:
|
||||||
data.8 SET_COLOR data.8 0x20 data.8 1 ; set the color to green
|
data.8 SET_COLOR data.8 0x20 data.8 1 ; set the color to green
|
||||||
data.str "file type" data.8 10
|
data.str "file type size" data.8 10
|
||||||
data.8 SET_COLOR data.8 0x70 data.8 1 ; set the color to white
|
data.8 SET_COLOR data.8 0x70 data.8 1 ; set the color to white
|
||||||
data.8 0
|
data.8 0
|
||||||
|
|
|
@ -272,6 +272,38 @@ print_str_to_terminal_loop:
|
||||||
pop r0
|
pop r0
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
print_decimal_to_terminal:
|
||||||
|
push r0
|
||||||
|
push r10
|
||||||
|
push r11
|
||||||
|
push r12
|
||||||
|
push r13
|
||||||
|
mov r10, rsp
|
||||||
|
mov r12, r0
|
||||||
|
|
||||||
|
push.8 0
|
||||||
|
print_decimal_to_terminal_loop:
|
||||||
|
push r12
|
||||||
|
div r12, 10
|
||||||
|
pop r13
|
||||||
|
rem r13, 10
|
||||||
|
mov r11, r13
|
||||||
|
add r11, '0'
|
||||||
|
push.8 r11
|
||||||
|
cmp r12, 0
|
||||||
|
ifnz jmp print_decimal_to_terminal_loop
|
||||||
|
print_decimal_to_terminal_print:
|
||||||
|
mov r0, rsp
|
||||||
|
call print_str_to_terminal
|
||||||
|
|
||||||
|
mov rsp, r10
|
||||||
|
pop r13
|
||||||
|
pop r12
|
||||||
|
pop r11
|
||||||
|
pop r10
|
||||||
|
pop r0
|
||||||
|
ret
|
||||||
|
|
||||||
shell_text_buf_bottom: data.fill 0, 512
|
shell_text_buf_bottom: data.fill 0, 512
|
||||||
shell_text_buf_top:
|
shell_text_buf_top:
|
||||||
shell_text_buf_ptr: data.32 0 ; pointer to the current input character
|
shell_text_buf_ptr: data.32 0 ; pointer to the current input character
|
||||||
|
|
Loading…
Reference in New Issue
Block a user