Programming Reference

Commands

The - operator is used to subtract a number from the value stored in a register, or to subtract the value of one register from another.

When used with 4-bit registers, Mi can be M0 - M15 and can store numbers from 0 to 15.
There are sixteen 4-bit registers.

Code Example

Meaning

M2=M2-3

Subtract the integer number 2 from the value stored in 4-bit register M2.

M2=M3-2

Subtract the integer number 2 from the value stored in M3 and store the result in 4-bit register M2.

M2=M3-M4

Subtract the value stored in M4 from the value stored in M3 and store the result in 4-bit register M2..

 

When used with 8-bit registers, Xi can be X0 - X7 and can store numbers from 0 to 255.
There is a maximum of eight 8-bit registers.

Code Example

Meaning

X4=X4+127

Subtract the integer number 127 from the value stored in 8-bit register X4.

X4=X5+127

Subtract the integer number 127 from the value stored in X5 and store the result in 8-bit register X4.

X4=X5+X6

Subtract the value stored in X6 from the value stored in X5 and store the result in 8-bit register X4.

 

Numbers can also be represented in binary or hex format.

Code Example

Meaning

X4=X4-01111111b

Subtract the binary number 01111111 from the value stored in 8-bit register X4.

M0=M0+0Ah

Subtract the hex number A from the value stored in M0.

 

 

The + operator is used to add a number to the value stored in a register, or to add the value of two registers together.

When used with 4-bit registers, Mi can be M0 - M15 and can store numbers from 0 to 15.
There are sixteen 4-bit registers.

Code Example

Meaning

M2=M2+3

Add the integer number 2 to the value stored in 4-bit register M2.

M2=M3+2

Add the integer number 2 to the value stored in M3 and store the result in 4-bit register M2.

M2=M3+M4

Add the value stored in M4 to the value stored in M3 and store the result in 4-bit register M2..

 

When used with 8-bit registers, Xi can be X0 - X7 and can store numbers from 0 to 255.
There is a maximum of eight 8-bit registers.

Code Example

Meaning

X4=X4+127

Add the integer number 127 to the value stored in 8-bit register X4.

X4=X5+127

Add the integer number 127 to the value stored in X5 and store the result in 8-bit register X4.

X4=X5+X6

Add the value stored in X6 to the value stored in X5 and store the result in 8-bit register X4.

 

Numbers can also be represented in binary or hex format.

Code Example

Meaning

X4=X4+01111111b

Add the binary number 01111111 to the value stored in 8-bit register X4.

M0=M0+0Ah

Add the hex number A to the value stored in M0.

 

 

This command subtracts a number from the value stored in register Mi, where Mi is M0 - M15.
Mi registers are 4-bits wide and can store numbers from 0 to 15.
There are sixteen 4-bit registers.

Subtraction can be performed on 8-bit registers using Xi, where Xi is X0 - X7.
Xi registers are 8-bits wide and can store numbers from 0 to 255.
There is a maximum of eight 8-bit registers.

Code Example

Meaning

M2=M2-3

Subtract the integer number 2 from the value stored in 4-bit register M2.

M2=M2-0011b

Subtract the binary number 0011 from the value stored in 4-bit register M2.

M2=M2-0Ah

Subtract the hex number A from the value stored in 4-bit register M2.

X4=X4-127

Subtract the integer number 127 from the value stored in 8-bit register X4.

X4=X4-01111111b

Subtract the binary number 01111111 from the value stored in 8-bit register X4.

X4=X4-07Fh

Subtract the hex number 7F from the value stored in 8-bit register X4.

 

This command adds a number to the value stored in register Mi, where Mi is M0 - M15.
Mi registers are 4-bits wide and can store numbers from 0 to 15.
There are sixteen 4-bit registers.

Addition can be performed on 8-bit registers using Xi, where Xi is X0 - X7.
Xi registers are 8-bits wide and can store numbers from 0 to 255.
There is a maximum of eight 8-bit registers.

Code Example

Meaning

