commit d8269ac8c0f566dbb8fd5e48acaeefa0ef04533e
parent c47a3e50ff83f7d4a0f98f456d7f2a67c1f0ab90
Author: Christian Ermann <christianermann@gmail.com>
Date: Mon, 4 Nov 2024 16:23:27 -0800
Convert tabs to spaces
Diffstat:
| M | forth.s | | | 168 | ++++++++++++++++++++++++++++++++++++++++---------------------------------------- |
1 file changed, 84 insertions(+), 84 deletions(-)
diff --git a/forth.s b/forth.s
@@ -119,15 +119,15 @@ docol:
next
dovar:
- addi w, w, cell
- push w
- next
+ addi w, w, cell
+ push w
+ next
docon:
- addi w, w, cell
- load_cell w, 0(w)
- push w
- next
+ addi w, w, cell
+ load_cell w, 0(w)
+ push w
+ next
.equ name_null, 0
@@ -284,59 +284,59 @@ defcode "parse-word", 10, 0, 0xB218226F, parse_word, fib
next
defcode ">number", 7, 0, 0x2F770E4C, to_number, parse_word
- pop x # word len
- pop w # word addr
- mv y, zero # initial value
- mv s3, zero # sign flag
- la s4, _base
- load_cell s4, 0(s4)
-
- beqz x, _to_number_empty_string
-
- lb t0, 0(w)
- addi w, w, 1
- addi x, x, -1
- li t1, 0x2D # '-'
- bne t0, t1, _to_number_digit_value
- addi s3, s3, -1
- bnez x, _to_number_loop
+ pop x # word len
+ pop w # word addr
+ mv y, zero # initial value
+ mv s3, zero # sign flag
+ la s4, _base
+ load_cell s4, 0(s4)
+
+ beqz x, _to_number_empty_string
+
+ lb t0, 0(w)
+ addi w, w, 1
+ addi x, x, -1
+ li t1, 0x2D # '-'
+ bne t0, t1, _to_number_digit_value
+ addi s3, s3, -1
+ bnez x, _to_number_loop
_to_number_empty_string:
- addi x, x, -1
- j _to_number_done
+ addi x, x, -1
+ j _to_number_done
_to_number_invalid:
- addi x, x, 1
- j _to_number_sign
+ addi x, x, 1
+ j _to_number_sign
_to_number_loop:
- mul y, y, s4
- lb t0, 0(w)
- addi w, w, 1
- addi x, x, -1
+ mul y, y, s4
+ lb t0, 0(w)
+ addi w, w, 1
+ addi x, x, -1
_to_number_digit_value:
- addi t0, t0, -48
- bltz t0, _to_number_invalid
- addi t1, t0, -10
- bltz t1, _to_number_base
- addi t0, t0, -7
- addi t1, t0, -10
- bltz t1, _to_number_invalid
+ addi t0, t0, -48
+ bltz t0, _to_number_invalid
+ addi t1, t0, -10
+ bltz t1, _to_number_base
+ addi t0, t0, -7
+ addi t1, t0, -10
+ bltz t1, _to_number_invalid
_to_number_base:
- bgt t0, s4, _to_number_invalid
- add y, y, t0
- bnez x, _to_number_loop
+ bgt t0, s4, _to_number_invalid
+ add y, y, t0
+ bnez x, _to_number_loop
_to_number_sign:
- beqz s3, _to_number_done
- neg y, y
+ beqz s3, _to_number_done
+ neg y, y
_to_number_done:
- push y
- push x
- next
+ push y
+ push x
+ next
defcode "word>hash", 9, 0, 0x50E0A245, word_to_hash, to_number
pop w # word address
@@ -374,7 +374,7 @@ defword "interpret", 9, 0, 0x1F98C57A, interpret, execute
_interpret_start:
.int parse_word, q_dup, q_branch, _interpret_parse_area_empty
.int two_dup
- .int find, q_dup, q_branch, _interpret_word_not_found
+ .int find, q_dup, q_branch, _interpret_word_not_found
.int nip, nip, to_cfa
.int compiling_q, q_branch, _interpret_execute_word
.int dup
@@ -384,10 +384,10 @@ _interpret_compile_word:
_interpret_execute_word:
.int execute, branch, _interpret_start
_interpret_word_not_found:
- .int to_number, zero_equal, q_branch, _interpret_retry
- .int compiling_q, q_branch, _interpret_start
+ .int to_number, zero_equal, q_branch, _interpret_retry
+ .int compiling_q, q_branch, _interpret_start
_interpret_compile_number:
- .int lit, lit, comma, comma, branch, _interpret_start
+ .int lit, lit, comma, comma, branch, _interpret_start
_interpret_retry:
.int drop, branch, _interpret_start
_interpret_parse_area_empty:
@@ -419,20 +419,20 @@ _branch_done:
next
defcode "prompt", 6, 0, 0xDFE6493B, prompt, q_branch
- la w, _prompt
- la x, _prompt_len
- call uart_put_string
- next
+ la w, _prompt
+ la x, _prompt_len
+ call uart_put_string
+ next
defcode "okay", 6, 0, 0xBA9EEB49, okay, prompt
- la w, _okay
- la x, _okay_len
- call uart_put_string
- next
+ la w, _okay
+ la x, _okay_len
+ call uart_put_string
+ next
defword "quit", 4, 0, 0x47878736, quit, okay
_quit_top:
- .int prompt
+ .int prompt
.int refill, drop # TODO: What should happen when 'refill' fails?
.int interpret, okay
.int branch, _quit_top
@@ -539,11 +539,11 @@ defcode "dup", 3, 0, 0xD330F226, dup, align
next
defcode "?dup", 4, 0, 0xFD2928D3, q_dup, dup
- load_cell w, 0(psp)
- beqz w, _q_dup_done
- push w
+ load_cell w, 0(psp)
+ beqz w, _q_dup_done
+ push w
_q_dup_done:
- next
+ next
defcode "swap", 4, 0, 0x64ED874E, swap, q_dup
pop w
@@ -740,33 +740,33 @@ defcode "immediate?", 10, 0, 0x89F23E9F, immediate_q, compiling_q
next
defword "postpone", 8, flag_immediate, 0x933F531F, postpone, immediate_q
- .int parse_word, find # TODO: was word actually found?
- .int to_cfa, dup
- .int immediate_q, q_branch, _postpone_compile
+ .int parse_word, find # TODO: was word actually found?
+ .int to_cfa, dup
+ .int immediate_q, q_branch, _postpone_compile
_postpone_execute:
- # stores "<xt>" into the current definition
- .int comma, exit
+ # stores "<xt>" into the current definition
+ .int comma, exit
_postpone_compile:
- # stores "lit <xt> ," into the current definition
- .int lit, lit, comma, comma, lit, comma, comma, exit
+ # stores "lit <xt> ," into the current definition
+ .int lit, lit, comma, comma, lit, comma, comma, exit
defword "immediate", 9, 0, 0xF232267A, immediate, postpone
- .int latest, fetch, lit, flag_offset, plus, dup
- .int fetch, lit, flag_immediate, or_
- .int swap, store
- .int exit
+ .int latest, fetch, lit, flag_offset, plus, dup
+ .int fetch, lit, flag_immediate, or_
+ .int swap, store
+ .int exit
defword "variable", 8, 0, 0x19385305, variable, immediate
.int parse_word, create # create header
.int lit, dovar, comma # append 'dovar'
- .int lit, 0, comma # initialize to zero
- .int exit
+ .int lit, 0, comma # initialize to zero
+ .int exit
defword "constant", 8, 0, 0x0691EA25, constant, variable
- .int parse_word, create # create header
- .int lit, docon, comma # append 'docon'
- .int comma # initialize to value on stack
- .int exit
+ .int parse_word, create # create header
+ .int lit, docon, comma # append 'docon'
+ .int comma # initialize to value on stack
+ .int exit
defcode "read-char", 10, 0, 0xF07E2044, read_char, variable
jal _read_char_impl
@@ -843,12 +843,12 @@ version_string:
version_string_len = (. - version_string)
_prompt:
- .ascii "> "
- _prompt_len = (. - _prompt)
+ .ascii "> "
+ _prompt_len = (. - _prompt)
_okay:
- .ascii "ok\n"
- _okay_len = (. - _okay)
+ .ascii "ok\n"
+ _okay_len = (. - _okay)
word_buffer: .space 255
.balign cell