1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-27 09:48:05 +11:00

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 -- DROP a --
DUP a -- a a DUP a -- a a
?DUP DUP if a is nonzero ?DUP DUP if a is nonzero
NIP a b -- b
OVER a b -- a b a OVER a b -- a b a
ROT a b c -- b c a ROT a b c -- b c a
SWAP a b -- b a SWAP a b -- b a
@ -12,5 +13,4 @@ SWAP a b -- b a
2SWAP a b c d -- c d a b 2SWAP a b c d -- c d a b
'S Returns current stack pointer, not counting the 'S Returns current stack pointer, not counting the
push it's making right now. push it's making right now.
S0 Returns address of PSP TOS. When PSP is empty, (cont.)
'S == S0 (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, PICK Pick nth item from stack. "0 PICK" = DUP,
"1 PICK" = OVER. "1 PICK" = OVER.
ROLL Rotate PSP over n items. "1 ROLL" = SWAP, ROLL Rotate PSP over n items. "1 ROLL" = SWAP,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

Binary file not shown.