Skip to content

Commit

Permalink
Added NDROP to builtin.c
Browse files Browse the repository at this point in the history
Added COUNT to base.fs
  • Loading branch information
flrl committed Jun 29, 2009
1 parent 16740fe commit bda310f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
then just no-op (and maybe print a warning) <- sorta done, but needs more thought
* debug primitives -- SEE, DUMP, etc
* proper test suite built around ASSERT
* don't like my NDUP or ASSERT implementations -- rewrite (use user memory?)




Expand Down
1 change: 1 addition & 0 deletions base.fs
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@
: CONSTANT CREATE DFA>CFA DOCON SWAP ! , ;
: EXIT IMMEDIATE NOINTERPRET 0 , ;
DEC 32 CONSTANT BL
: COUNT DUP 1+ SWAP C@ ;
15 changes: 13 additions & 2 deletions builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,19 @@ PRIMITIVE ("2DROP", 0, _2DROP, _negROT) {
}


// ( n*a n -- )
PRIMITIVE ("NDROP", 0, _NDROP, _2DROP) {
REG(n);

DPOP(n);
n = data_stack.index - n;
n = (n >= -1 ? n : -1);
data_stack.index = n;
}


// ( b a -- b a b a )
PRIMITIVE ("2DUP", 0, _2DUP, _2DROP) {
PRIMITIVE ("2DUP", 0, _2DUP, _NDROP) {
REG(a);
REG(b);

Expand Down Expand Up @@ -1327,7 +1338,7 @@ PRIMITIVE ("LITSTRING", 0, _LITSTRING, _0BRANCH) {
}


// ( -- )
// ( addr len -- )
PRIMITIVE ("TELL", 0, _TELL, _LITSTRING) {
REG(a);
REG(b);
Expand Down

0 comments on commit bda310f

Please sign in to comment.