Inline min/max/abs.
This commit is contained in:
@ -68,11 +68,6 @@
|
|||||||
( Recursion )
|
( Recursion )
|
||||||
: recurse current @ @ aliteral ['] execute , ; immediate
|
: recurse current @ @ aliteral ['] execute , ; immediate
|
||||||
|
|
||||||
( Compound words requiring conditionals )
|
|
||||||
: min 2dup < if drop else nip then ;
|
|
||||||
: max 2dup < if nip else drop then ;
|
|
||||||
: abs ( n -- +n ) dup 0< if negate then ;
|
|
||||||
|
|
||||||
( Dictionary Format )
|
( Dictionary Format )
|
||||||
: >flags& ( xt -- a ) cell - ; : >flags ( xt -- flags ) >flags& c@ ;
|
: >flags& ( xt -- a ) cell - ; : >flags ( xt -- flags ) >flags& c@ ;
|
||||||
: >name-length ( xt -- n ) >flags& 1+ c@ ;
|
: >name-length ( xt -- n ) >flags& 1+ c@ ;
|
||||||
|
|||||||
@ -54,3 +54,8 @@
|
|||||||
: cmove> ( a a n -- ) for aft 2dup swap r@ + c@ swap r@ + c! then next 2drop ;
|
: cmove> ( a a n -- ) for aft 2dup swap r@ + c@ swap r@ + c! then next 2drop ;
|
||||||
: fill ( a n ch -- ) swap for swap aft 2dup c! 1 + then next 2drop ;
|
: fill ( a n ch -- ) swap for swap aft 2dup c! 1 + then next 2drop ;
|
||||||
: erase ( a n -- ) 0 fill ; : blank ( a n -- ) bl fill ;
|
: erase ( a n -- ) 0 fill ; : blank ( a n -- ) bl fill ;
|
||||||
|
|
||||||
|
( Compound words requiring conditionals )
|
||||||
|
: min 2dup < if drop else nip then ;
|
||||||
|
: max 2dup < if nip else drop then ;
|
||||||
|
: abs ( n -- +n ) dup 0< if negate then ;
|
||||||
|
|||||||
@ -53,4 +53,7 @@
|
|||||||
X("cmove>", cmove2, memmove((void *) *sp, (void *) sp[-1], tos); sp -= 2; DROP) \
|
X("cmove>", cmove2, memmove((void *) *sp, (void *) sp[-1], tos); sp -= 2; DROP) \
|
||||||
Y(fill, memset((void *) sp[-1], tos, *sp); sp -= 2; DROP) \
|
Y(fill, memset((void *) sp[-1], tos, *sp); sp -= 2; DROP) \
|
||||||
Y(erase, memset((void *) *sp, 0, tos); NIP; DROP) \
|
Y(erase, memset((void *) *sp, 0, tos); NIP; DROP) \
|
||||||
Y(blank, memset((void *) *sp, ' ', tos); NIP; DROP)
|
Y(blank, memset((void *) *sp, ' ', tos); NIP; DROP) \
|
||||||
|
Y(min, tos = tos < *sp ? tos : *sp; NIP) \
|
||||||
|
Y(max, tos = tos > *sp ? tos : *sp; NIP) \
|
||||||
|
Y(abs, tos = tos < 0 ? -tos : tos)
|
||||||
|
|||||||
@ -125,9 +125,6 @@ e: check-boot
|
|||||||
out: >name-length
|
out: >name-length
|
||||||
out: >flags
|
out: >flags
|
||||||
out: >flags&
|
out: >flags&
|
||||||
out: abs
|
|
||||||
out: max
|
|
||||||
out: min
|
|
||||||
out: recurse
|
out: recurse
|
||||||
out: aft
|
out: aft
|
||||||
out: repeat
|
out: repeat
|
||||||
@ -170,6 +167,10 @@ e: check-boot
|
|||||||
;e
|
;e
|
||||||
|
|
||||||
e: check-extra-opcodes
|
e: check-extra-opcodes
|
||||||
|
out: abs
|
||||||
|
out: max
|
||||||
|
out: min
|
||||||
|
|
||||||
out: blank
|
out: blank
|
||||||
out: erase
|
out: erase
|
||||||
out: fill
|
out: fill
|
||||||
|
|||||||
Reference in New Issue
Block a user