maxmgv documentation
John Strawn
9/11/87
Suppose that register a contains the maximum of the vector so
far. x0 contains the current vector element. There is a CMPM
instruction that should at least be considered. Here is one
solution:
move x:(r1),a
abs a x:(r1)+n1,b
do x1,foo2
cmpm b,a
jge foo1
abs b
tfr b,a
foo1 move x:(r1)+n1,b
foo2 nop
This cannot be contracted. Remember that the Tcc instruction
does not allow a parallel move. An inner loop like this takes 7
instructions without a jump, 5 instructions with a jump. This
solution suffers from the jump.
A quicker solution is to ignore the cmpm instruction and to
calculate the absolute value by hand:
move x:(r1),a
abs a x:(r1)+n1,b
do x1,foo3
abs b
move b,x0
cmp b,a x:(r1)+n1,b
foo3 tlt x0,a
This solution takes only 4 instructions per pass through the loop.