commit
e1da81f314
|
@ -8,6 +8,7 @@ shell_task_return:
|
||||||
call shell_clear_buffer
|
call shell_clear_buffer
|
||||||
call shell_print_prompt
|
call shell_print_prompt
|
||||||
shell_task_loop:
|
shell_task_loop:
|
||||||
|
mov r0, 1
|
||||||
mov r1, [shell_terminal_stream_struct_ptr]
|
mov r1, [shell_terminal_stream_struct_ptr]
|
||||||
mov r2, shell_char_buffer
|
mov r2, shell_char_buffer
|
||||||
call read
|
call read
|
||||||
|
@ -16,7 +17,6 @@ shell_task_loop:
|
||||||
cmp.8 r0, 0
|
cmp.8 r0, 0
|
||||||
ifnz call shell_task_parse_key
|
ifnz call shell_task_parse_key
|
||||||
|
|
||||||
call yield_task
|
|
||||||
rjmp shell_task_loop
|
rjmp shell_task_loop
|
||||||
|
|
||||||
shell_task_parse_key:
|
shell_task_parse_key:
|
||||||
|
@ -233,16 +233,19 @@ shell_clear_buffer:
|
||||||
; outputs:
|
; outputs:
|
||||||
; none
|
; none
|
||||||
print_character_to_terminal:
|
print_character_to_terminal:
|
||||||
|
push r0
|
||||||
push r1
|
push r1
|
||||||
push r2
|
push r2
|
||||||
|
|
||||||
mov.8 [shell_char_buffer], r0
|
mov.8 [shell_char_buffer], r0
|
||||||
|
mov r0, 1
|
||||||
mov r1, [shell_terminal_stream_struct_ptr]
|
mov r1, [shell_terminal_stream_struct_ptr]
|
||||||
mov r2, shell_char_buffer
|
mov r2, shell_char_buffer
|
||||||
call write
|
call write
|
||||||
|
|
||||||
pop r2
|
pop r2
|
||||||
pop r1
|
pop r1
|
||||||
|
pop r0
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; print a string to the terminal
|
; print a string to the terminal
|
||||||
|
@ -257,6 +260,7 @@ print_str_to_terminal:
|
||||||
mov r1, [shell_terminal_stream_struct_ptr]
|
mov r1, [shell_terminal_stream_struct_ptr]
|
||||||
mov r2, r0
|
mov r2, r0
|
||||||
print_str_to_terminal_loop:
|
print_str_to_terminal_loop:
|
||||||
|
mov r0, 1
|
||||||
call write
|
call write
|
||||||
inc r2
|
inc r2
|
||||||
cmp.8 [r2], 0x00
|
cmp.8 [r2], 0x00
|
||||||
|
|
|
@ -40,7 +40,9 @@ event_loop_end:
|
||||||
call is_task_id_used
|
call is_task_id_used
|
||||||
ifz jmp close_window
|
ifz jmp close_window
|
||||||
call yield_task
|
call yield_task
|
||||||
mov.8 [read_buffer], 0
|
cmp.8 [read_buffer_ack], 1
|
||||||
|
ifz mov.8 [read_buffer], 0
|
||||||
|
ifz mov.8 [read_buffer_ack], 0
|
||||||
rjmp event_loop
|
rjmp event_loop
|
||||||
|
|
||||||
mouse_down:
|
mouse_down:
|
||||||
|
|
|
@ -9,6 +9,8 @@ stream_write_to_terminal:
|
||||||
|
|
||||||
stream_get_input:
|
stream_get_input:
|
||||||
mov r0, [read_buffer]
|
mov r0, [read_buffer]
|
||||||
|
mov [read_buffer_ack], 1
|
||||||
ret
|
ret
|
||||||
|
|
||||||
read_buffer: data.32 0
|
read_buffer: data.32 0
|
||||||
|
read_buffer_ack: data.32 0
|
||||||
|
|
|
@ -53,11 +53,11 @@ tell:
|
||||||
|
|
||||||
; read specified number of bytes into the specified buffer
|
; read specified number of bytes into the specified buffer
|
||||||
; inputs:
|
; inputs:
|
||||||
; r0: number of bytes to read (ignored if file struct is a stream)
|
; r0: number of bytes to read
|
||||||
; r1: pointer to file struct
|
; r1: pointer to file struct
|
||||||
; r2: pointer to destination buffer (always 4 bytes if file struct is a stream)
|
; r2: pointer to destination buffer
|
||||||
; outputs:
|
; outputs:
|
||||||
; none
|
; r0: number of bytes left to read (streams can read short)
|
||||||
read:
|
read:
|
||||||
push r3
|
push r3
|
||||||
push r1
|
push r1
|
||||||
|
@ -73,6 +73,26 @@ read:
|
||||||
pop r3
|
pop r3
|
||||||
ret
|
ret
|
||||||
stream_read:
|
stream_read:
|
||||||
|
push r1
|
||||||
|
push r2
|
||||||
|
|
||||||
|
stream_read_loop:
|
||||||
|
call stream_read_char
|
||||||
|
call yield_task
|
||||||
|
|
||||||
|
cmp.8 [r2], 0
|
||||||
|
ifz jmp stream_read_out
|
||||||
|
|
||||||
|
inc r2
|
||||||
|
dec r0
|
||||||
|
ifnz jmp stream_read_loop
|
||||||
|
|
||||||
|
stream_read_out:
|
||||||
|
pop r2
|
||||||
|
pop r1
|
||||||
|
ret
|
||||||
|
|
||||||
|
stream_read_char:
|
||||||
push r0
|
push r0
|
||||||
push r1
|
push r1
|
||||||
push r2
|
push r2
|
||||||
|
@ -83,7 +103,7 @@ stream_read:
|
||||||
|
|
||||||
; put the result into [r2]
|
; put the result into [r2]
|
||||||
pop r2
|
pop r2
|
||||||
mov [r2], r0
|
mov.8 [r2], r0
|
||||||
|
|
||||||
pop r1
|
pop r1
|
||||||
pop r0
|
pop r0
|
||||||
|
@ -91,7 +111,7 @@ stream_read:
|
||||||
|
|
||||||
; write specified number of bytes into the specified file
|
; write specified number of bytes into the specified file
|
||||||
; inputs:
|
; inputs:
|
||||||
; r0: number of bytes to write (ignored if file struct is a stream)
|
; r0: number of bytes to write
|
||||||
; r1: pointer to file struct
|
; r1: pointer to file struct
|
||||||
; r2: pointer to source buffer (always 4 bytes if file struct is a stream)
|
; r2: pointer to source buffer (always 4 bytes if file struct is a stream)
|
||||||
; outputs:
|
; outputs:
|
||||||
|
@ -111,6 +131,20 @@ write:
|
||||||
pop r3
|
pop r3
|
||||||
ret
|
ret
|
||||||
stream_write:
|
stream_write:
|
||||||
|
push r31
|
||||||
|
push r2
|
||||||
|
|
||||||
|
mov r31, r0 ; number of bytes to write = loop count
|
||||||
|
stream_write_loop:
|
||||||
|
call stream_write_char
|
||||||
|
inc r2
|
||||||
|
loop stream_write_loop
|
||||||
|
|
||||||
|
pop r2
|
||||||
|
pop r31
|
||||||
|
ret
|
||||||
|
|
||||||
|
stream_write_char:
|
||||||
push r0
|
push r0
|
||||||
push r1
|
push r1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user