Copying arrays on the word RAM #
The seven-register copy routine charges every address calculation, load, store, increment, and loop test. Source and destination may be disjoint in either order or equal. It is a fixed program: neither the length nor either address is baked into the code.
Main definitions #
Cslib.WordRAM.ArrayCopy.src,Cslib.WordRAM.ArrayCopy.dst,Cslib.WordRAM.ArrayCopy.len,Cslib.WordRAM.ArrayCopy.idx,Cslib.WordRAM.ArrayCopy.addr,Cslib.WordRAM.ArrayCopy.value,Cslib.WordRAM.ArrayCopy.one: the seven registers of the copy routine.Cslib.WordRAM.ArrayCopy.body,Cslib.WordRAM.ArrayCopy.program: single-word loop body and full copying program between addresses supplied in registers.Cslib.WordRAM.ArrayCopy.copyPrefix: mathematical specification of the writes.
Main results #
Cslib.WordRAM.ArrayCopy.exec: copyingnwords within7 * n + 4instructions, preserving the source and all cells outside the destination.Cslib.WordRAM.ArrayCopy.exec_of_separated_or_eq: the same native program also supports disjoint blocks in the reverse address order or identical source and destination.
References #
Copying zero words leaves memory unchanged.
Reading within the copied destination block returns the corresponding source word.
Source base, destination base, length, index, temporary address, value, and one.
Instances For
Five data instructions per copied word.
Instances For
A fixed copying program with all three parameters in registers.
Instances For
Low-level structured copying charges register setup and all loop instructions, excluding
the final halt. The one-past-end addresses must fit a word. Boundedness of the input memory and
registers is a separate premise when using ExecWithin.bounded to obtain bounded-word execution.