ADD - Add X to the Accumulator Command

Adds the argument to the value currently in the accumulator value and stores it in the accumulator.

Syntax

Basic Use

ADD x
Where "x" is the value or memory location you want to add to the accumulator. You may use a raw value (hex or decimal), tilde memory, task port, or persistent memory.

Advanced Use

ADD Label,x
Where "Label" is the Label you want it to compare to offset by the value in the X register.
This technique is used to dynamically use a value from an array. Not sure I can think of a valid use for this. If you use it let us know so we can update the examples.

Arrays have an index of 4 so you must load a value of 5 into the X register to get the first value in the array. An array does not need to be in a task. It can be before or in between tasks in the task editor.

Example

Example 1

Basic uses.

{
LDA #33    //Load a value of 1 into the accumulator
ADD #10   //Add 10 to the value in the Accumulator
STA ~4    //Store the new value of 43 into tilde memory ~4

LDA ~5    //Copy the value in tilde 5 to the Accumulator
ADD #10   //Add the fixed decimal value 10 to the value in the Accumulator

LDA ~5    //Copy the value in tilde 5 to the Accumulator
ADD #0x13 //Add the fixed decimal value 18 to the value in the Accumulator

LDA ~3    //Load the value from ~3 into the accumulator
ADD #5    //Add the fixed decimal value 5 to the value in the Accumulator
STA ~3    //Store the value of 5 plus the previous value back into ~3

LDA ~3    //Load the value from ~3 into the accumulator
ADD $14   //Add the value in persistent memory 14.
STA ~3    //Store the new value back into ~3

LDA #0    //Load the value from 0
ADD ~14   //Add the value in tilde memory 14.
STA ~3    //Store the value into ~3
}

Example 2

Advanced use case.

{
LDX ~13     //Load value in ~13 into the x register
LDA ~12     //Load the value of ~12 into the accumulator
ADD Array,x //Add the value from our array in position equal to the value in ~13 minus 4
STA ~4      //Store the new value into tilde memory ~4
}