LDA - Load Data Accumulator Command
This is the command you use to load a value into the data accumulator.
The data accumulator is a temporary storage location where you can compare and manipulate a piece of data.
Every task has its own accumulator.
This is a single byte memory location where a value can be temporarily stored when the task has to use it.
The LDA command can also be modified by the X register to load from an array.
Using the CMP Command doesn’t destroy the accumulator so you can do it repetitively without reloading. |
Syntax
Basic Use
LDA x
Where "x" is the value or memory location you want to put into the accumulator. You may use a raw value (hex or decimal), tilde memory, task port, or persistent memory. You can even load from the message buffer using the @ symbol to specify which byte to load from.
It can be any value from 0-255.
Advanced Use
LDA Label,x
Where "Label" is the Label you want it to load from offset by the value in the X register.
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. |
-
LDA #x - Loads a fixed value (decimal or hex)
-
LDA ~x - Loads from a tilde memory
-
LDA $x - Loads from a persistent memory
-
LDA ^x - Loads from a task port
-
LDA @x - Loads from a the memory buffer
-
TXA Command - Transfers X register to the accumulator
-
SWAP Command - Swaps X register with the accumulator
-
LDA Label,x - Loads from an array offset by the X register
Examples
Example 1
Basic ways of loading to the accumulator.
{
LDA #11 //Loads the decimal value of 11 into the accumulator.
LDA #0x0A //Loads the Hex value of 10 into the accumulator.
LDA ~2 //Loads whatever is stored in tilde memory ~2 into the accumulator.
LDA ^35,1 //Lux level Hi byte into the accumulator.
LDA ^10,0 //Loads keyboard port. (check what button was pressed)
LDA $10 //Load value from persistent memory location 10.
LDA $Area4_State //Load value from persistent memory location named "Area4_State".
LDA #PrimaryArea //Load value of the constant named "PrimaryArea".
LDA @3 //Loads the opcode from the message buffer into the accumulator.
}
Example 2
Loading from the buffer.
{
Name="Temp Set Point Value Grabber"
start(0x1C,AreaTemp,0x0D,0x48,x,x,0xFF) //Start on Set Temp message.
LDA @4 //Grab the 5th byte of the last message. (the whole temp in C)
STA ~10 //Store it into memory.
...
}
Example 3
Loading from an array using the X register.
PresetOpcodeArray: Send2(0x00,0x01,0x02,0x03,0x0A,0x0B,0x0C,0x0D)
{
...
LDA ~15 //Load the preset number we want to send
ADD #4 //Add 4. Arrays have an index of 4
SWAP //Swap it into the X Register
LDA PresetOpcodeArray,x //Grab the correct opcode from the array
STA ~3 //Store it into the opcode byte of the classic preset message.
TX ~0,2,7 //Send the preset message
Null
...
}