Optimizing FV-1 assembly code generated by SpinCAD Designer

Some of the more seasoned FV-1 effects developers have noticed that SpinCAD Designer allocates registers where they are not needed, chewing up precious instructions (there are only 128 spaces available) and registers (only 32 available). The main reason for this is that registers are used at the output points of blocks to hold values to be passed to the input pins of downstream blocks. In many cases, this is not ultimately needed.

SpinCAD Designer does let you create a patch which over-allocates resources, but the FV-1 will not be able to assemble or load such a patch.

Most of the time this is not a big deal, because many effects can be created without approaching these limits, but if you ABSOLUTELY HAVE TO GET EVERY LAST DROP OF PERFORMANCE out of the chip (yes, I can see that many of you are raising your hands and nodding "uh-huh" in a slightly smug way) then read on!

Let's look at an example:

; ------- Smoother

RDAX 37, 1.0

RDFX 40, 0.0700

WRAX 40, 0.0

; ------- Scale/Offset

RDAX 40, 1.0

SOF 0.2700, 0.7300

WRAX 41, 0.0

It's pretty clear that these adjacent instructions:

WRAX 40, 0.0

RDAX 40, 1.0

can be replaced by:

WRAX 40, 1.0

This saves one instruction. It doesn't save a register yet because register 40 is already used by the RDFX instruction so we can't get rid of it.

So, how do you find these patterns in general, to modify them?

Case 1:

If there is a pair of adjacent instructions of the form:

index n: wrax reg, 0.0

index n+1: rdax reg, 1.0

AND there is no reference to "reg" by any instruction elsewhere in the entire program, then these two instructions can safely be eliminated, and the allocation of reg can also be eliminated.

Saves two instructions and one register

Case 2:

If there is a pair of adjacent instructions of the form:

index n: wrax reg, 0.0

index n+1: rdax reg, 1.0

and THIS TIME there IS a reference to "reg" by an instruction elsewhere in the program, then these two instructions can safely be replaced by:

wrax reg, 1.0

Saves one instruction.

Case 3:

If there is a pair of adjacent instructions of the form:

index n: wrax reg, 0.0

index n+1: rdax reg, inputGain

AND reg is not used elsewhere in the program,

these can be replaced by the following:

sof inputGain, 0.0

Saves one instruction.

inputGain can be either a variable reference or a constant other than 1.0.

Last updated