needs lib/type num/math unit hal/muldiv : (one? ( op -- ?op f ) dup (i? if 1 = if drop 1 exit then then 0 ; : ?shiftable ( op -- op f ) dup (i? if ?dup if log2mod swap if drop else ( op n ) i) swap (R> R>) 1 exit then then then 0 ; : mulorshift, ( op -- ) (one? not if ?shiftable if <<, else *, then then ; : divorshift, ( op -- ) (one? not if ?shiftable if >>, else /mod, then then ; : ?modmask ( op -- op f ) dup (i? if ?dup if dup pow2? not if drop else ( op n ) 1- i) swap (R> R>) 1 exit then then then 0 ; : modorand, ( op -- ) ?modmask if &, else dup /mod, dup (R> REGS = if drop else ( op ) dup (dir? if S>) !, else (R> S) &) swap R>) @, then then then ; : [*n] ( n -- n ) n< i) mulorshift, ; immediate : [*n+] ( idx a -- a ) PSP) S>) @+, n< i) S>) mulorshift, S) &) +, ; immediate