You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
911 B
Forth
42 lines
911 B
Forth
1 week ago
|
: cell 8 ;
|
||
|
: cell+ cell + ;
|
||
|
: cells cell * ;
|
||
|
: char+ 1 + ;
|
||
|
: chars ;
|
||
|
|
||
|
: state _d 7 cells + ;
|
||
|
: [ 0 state ! ; immediate
|
||
|
: ] -1 state ! ;
|
||
|
|
||
|
: sp _d ;
|
||
|
: rp [ _d cell+ ] literal ;
|
||
|
: dp [ _d 3 cells + ] literal ;
|
||
|
|
||
|
: sp@ sp @ ;
|
||
|
: rp@ rp @ cell+ ;
|
||
|
: ip [ _d cell+ cell+ ] literal ;
|
||
|
: here dp @ ;
|
||
|
: unused [ _d 8 cells + ] literal @ here - ;
|
||
|
: latest [ _d 4 cells + ] literal @ ;
|
||
|
|
||
|
: dup sp@ @ ;
|
||
|
: drop sp@ cell+ sp ! ;
|
||
|
: pick cells cell+ sp@ + @ ;
|
||
|
: >r rp@ cell - rp !
|
||
|
rp@ cell+ @ rp@ !
|
||
|
rp@ cell+ ! ;
|
||
|
: r> rp@ @
|
||
|
rp@ cell+ rp !
|
||
|
rp@ @ swap rp@ ! ;
|
||
|
: rot >r swap r> swap ;
|
||
|
: -rot rot rot ;
|
||
|
: over 1 pick ;
|
||
|
|
||
|
: +! dup >r swap r> @ + swap ! ;
|
||
|
: allot dp +! ;
|
||
|
: , here ! cell allot ;
|
||
|
|
||
|
: 1+ 1 + ;
|
||
|
: 1- 1 - ;
|
||
|
|