When using large arrays it would be nice to be able to adjust the array for a certain number of bytes per number. Mostly I want fast routines to read such adjusted multi byte numbers to singles on the stack and conversely to store singles in the array adjusted for a certain number of bytes. In a 64 bit system there is a need for other single number arrays than one byte (c@ c!) and eight bytes (@ !).
So how to implement
cs@ ( ad b -- n )
cs! ( n ad b -- )
where b is the number of bytes. The word cs! seems to work as
: cs! ( n ad b -- ) >r sp@ cell+ swap r> cmove drop ;
but how about cs@ and how to do it in pure ANS Forth without sp@ or similar words?
CS
stands for Control-Flow Stack operations, likecs-roll
etc, see The optional Programming-Tools word set. So usagecs
suffix for other semantics may confuse. – ruvimaddr @
give the same result asaddr 8 mb@
in case of cell size is 64 bits? I mean thatcmove
may lead to different result in such case. Also note that in general case byte order may differ in memory and on stack. – ruvim