diff --git a/blk/355 b/blk/355 index 434d27a..f8305a7 100644 --- a/blk/355 +++ b/blk/355 @@ -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, diff --git a/blk/367 b/blk/367 index 2f33879..f8c67a0 100644 --- a/blk/367 +++ b/blk/367 @@ -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 @ - ; diff --git a/blk/368 b/blk/368 index d1532ba..4928621 100644 --- a/blk/368 +++ b/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 -- ) 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 ; diff --git a/blk/385 b/blk/385 index 60dd886..db838a0 100644 --- a/blk/385 +++ b/blk/385 @@ -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 ; diff --git a/blk/386 b/blk/386 deleted file mode 100644 index 6249a9e..0000000 --- a/blk/386 +++ /dev/null @@ -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 ; diff --git a/cvm/forth.bin b/cvm/forth.bin index 27637a5..5a282b4 100644 Binary files a/cvm/forth.bin and b/cvm/forth.bin differ diff --git a/doc/avr.txt b/doc/avr.txt index fcfb5f1..60097c1 100644 --- a/doc/avr.txt +++ b/doc/avr.txt @@ -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@. diff --git a/doc/dict.txt b/doc/dict.txt index c30381e..1b9d50b 100644 --- a/doc/dict.txt +++ b/doc/dict.txt @@ -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 diff --git a/doc/usage.txt b/doc/usage.txt index 923e266..11d0ccc 100644 --- a/doc/usage.txt +++ b/doc/usage.txt @@ -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.