It looks pretty readable to me...but here are a couple thoughts which you may or may not find useful:
You could use the Forth 200x structures <http://www.forth200x.org/structures.html>:
0
field: ring-max
field: ring-length
field: ring-first
field: ring-item-size
0 +field ring-data
constant /ring
You could also then make a defining word for rings:
: init-ring ( max item-size ring -- )
dup >r ring-item-size !
r@ ring-max !
0 r@ ring-length !
0 r> ring-first ! ;
: ring ( max item-size "name" -- )
create here >r 2dup * cells /ring + allot r> init-ring ;
\ Ring for testing
4 3 ring r \ four items of three cells each
You could use 'bounds' and 'I' in your DO loops:
: bounds ( addr size -- end-addr start-addr ) over + swap ;
: foo ... ( addr size ) bounds DO I @ LOOP ... ;
It might possibly be helpful to define indexing words...not sure about
names, and haven't tried the refactoring, but maybe something like this?
: ring-index ( n ring -- offset )
dup >r ring-first @ + r> ring-max @ mod ;
: index>addr ( offset ring -- addr )
dup >r ring-item-size @ * r> ring-data + ;
: ring-item ( n ring -- addr )
tuck ring-index swap index>addr ;
--Josh