# Analyzing a simple SpinCAD Builder file

We'll start with an easy one.  The "Absolute Value" block has only one instruction, "absa".

![](https://c10.patreonusercontent.com/4/patreon-media/p/post/70492245/1da9f7887fc94e079b7ae18b544ba52e/eyJ3ZWJwIjowfQ%3D%3D/1.jpg?token-time=1682121600\&token-hash=4rDXQ_1tlONYuwuNCdZ-aHHRdY3CorLe29i7pBTZQdk%3D)

![](https://c10.patreonusercontent.com/4/patreon-media/p/post/70492245/c6128840c4214fd1be2a787e581e2efb/eyJ3ZWJwIjowfQ%3D%3D/1.jpg?token-time=1682121600\&token-hash=HDTJgCRPreKj21x-mPhPN7IwL5OXzQFVBf8GJxtExRc%3D)

Source code can be found [here](https://github.com/HolyCityAudio/SpinCAD-Designer/blob/master/src/SpinCADBuilder/Absa.spincad).&#x20;

<figure><img src="/files/C2yhv8vvEOvSUzNNhUf6" alt=""><figcaption></figcaption></figure>

We'll go one line at a time.

> @name AbsoluteValue

**@name** sets the name of the block.

> @color "0xf2f224"

**@color** sets the 24-bit value for the block's color.

> @controlInput input Input

**@controlInput** defines a register variable name and displayed pin name for a control input.  Control inputs are located on the left side of a block.

> @controlOutput output1 Output

**@controlOutput** defines a register variable name and displayed pin name for a control input.  Control outputs are located on the right side of a block.

> equ   output1     reg0

This is the first Spin ASM statement.  We have to a to the very least, declare a register for each output pin, whether audio or control, in the block.   Note that the actual register that will be used will depend on the other blocks being used and how many registers were allocated prior to this one.

The input pin variable is reserved to be replaced by a register value from the previous block in the model after the blocks are sorted into a model.

> @isPinConnected Input

**@isPinConnected** lets you control blocks of code generation depending on whether certain pins are connected.  In this case, there is only one input pin, so we see if that's connected.  If not, we don't generate any code at all.  Note that there are also @else (optional) and @endif statements which you will have to line up to be sure about what is or isn't going to be generated.

> rdax    input,1    ;read input signal

here we get the value from the previous block into the ACC.

> absa

Oh, hooray!  absa to the rescue!

> wrax    output1,0

Write the result in the ACC to the output register.  I left out the comment in the actual source code as it's obviously left over from something else and makes no sense!

> @setOutputPin Output output1

**@setOutputPin** does something special, I'm sure.  I just don't remember exactly what it is.  The graphical editor does need to distinguish input and output pins so as to only allow a connection between one of each.  No input-input or output-output.  So that might be it.

> @endif

**@endif** is the matching conditional for the *@isPinConnected Input* statement above.

So, that's it!  This example has no control panel.

It's trivial examples like this one that highlight the overhead of SpinCAD generated code.  We really probably only needed one instruction but got three and used up an extra register.  Larger blocks suffer less proportionately, as it's still just an instruction to read an input, one to write the output, and a register per output.  That said, if needed, those things are not that hard to optimize by hand.


---

# 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/beneath-the-hood/analyzing-a-simple-spincad-builder-file.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.
