Add word NIP

This commit is contained in:
Virgil Dupras 2020-05-22 14:03:12 -04:00
parent b08970ae8a
commit d5beeac96b
12 changed files with 13 additions and 12 deletions

View File

@ -3,6 +3,7 @@ Parameter Stack
DROP a --
DUP a -- a a
?DUP DUP if a is nonzero
NIP a b -- b
OVER a b -- a b a
ROT a b c -- b c a
SWAP a b -- b a
@ -12,5 +13,4 @@ SWAP a b -- b a
2SWAP a b c d -- c d a b
'S Returns current stack pointer, not counting the
push it's making right now.
S0 Returns address of PSP TOS. When PSP is empty,
'S == S0 (cont.)
(cont.)

View File

@ -1,4 +1,5 @@
(cont.)
S0 Returns address of PSP TOS. When PSP is empty,
'S == S0
PICK Pick nth item from stack. "0 PICK" = DUP,
"1 PICK" = OVER.
ROLL Rotate PSP over n items. "1 ROLL" = SWAP,

View File

@ -7,7 +7,7 @@
SWAP OVER - ( ilen chars-to-move )
SWAP EDPOS @ _cpos 2DUP + ( ctm ilen a a+ilen )
3 PICK MOVE- ( ctm ilen )
SWAP DROP ( ilen )
NIP ( ilen )
ELSE DROP ( ilen becomes rbuffsize )
THEN
DUP IBUF EDPOS @ _cpos ROT MOVE ( ilen )

View File

@ -7,7 +7,7 @@
THEN
ROT ( o a n ol )
< IF ( under limit, do nothing )
SWAP DROP ( a )
NIP ( a )
ELSE ( o a )
SWAP OVER @ ( a o n )
-^ ( a n-o )

View File

@ -12,3 +12,4 @@
IF OVER C@ OR
ELSE 0xff XOR OVER C@ AND THEN ( addr flg )
SWAP C! ;
: NIP SWAP DROP ;

View File

@ -9,5 +9,5 @@
OVER ! 1+ C< ( a c )
OVER 0x2d ( 2e-1 for NULL ) RAM+ = OVER WS? OR
UNTIL ( a c )
SWAP DROP 0x0e RAM+ ( ws a )
NIP 0x0e RAM+ ( ws a )
SWAP EOT? IF 4 OVER ! THEN ;

View File

@ -7,7 +7,7 @@
: IMMED? 1- C@ 0x80 AND ;
: +! SWAP OVER @ + SWAP ! ;
: -^ SWAP - ;
: / /MOD SWAP DROP ;
: / /MOD NIP ;
: MOD /MOD DROP ;
: ALLOT HERE +! ;
: CREATE (entry) 11 ( 11 == cellWord ) C, ;

View File

@ -7,7 +7,6 @@
?DUP NOT IF EXIT THEN
1+ DUP PICK ( n val )
SWAP 2 * (roll) ( val )
SWAP DROP
;
NIP ;
: 2OVER 3 PICK 3 PICK ;
: 2SWAP 3 ROLL 3 ROLL ;

View File

@ -8,5 +8,5 @@
( gid dmask )
0xff XOR ( dpos ) 0 ( dindex )
BEGIN 1+ 2DUP RSHIFT NOT UNTIL 1-
( gid dpos dindex ) SWAP DROP
( gid dpos dindex ) NIP
( gid dindex ) SWAP 8 * + ;

View File

@ -8,7 +8,7 @@
0 ( cnt )
BEGIN
_idle
DUP 0xff = IF DROP ELSE SWAP DROP EXIT THEN
DUP 0xff = IF DROP ELSE NIP EXIT THEN
1+
DUP 20 = UNTIL
DROP 0xff

View File

@ -4,5 +4,5 @@
CREATE _ '0' C, ':' C, 'A' C, '[' C, 'a' C, 0xff C,
: _nxtcls
_sel @ _ BEGIN ( c a ) C@+ 2 PICK > UNTIL ( c a )
1- C@ SWAP DROP _sel !
1- C@ NIP _sel !
;

Binary file not shown.