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

Make MOVE* words use A@ and A!

This allows us to remove AMOVE* words.
This commit is contained in:
Virgil Dupras 2020-10-29 12:15:21 -04:00
parent 69bb34ce7b
commit 75ef1f440c
9 changed files with 37 additions and 47 deletions

View File

@ -9,3 +9,6 @@
DUP I C!
LOOP DROP ;
: ALLOT0 ( n -- ) H@ OVER 0 FILL ALLOT ;
SYSVARS 0x3e + :** A@
SYSVARS 0x40 + :** A!
SYSVARS 0x42 + :** A,

15
blk/367
View File

@ -1,14 +1,13 @@
: MOVE ( a1 a2 u -- )
?DUP IF ( u ) 0 DO ( a1 a2 )
SWAP C@+ ( a2 a1+1 x )
ROT C!+ ( a1+1 a2+1 )
OVER I + A@ ( src dst x )
OVER I + ( src dst x dst )
A! ( src dst )
LOOP THEN 2DROP ;
: MOVE- ( a1 a2 u -- )
?DUP IF TUCK + 1- ( a1 u a2+u-1 )
ROT 2 PICK + 1- ( u a2+u-1 a1+u-1 )
ROT ( u ) 0 DO ( a2 a1 )
C@- ( a2 a1-1 x )
ROT C!- ( a1-1 a2-1 ) SWAP ( a2 a1 )
?DUP IF ( u ) 0 DO ( a1 a2 )
OVER I' + I - 1- A@ ( src dst x )
OVER I' + I - 1- ( src dst x dst )
A! ( src dst )
LOOP THEN 2DROP ;
: MOVE, ( a u -- ) H@ OVER ALLOT SWAP MOVE ;
: PREV 3 - DUP @ - ;

10
blk/368
View File

@ -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 -- )
C@+ ( w+1 len ) TUCK MOVE, ( len )
( write prev value )
H@ CURRENT @ - ,
C, ( write size )
H@ CURRENT !
;
H@ CURRENT ! ;
: (entry) WORD [entry] ;
: CREATE (entry) 2 ( cellWord ) C, ;
: VARIABLE CREATE 2 ALLOT ;

12
blk/385
View File

@ -2,15 +2,3 @@
( b1 b2 -- )
: LOADR 1+ SWAP DO I DUP . NL LOAD LOOP ;
: 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 ;

View File

@ -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 ;

Binary file not shown.

View File

@ -97,9 +97,9 @@ Example to write 0x1234 to the first byte of the first page:
asperase 0x1234 0 aspfb! 0 aspfp!
Please note that aspfb! deals with *words*, not bytes. If, for
example, you want to hook it to A!*, make sure you use AMOVEW
instead of AMOVE. You will need to create a wrapper word around
aspfb! that divides dst addr by 2 because AMOVEW use byte-based
example, you want to hook it to A!*, make sure you use MOVEW
instead of MOVE. You will need to create a wrapper word around
aspfb! that divides dst addr by 2 because MOVEW use byte-based
addresses but aspfb! uses word-based ones. You also have to make
sure that A@* points to @ (or another word-based fetcher)
instead of its default value of C@.

View File

@ -52,6 +52,7 @@ $ - Initialize
literal. If not found, aborts.
, n -- Write n in HERE and advance it.
ALLOT n -- Move HERE by n bytes
A, b -- Indirect C,
C, b -- Write byte b in HERE and advance it.
FIND w -- a f Like '?, but for w.
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
? a -- Print value of addr a
+! 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 -- a+1 c Fetch c from a and inc 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
with a1+u, going down.
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
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-
MOVEW notes: this word's purpose is to interface with word-
based systems. src and dst are addressed as *bytes* but u is a
*word* count. Every iteration increases src and dst by 2. When
you use it, be aware that default values for A!* and A@* are C!
and C@. If you don't adjust before using AMOVEW, you will get
weird results.
*word* count. Every iteration increases src and dst by 2. This
shouldn't be used on regular memory, it will yield weird
results. Use it with A! switch pointing to a word-based target.
# Arithmetic / Bits

View File

@ -85,12 +85,16 @@ need switches in regular code.
# Addressed devices
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
also a AMOVE word that is the same as MOVE but using A@ and A!.
are switch words and initially point to C@, C! and C,.
Addressed device words can be useful to "pipe" processing to
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 are Collapse OS' main access to permanent storage.