STX - Store from the X Register Command
This command will copy whatever value is currently in the X register into the specified memory location or port. You can store either decimal or hex values.
The STA command can also be modified by the X register to dynamically store to a memory location.
This is very similar to the STA command but stores the X register value instead of the accumulator.
Using the STX command doesn’t destroy the X register so you can do it repetitively without reloading. |
STX Argument (Store X register)
Copies the value held in the X register to a memory location pointed to by the Argument.
This command has no effect on the flag state.
Syntax
STX y
Where "y" is the memory location or port you want to store the value from the X register into. You may use a tilde memory, task port, or persistent memory.
It can be any value from 0-255.
Examples
Basic ways to store values.
{
LDX #0x01 //Loads the hex value of 0x01 into the X Register.
STX ~1 //Store that value into ~1 memory location.
LDX ~2 //Loads the value from ~2 into the X Register.
STX ~12 //Store that value into ~12 memory location.
LDX #15 //Loads the decimal value of 15 (hex 0x0F) into the X Register.
STX ~1 //Store that value into ~1 memory location.
LDX #StartValue //Loads the value of the "StartValue" constant into the X Register.
STX ~4 //Store that value into ~4 memory location.
LDX #3 //Loads the value of 3 into the X Register.
STX $22 //Store that value into $22 persistent memory location.
LDX #0x03 //Loads the value of 3 into the X Register.
STX $CurrentPreset //Stores it into the persistent memory named "CurrentPreset".
LDX #0 //Load a value of 0 into the X Register
STX ^18,0 //Store to the LED Port (18,0) to 0. Turning LED’s 1-8 off
}