# 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

<br>

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

&#x20;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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://holy-city-audio.gitbook.io/spincad-designer/tips-and-tricks/optimizing-fv-1-assembly-code-generated-by-spincad-designer.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
