^59 - The Dipswitch Port
This read only port contains the state of all the dipswitches on a device in banks of 8. The value is a bitfield with each contact represented by a single bit.
Syntax
LDA ^59,x
Where x is the bank of dipswitches you want the status of.
LDA ^59,0 will give the state of dipswitches 1-8.
LDA ^59,1 will give the state of dipswitches 9-16.
Examples
Example 1
Example showing using SHR to interrogate one dipswitch at a time.
Task1()
{
Name="Occupancy Trigger" //Checks the state of dipswitch 3.
LDA ^59,0 //Get the dipswitch port
SHR //Move dipswitch 1 into the carry flag
SHR //Move dipswitch 2 into the carry flag
SHR //Move dipswitch 3 into the carry flag
BRC Occupancy //If carry flag is set sensor saw motion
...
}
Example 2
{
LDA ^59,0 //Load the first 8 dipswitchs
AND #0x04 //AND it with 0x04 and mask out all but dipswitch 3
BRZ ThreeOff //If off branch, if not assume on
...
}