Make MOVE* words use A@ and A!
This allows us to remove AMOVE* words.
This commit is contained in:
parent
69bb34ce7b
commit
75ef1f440c
3
blk/355
3
blk/355
@ -9,3 +9,6 @@
|
|||||||
DUP I C!
|
DUP I C!
|
||||||
LOOP DROP ;
|
LOOP DROP ;
|
||||||
: ALLOT0 ( n -- ) H@ OVER 0 FILL ALLOT ;
|
: ALLOT0 ( n -- ) H@ OVER 0 FILL ALLOT ;
|
||||||
|
SYSVARS 0x3e + :** A@
|
||||||
|
SYSVARS 0x40 + :** A!
|
||||||
|
SYSVARS 0x42 + :** A,
|
||||||
|
15
blk/367
15
blk/367
@ -1,14 +1,13 @@
|
|||||||
: MOVE ( a1 a2 u -- )
|
: MOVE ( a1 a2 u -- )
|
||||||
?DUP IF ( u ) 0 DO ( a1 a2 )
|
?DUP IF ( u ) 0 DO ( a1 a2 )
|
||||||
SWAP C@+ ( a2 a1+1 x )
|
OVER I + A@ ( src dst x )
|
||||||
ROT C!+ ( a1+1 a2+1 )
|
OVER I + ( src dst x dst )
|
||||||
|
A! ( src dst )
|
||||||
LOOP THEN 2DROP ;
|
LOOP THEN 2DROP ;
|
||||||
: MOVE- ( a1 a2 u -- )
|
: MOVE- ( a1 a2 u -- )
|
||||||
?DUP IF TUCK + 1- ( a1 u a2+u-1 )
|
?DUP IF ( u ) 0 DO ( a1 a2 )
|
||||||
ROT 2 PICK + 1- ( u a2+u-1 a1+u-1 )
|
OVER I' + I - 1- A@ ( src dst x )
|
||||||
ROT ( u ) 0 DO ( a2 a1 )
|
OVER I' + I - 1- ( src dst x dst )
|
||||||
C@- ( a2 a1-1 x )
|
A! ( src dst )
|
||||||
ROT C!- ( a1-1 a2-1 ) SWAP ( a2 a1 )
|
|
||||||
LOOP THEN 2DROP ;
|
LOOP THEN 2DROP ;
|
||||||
: MOVE, ( a u -- ) H@ OVER ALLOT SWAP MOVE ;
|
: MOVE, ( a u -- ) H@ OVER ALLOT SWAP MOVE ;
|
||||||
: PREV 3 - DUP @ - ;
|
|
||||||
|
10
blk/368
10
blk/368
@ -1,10 +1,16 @@
|
|||||||
|
: MOVEW ( src dst u -- )
|
||||||
|
( u ) 0 DO
|
||||||
|
SWAP DUP I 1 LSHIFT + A@ ( dst src x )
|
||||||
|
ROT TUCK I 1 LSHIFT + ( src dst x dst )
|
||||||
|
A! ( src dst )
|
||||||
|
LOOP 2DROP ;
|
||||||
|
: PREV 3 - DUP @ - ;
|
||||||
: [entry] ( w -- )
|
: [entry] ( w -- )
|
||||||
C@+ ( w+1 len ) TUCK MOVE, ( len )
|
C@+ ( w+1 len ) TUCK MOVE, ( len )
|
||||||
( write prev value )
|
( write prev value )
|
||||||
H@ CURRENT @ - ,
|
H@ CURRENT @ - ,
|
||||||
C, ( write size )
|
C, ( write size )
|
||||||
H@ CURRENT !
|
H@ CURRENT ! ;
|
||||||
;
|
|
||||||
: (entry) WORD [entry] ;
|
: (entry) WORD [entry] ;
|
||||||
: CREATE (entry) 2 ( cellWord ) C, ;
|
: CREATE (entry) 2 ( cellWord ) C, ;
|
||||||
: VARIABLE CREATE 2 ALLOT ;
|
: VARIABLE CREATE 2 ALLOT ;
|
||||||
|
12
blk/385
12
blk/385
@ -2,15 +2,3 @@
|
|||||||
( b1 b2 -- )
|
( b1 b2 -- )
|
||||||
: LOADR 1+ SWAP DO I DUP . NL LOAD LOOP ;
|
: LOADR 1+ SWAP DO I DUP . NL LOAD LOOP ;
|
||||||
: LOADR+ BLK> @ + SWAP BLK> @ + SWAP LOADR ;
|
: LOADR+ BLK> @ + SWAP BLK> @ + SWAP LOADR ;
|
||||||
( Now, adev stuff )
|
|
||||||
SYSVARS 0x3e + :** A@
|
|
||||||
SYSVARS 0x40 + :** A!
|
|
||||||
SYSVARS 0x42 + :** A,
|
|
||||||
|
|
||||||
( src dst u -- )
|
|
||||||
: AMOVE
|
|
||||||
( u ) 0 DO
|
|
||||||
SWAP DUP I + A@ ( dst src x )
|
|
||||||
ROT TUCK I + ( src dst x dst )
|
|
||||||
A! ( src dst )
|
|
||||||
LOOP 2DROP ;
|
|
||||||
|
6
blk/386
6
blk/386
@ -1,6 +0,0 @@
|
|||||||
: AMOVEW ( src dst u -- )
|
|
||||||
( u ) 0 DO
|
|
||||||
SWAP DUP I 1 LSHIFT + A@ ( dst src x )
|
|
||||||
ROT TUCK I 1 LSHIFT + ( src dst x dst )
|
|
||||||
A! ( src dst )
|
|
||||||
LOOP 2DROP ;
|
|
BIN
cvm/forth.bin
BIN
cvm/forth.bin
Binary file not shown.
@ -97,9 +97,9 @@ Example to write 0x1234 to the first byte of the first page:
|
|||||||
asperase 0x1234 0 aspfb! 0 aspfp!
|
asperase 0x1234 0 aspfb! 0 aspfp!
|
||||||
|
|
||||||
Please note that aspfb! deals with *words*, not bytes. If, for
|
Please note that aspfb! deals with *words*, not bytes. If, for
|
||||||
example, you want to hook it to A!*, make sure you use AMOVEW
|
example, you want to hook it to A!*, make sure you use MOVEW
|
||||||
instead of AMOVE. You will need to create a wrapper word around
|
instead of MOVE. You will need to create a wrapper word around
|
||||||
aspfb! that divides dst addr by 2 because AMOVEW use byte-based
|
aspfb! that divides dst addr by 2 because MOVEW use byte-based
|
||||||
addresses but aspfb! uses word-based ones. You also have to make
|
addresses but aspfb! uses word-based ones. You also have to make
|
||||||
sure that A@* points to @ (or another word-based fetcher)
|
sure that A@* points to @ (or another word-based fetcher)
|
||||||
instead of its default value of C@.
|
instead of its default value of C@.
|
||||||
|
24
doc/dict.txt
24
doc/dict.txt
@ -52,6 +52,7 @@ $ - Initialize
|
|||||||
literal. If not found, aborts.
|
literal. If not found, aborts.
|
||||||
, n -- Write n in HERE and advance it.
|
, n -- Write n in HERE and advance it.
|
||||||
ALLOT n -- Move HERE by n bytes
|
ALLOT n -- Move HERE by n bytes
|
||||||
|
A, b -- Indirect C,
|
||||||
C, b -- Write byte b in HERE and advance it.
|
C, b -- Write byte b in HERE and advance it.
|
||||||
FIND w -- a f Like '?, but for w.
|
FIND w -- a f Like '?, but for w.
|
||||||
EMPTY -- Rewind HERE and CURRENT where they were at
|
EMPTY -- Rewind HERE and CURRENT where they were at
|
||||||
@ -153,6 +154,8 @@ J -- n Copy RS third item to PS
|
|||||||
! n a -- Store n in address a
|
! n a -- Store n in address a
|
||||||
? a -- Print value of addr a
|
? a -- Print value of addr a
|
||||||
+! n a -- Increase value of addr a by n
|
+! n a -- Increase value of addr a by n
|
||||||
|
A@ a -- c Indirect C@
|
||||||
|
A! c a -- Indirect C!
|
||||||
C@ a -- c Set c to byte at address a
|
C@ a -- c Set c to byte at address a
|
||||||
C@+ a -- a+1 c Fetch c from a and inc a.
|
C@+ a -- a+1 c Fetch c from a and inc a.
|
||||||
C@- a -- a-1 c Fetch c from a and dec a.
|
C@- a -- a-1 c Fetch c from a and dec a.
|
||||||
@ -172,23 +175,16 @@ MOVE a1 a2 u -- Copy u bytes from a1 to a2, starting
|
|||||||
MOVE- a1 a2 u -- Copy u bytes from a1 to a2, starting
|
MOVE- a1 a2 u -- Copy u bytes from a1 to a2, starting
|
||||||
with a1+u, going down.
|
with a1+u, going down.
|
||||||
MOVE, a u -- Copy u bytes from a to HERE.
|
MOVE, a u -- Copy u bytes from a to HERE.
|
||||||
|
MOVEW src dst u -- Same as MOVE, but with words
|
||||||
|
|
||||||
# Addressed devices
|
Important note: MOVE* use A@ and A! instead of C@ and C! See
|
||||||
|
"Addressed devices" in usage.txt.
|
||||||
|
|
||||||
ADEV$ -- Initialize adev subsystem
|
MOVEW notes: this word's purpose is to interface with word-
|
||||||
A@ a -- c Indirect C@
|
|
||||||
A! c a -- Indirect C!
|
|
||||||
A@* -- a Address for A@ word
|
|
||||||
A!* -- a Address for A! word
|
|
||||||
AMOVE src dst u -- Same as MOVE, but with A@ and A!
|
|
||||||
AMOVEW src dst u -- Same as AMOVE, but with words
|
|
||||||
|
|
||||||
AMOVEW notes: this word's purpose is to interface with word-
|
|
||||||
based systems. src and dst are addressed as *bytes* but u is a
|
based systems. src and dst are addressed as *bytes* but u is a
|
||||||
*word* count. Every iteration increases src and dst by 2. When
|
*word* count. Every iteration increases src and dst by 2. This
|
||||||
you use it, be aware that default values for A!* and A@* are C!
|
shouldn't be used on regular memory, it will yield weird
|
||||||
and C@. If you don't adjust before using AMOVEW, you will get
|
results. Use it with A! switch pointing to a word-based target.
|
||||||
weird results.
|
|
||||||
|
|
||||||
# Arithmetic / Bits
|
# Arithmetic / Bits
|
||||||
|
|
||||||
|
@ -85,12 +85,16 @@ need switches in regular code.
|
|||||||
# Addressed devices
|
# Addressed devices
|
||||||
|
|
||||||
A@, A! and A, are the indirect versions of C@, C! and C,. They
|
A@, A! and A, are the indirect versions of C@, C! and C,. They
|
||||||
are switch words and initially point to C@, C! and C,. There is
|
are switch words and initially point to C@, C! and C,.
|
||||||
also a AMOVE word that is the same as MOVE but using A@ and A!.
|
|
||||||
|
|
||||||
Addressed device words can be useful to "pipe" processing to
|
Addressed device words can be useful to "pipe" processing to
|
||||||
places outside of regular memory.
|
places outside of regular memory.
|
||||||
|
|
||||||
|
All MOVE words use A@ and A! instead of C@ and C!. This gives a
|
||||||
|
lot of flexibility to those words, allowing for complex data
|
||||||
|
transfers. The cost of the indirection is small because of the
|
||||||
|
optimized ways aliases are built.
|
||||||
|
|
||||||
# Disk blocks
|
# Disk blocks
|
||||||
|
|
||||||
Disk blocks are Collapse OS' main access to permanent storage.
|
Disk blocks are Collapse OS' main access to permanent storage.
|
||||||
|
Loading…
Reference in New Issue
Block a user