CoreForth-0

cortex/common/core.ft.md


variable (source-id)
variable (sink-id)

: source-id     (source-id) @ ;
: sink-id       (sink-id) @ ;

: negate        invert 1+ ;
: pick          ?dup if 1- cells sp@ + @ else dup then ;
: dnegate       not >r not 1 m+ r> + ;
: m*            2dup xor 0< >r abs swap abs um* r> if dnegate then ;

: /mod          2dup xor 0< >r
                swap dup 0< dup >r if negate then
                swap dup 0< if negate then
                u/mod swap r> if negate then swap r> if negate then ;

: sm/rem        nip /mod ;
: um/mod        nip u/mod ;

: fm/mod        dup >r 2dup xor 0< >r sm/rem over 0<> r> and if
                  1 - swap r> + swap exit
                then r> drop ;
: */mod         >r m* r> sm/rem ;
: */            */mod swap drop ;

::stc:: : (s")        r> 1- dup 1+ swap c@ 2dup + aligned 1+ >r ;
::itc:: : (s")        r> dup 1+ swap c@ 2dup + aligned >r ;
::dtc:: : (s")        r> dup 1+ swap c@ 2dup + aligned >r ;