mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-05 08:50:56 +11:00
Add 2>R and 2R>
This allows us to make DO..LOOP more compact.
This commit is contained in:
parent
b89fa2981f
commit
f54b1dc504
2
blk/048
2
blk/048
@ -1,7 +1,9 @@
|
|||||||
Return Stack
|
Return Stack
|
||||||
|
|
||||||
>R n -- R:n Pops PS and push to RS
|
>R n -- R:n Pops PS and push to RS
|
||||||
|
2>R x y -- R:x y Equivalent to SWAP >R >R
|
||||||
R> R:n -- n Pops RS and push to PS
|
R> R:n -- n Pops RS and push to PS
|
||||||
|
2R> R:x y -- x y Equivalent to R> R> SWAP
|
||||||
I -- n Copy RS TOS to PS
|
I -- n Copy RS TOS to PS
|
||||||
I' -- n Copy RS second item to PS
|
I' -- n Copy RS second item to PS
|
||||||
J -- n Copy RS third item to PS
|
J -- n Copy RS third item to PS
|
||||||
|
18
blk/326
18
blk/326
@ -1,13 +1,17 @@
|
|||||||
CODE >R
|
CODE >R
|
||||||
HL POPqq,
|
HL POPqq, chkPS,
|
||||||
chkPS,
|
17 BCALL, ( 17 == pushRS )
|
||||||
( 17 == pushRS )
|
;CODE
|
||||||
17 BCALL,
|
CODE 2>R
|
||||||
|
DE POPqq, HL POPqq, chkPS,
|
||||||
|
17 BCALL, ( 17 == pushRS ) EXDEHL, 17 BCALL,
|
||||||
;CODE
|
;CODE
|
||||||
|
|
||||||
CODE R>
|
CODE R>
|
||||||
( 20 == popRS )
|
20 BCALL, ( 20 == popRS )
|
||||||
20 BCALL,
|
|
||||||
HL PUSHqq,
|
HL PUSHqq,
|
||||||
;CODE
|
;CODE
|
||||||
|
CODE 2R>
|
||||||
|
20 BCALL, ( 20 == popRS ) EXDEHL, 20 BCALL,
|
||||||
|
HL PUSHqq, DE PUSHqq,
|
||||||
|
;CODE
|
||||||
|
|
||||||
|
7
blk/431
7
blk/431
@ -3,11 +3,8 @@
|
|||||||
: / /MOD SWAP DROP ;
|
: / /MOD SWAP DROP ;
|
||||||
: MOD /MOD DROP ;
|
: MOD /MOD DROP ;
|
||||||
|
|
||||||
( In addition to pushing H@ this compiles 2 >R so that loop
|
( In addition to pushing H@ this compiles 2>R so that loop
|
||||||
variables are sent to PS at runtime )
|
variables are sent to PS at runtime )
|
||||||
: DO
|
: DO COMPILE 2>R H@ ; IMMEDIATE
|
||||||
COMPILE SWAP COMPILE >R COMPILE >R
|
|
||||||
H@
|
|
||||||
; IMMEDIATE
|
|
||||||
|
|
||||||
|
|
||||||
|
2
blk/432
2
blk/432
@ -12,5 +12,5 @@
|
|||||||
: LOOP
|
: LOOP
|
||||||
COMPILE _ COMPILE (?br)
|
COMPILE _ COMPILE (?br)
|
||||||
H@ - ,
|
H@ - ,
|
||||||
COMPILE R> COMPILE DROP COMPILE R> COMPILE DROP
|
COMPILE 2R> COMPILE 2DROP
|
||||||
; IMMEDIATE
|
; IMMEDIATE
|
||||||
|
BIN
emul/forth.bin
BIN
emul/forth.bin
Binary file not shown.
Loading…
Reference in New Issue
Block a user