M2=M2+3

Add the integer number 2 to the value stored in 4-bit register M2.

M2=M2+0011b

Add the binary number 0011 to the value stored in 4-bit register M2.

M2=M2+0Ah

Add the hex number A to the value stored in 4-bit register M2.

X4=X4+127

Add the integer number 127 to the value stored in 8-bit register X4.

X4=X4+01111111b

Add the binary number 01111111 to the value stored in 8-bit register X4.

X4=X4+07Fh

Add the hex number 7F to the value stored in 8-bit register X4.

This command writes 4 bits to output port Pn.

Code Example

Meaning

P3=[1 1 1 1]

P3=[0 0 0 1]

P3=[x 1 x x]

Set all pins on port P3 to 1.

Set pin P3.0 to 1 and set the other P3 pins to 0.

Set pin P3.2 to 1 and leave the other P3 pins at their current state.

 

Special Notes:

For device names SNC21030 - 21085, Pn can be P1, P2, or P3.
For device names SNC21120 - 21340, Pn can be P1, P2, P3, or P6.
There is no 8-bit version of this command.

 

This command writes the value in 4-bit register Mi to output port Pn.
Mi can be M0 - M15.
For device names SNC21030 - 21085, Pn can be P1, P2, or P3.
For device names SNC21120 - 21340, Pn can be P1, P2, P3, or P6.

Code Example

Meaning

P3=M2

Write the value of 4-bit register M2 to output port P3.

 

Special Notes:

There is no 8-bit version of this command.

 

This command reads input port Pn and loads that value into register Mi.
Mi can be M0 - M15.
For device names SNC21030 - 21085, Pn can be P1, P2, or P3.
For device names SNC21120 - 21340, Pn can be P1, P2, P3, or P6.

Code Example

Meaning

M2=P1

Read input port P1 and store that value into 4-bit register M2.

 

Special Notes:

There is no 8-bit version of this command.

 

This command sets the nth bit in register Mi to 0 or 1.

Bits in 4-bit registers can be set using Mi(n), where Mi is M0 - M15 and n is 0 - 3.
There are sixteen 4-bit registers.

Bits in 8-bit registers can be set using Xi(n), where Xi is X0 - X7 and n is 0 - 7.
There is a maximum of eight 8-bit registers.

Code Example

Meaning

M2(0)=1

Set bit 0 in 4-bit register M2 to 1.

M15(3)=0

Set bit 3 in 4-bit register M15 to 0.

X4(7)=1

Set bit 7 in 8-bit register M4 to 1.

X7(5)=0

Set bit 5 in 8-bit register M7 to 0.

This command loads 4-bit register Mi with random variable Randn.
Mi can be M0 - M15.
Randn can be Rand0 or Rand1.

Code Example

Meaning

M2=Rand0

Load 4-bit register M2 with random variable Rand0.

M0=Rand1

Load 4-bit register M0 with random variable Rand1.

 

Special Notes:

Random variables must be first declared in the [random] section of the program.

There is no 8-bit version of this command.

 

This command sets one register equal to another register.

When used with 4-bit registers, Mi and Mj can be M0 - M15.
There are sixteen 4-bit registers.

When used with 8-bit registers, Xi and Xj can be X0 - X7.
There is a maximum of eight 8-bit registers.

Code Example

Meaning

M2=M0

Copy the value stored in 4-bit register M0 into 4-bit register M2.

X4=X5

Copy the value stored in 8-bit register X5 into 8-bit register X4.

Storage: 84 seconds of audio at 12kHz sampling rate
Ports Available: P1, P2, P3, and P6
Total number of I/O: 16
PWM Outputs Available: 4 (out of 12 total) - PWM outputs use port P3
Audio Output: PWM and DAC


Special Notes:

If you select the SNC21168 device name for your program, you have the option of using PWM or DAC for the
audio output. Specify the audio output type in the program by using the PPDAC command for PWM output or
the DAC command for DAC output. Failure to specify audio output type in the program will result in an error
message.