mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-28 08:58:07 +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
|
||||
|
||||
>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
|
||||
2R> R:x y -- x y Equivalent to R> R> SWAP
|
||||
I -- n Copy RS TOS to PS
|
||||
I' -- n Copy RS second item to PS
|
||||
J -- n Copy RS third item to PS
|
||||
|
18
blk/326
18
blk/326
@ -1,13 +1,17 @@
|
||||
CODE >R
|
||||
HL POPqq,
|
||||
chkPS,
|
||||
( 17 == pushRS )
|
||||
17 BCALL,
|
||||
HL POPqq, chkPS,
|
||||
17 BCALL, ( 17 == pushRS )
|
||||
;CODE
|
||||
CODE 2>R
|
||||
DE POPqq, HL POPqq, chkPS,
|
||||
17 BCALL, ( 17 == pushRS ) EXDEHL, 17 BCALL,
|
||||
;CODE
|
||||
|
||||
CODE R>
|
||||
( 20 == popRS )
|
||||
20 BCALL,
|
||||
20 BCALL, ( 20 == popRS )
|
||||
HL PUSHqq,
|
||||
;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 /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 )
|
||||
: DO
|
||||
COMPILE SWAP COMPILE >R COMPILE >R
|
||||
H@
|
||||
; IMMEDIATE
|
||||
: DO COMPILE 2>R H@ ; IMMEDIATE
|
||||
|
||||
|
||||
|
2
blk/432
2
blk/432
@ -12,5 +12,5 @@
|
||||
: LOOP
|
||||
COMPILE _ COMPILE (?br)
|
||||
H@ - ,
|
||||
COMPILE R> COMPILE DROP COMPILE R> COMPILE DROP
|
||||
COMPILE 2R> COMPILE 2DROP
|
||||
; IMMEDIATE
|
||||
|
BIN
emul/forth.bin
BIN
emul/forth.bin
Binary file not shown.
Loading…
Reference in New Issue
Block a user