Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"type-counted" optimization #2

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions generic/forth/test.forth
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,9 @@ marker: -test-mark
: test:[
[ 60 5 + ] literal 65 =assert ;

: test:[2
1 if [ 60 5 + ] literal then 65 =assert ;

depth 0= assert
test
depth 0= assert
Expand Down
19 changes: 10 additions & 9 deletions generic/words.S
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ defword "4drop",5,"drop4",REGULAR

.ifndef xt_over
defword "over",4,over,REGULAR /* ( a b -- a b a ) */
.int xt_swap
.int xt_rpush
.int xt_dup
.int xt_rot
.int xt_rpop
.int xt_swap
.int xt_end_word
.endif
Expand Down Expand Up @@ -61,9 +61,13 @@ defword ">",1,gt,REGULAR

.ifndef xt_eq
defword "=",1,eq,REGULAR
.int xt_dup2
.int xt_lt, xt_invert, xt_mrot
.int xt_swap, xt_lt, xt_invert, xt_and // !(a < b) and !(b < a)
.int xt_xor
.int xt_branch0
lbl is_equal
.int xt_btick, FALSE
.int xt_end_word
is_equal:
.int xt_btick, TRUE
.int xt_end_word
.endif

Expand Down Expand Up @@ -476,11 +480,8 @@ defword "type-counted",12,typecounted,REGULAR // ( addr count -- )
type_counted_next_char:
.int xt_dup, xt_branch0
lbl type_counted_done
.int xt_over, xt_plus, xt_fetchbyte, xt_emit
.int xt_dec
.int xt_swap, xt_dup
.int xt_fetchbyte, xt_emit
.int xt_inc
.int xt_swap
.int xt_branch
lbl type_counted_next_char
type_counted_done:
Expand Down