BASIC Stamp Programming |
'{ $STAMP BS2 } DEBUG "Hello World!" 'Test message END 'End program and put stamp in low-power mode |
'{ $STAMP BS2 } mybit VAR BIT 'Value can be 0 or 1 mynib VAR NIB 'Value can be 0 to 15 mybyte VAR BYTE 'Value can be 0 to 255 myword VAR WORD 'Value can be 0 to 65535 myarray VAR BYTE(2) 'An array of two bytes |
'{ $STAMP BS2 } cat VAR BYTE 'cat is byte-sized variable tabby VAR cat 'tabby is an alias to cat rhino VAR WORD 'A 16-bit variable head VAR rhino.HIGHBYTE 'Alias to upper byte of rhino using modifier HIGHBYTE tail VAR rhino.LOWBYTE 'Alias to lower byte of rhino using modifier LOWBYTE |
'{ $STAMP BS2 } midinoteon CON 144 'MIDI note on status byte (for channel = 0) midinoteoff CON 128 midicontchng CON 176 midiprogchng CON midicontchng+16 |
'{ $STAMP BS2 } LetterA CON "A" 'ASCII code for A (65) Cheers CON 3 'Decimal Hex128 CON $80 'Hexadecimal FewBits CON %1101 'Binary |
ABS | absolute value |
COS | cosine in two's compliment binary radians |
DCD | 2n-power decoder |
~ | inverse |
- | negative |
NCD | priority encoder of a 16-bit value |
SIN | sine in two's compliment binary radians |
SQR | square root |
+ | addition |
- | subtraction |
* | multiplication |
** | multiplication (returns upper 16-bits) |
*/ | multiply by 8-bit integer, 8-bit fraction |
/ | division |
// | modulus (remainder of division |
MIN | limits a value to a specified low |
MAX | limits a value to a specified high |
DIG | returns specified digit of number |
<< | left shift |
>> | right shift |
REV | reverse specified number of bits |
& | bitwise AND |
| | bitwise OR |
^ | bitwise XOR |
&/ | logical AND NOT |
|/ | logical OR NOT |
^/ | logical XOR NOT |
'{ $STAMP BS2 } MyBytes VAR BYTE(10) ' Define 10-byte array. Index VAR NIB ' Define normal nibble variable. FOR Index = 0 TO 9 ' Repeat with Index= 0,1,2...9 MyBytes(Index) = Index * 13 ' Write index*13 to each cell of array. NEXT FOR Index = 0 TO 9 ' Repeat with Index= 0,1,2...9 DEBUG ? MyBytes(Index) ' Show contents of each cell. NEXT STOP |