diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2024-05-16 18:59:53 +0300 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2024-05-16 18:59:53 +0300 |
| commit | 9a3e2a3d05fc0b6bd0a847e29da0a87934f5a743 (patch) | |
| tree | 9b8cd310e4b5fe79d3eacfdb284992ae0023bf7e /atk16_projects | |
| parent | 1045229da08fc1c8168b5ae58d54a1566eefaaac (diff) | |
Fix another jump issue in assembler, improve monitor
Diffstat (limited to 'atk16_projects')
| -rw-r--r-- | atk16_projects/monitor/monitor.atk16 | 138 |
1 files changed, 84 insertions, 54 deletions
diff --git a/atk16_projects/monitor/monitor.atk16 b/atk16_projects/monitor/monitor.atk16 index 4580d5f..a0d4e9d 100644 --- a/atk16_projects/monitor/monitor.atk16 +++ b/atk16_projects/monitor/monitor.atk16 @@ -14,6 +14,7 @@ @data text_cursor_p 0xE800 @data input_buffer_p 0xE801 @data input_cursor_p 0xE802 +@data input_entered_bool 0xE803 @data title_string " »» ATK16 monitor v0.1 »»" @data subtitle_string " Run [help] for a list of commands" @@ -46,6 +47,13 @@ str RG RA ; END + ; BEGIN input_entered_bool = 0 + ldi input_entered_bool RA + ldr RA RA + ldi 0 RB + str RB RA + ; END + ; use memset to clear the text buffer ; BEGIN memset(text_mem, 0, text_buffer_size) ldi vt_text_mem RA ; RA := text buffer address pointer @@ -83,64 +91,34 @@ ; BEGIN critical section m_set_critical RA RB - ; TODO evaluate input_buffer if newline was just pressed - ;calli is_newline_pressed - ;subi RG 1 RG ; if is_newline_pressed() == 1, then loop_newline_pressed - ;bri zero loop_newline_pressed - jpi loop_finally + ldi input_entered_bool RA + ldr RA RA + ldr RA RB + subi RB 0 RB + bri zero loop_finally ; if input_entered_bool == 0 (false), skip to end of loop -@label loop_newline_pressed - ; TODO - jpi loop_finally +@label loop_input_was_entered + ldi 0 RB ; else, run this branch and set input_entered_bool = 0 + str RB RA -@label loop_finally - m_clear_critical RA RB - ; END critical section - jpi loop +@data eval_output_string "command received!" + ldi eval_output_string RA + calli put_string -;;; Subroutines + ; ldi input_buffer_p RA ; TODO! + ; ldr RA RA + ; ldr RA RA + ; calli put_string -@label newline - ; move cursor to the beginning of the next line - ; parameters: none - ; returns: none - - stack_stash RA RB m_newline RA RB - stack_restore RA RB - return -@label put_char - ; put a character at the current cursor position - ; parameters: RA = character to put - ; returns: none - - stack_stash RB RC - m_put_char RA RB RC - stack_restore RB RC - return - -@label put_string - ; put a string at the current cursor position - ; parameters: RA = string_p - ; returns: none - - stack_stash RA RB RC RD RE - ldr RA RB ; RB := string length - addi RA 1 RC ; RC := pointer to first character -@label put_string_loop - subi RB 0 RB ; exit if RB has been decremented to 0 - bri zero put_string_done ; i.e. no more characters to put - - ldr RC RA ; RA := character to put - m_put_char RA RD RE ; inline the put_char subroutine to avoid function call overhead + ldi prompt_string RA + calli put_string - inc RC - subi RB 1 RB - jpi put_string_loop -@label put_string_done - stack_restore RA RB RC RD RE - return +@label loop_finally + m_clear_critical RA RB + ; END critical section + jpi loop @data row_index_mask ${64 - 1} @@ -163,7 +141,8 @@ subi RB 5 RB subi RB 3 RB - bri zero keyboard_isr_backspace + ldi keyboard_isr_backspace RD + brr zero RD ldi row_index_mask RD ; else code is not special; write it to text buffer ldr RD RD ; if cursor is not at the end of the line @@ -201,8 +180,15 @@ callr RD ; END - ldi prompt_string RA - calli put_string + ; BEGIN input_entered_bool = 1 + ldi input_entered_bool RA + ldr RA RA + ldi 1 RB + str RB RA + ; END + + ldi ${ord(" ")} RA + m_put_char RA RB RD jpi keyboard_isr_end @@ -228,6 +214,50 @@ stack_restore RA RB RC RD rti +;;; Subroutines + +@label newline + ; move cursor to the beginning of the next line + ; parameters: none + ; returns: none + + stack_stash RA RB + m_newline RA RB + stack_restore RA RB + return + +@label put_char + ; put a character at the current cursor position + ; parameters: RA = character to put + ; returns: none + + stack_stash RB RC + m_put_char RA RB RC + stack_restore RB RC + return + +@label put_string + ; put a string at the current cursor position + ; parameters: RA = string_p + ; returns: none + + stack_stash RA RB RC RD RE + ldr RA RB ; RB := string length + addi RA 1 RC ; RC := pointer to first character +@label put_string_loop + subi RB 0 RB ; exit if RB has been decremented to 0 + bri zero put_string_done ; i.e. no more characters to put + + ldr RC RA ; RA := character to put + m_put_char RA RD RE ; inline the put_char subroutine to avoid function call overhead + + inc RC + subi RB 1 RB + jpi put_string_loop +@label put_string_done + stack_restore RA RB RC RD RE + return + @address vt_ISR0 @begin_override keyboard_isr |
