beautypg.com

Stack commands, Mathematical commands (unary), Mathematical commands (binary) – Pololu Maestro User Manual

Page 54

background image

Stack commands

command

stack

effect

description

DEPTH

+1

gets the number of numbers on the stack

DROP

-1

removes the top number from the stack

DUP

+1

duplicates the top number

OVER

+1

duplicates the number directly below the top, copying it onto the top

PICK

-1,+1

takes a number n between 0 and 63, then puts the nth number below the top onto the stack
(0 PICK is equivalent to DUP)

SWAP

a,b →
b,a

swaps the top two numbers

ROT

a,b,c

b,c,a

permutes the top three numbers so that the 3rd becomes the top and the others move down
one position

ROLL

-1,*

takes a number n, then permutes the top n+1 numbers so that the n+1th becomes the top and
all of the others move down one

PEEK

-1,+1

(Mini Maestro 12, 18, and 24 only) takes a number n, then copies the nth value on the stack
(measured from the bottom) to the top of the stack

POKE

-2,+1

(Mini Maestro 12, 18, and 24 only) takes a number n, then removes the next value from the
stack and puts it at the nth location on the stack (measured from the bottom)

Mathematical commands (unary)

These commands take a single argument from the top of the stack, then return a single value as a result. Some of these
have equivalents in C (and most other languages), listed in the “C equivalent” column below. We use “false” to mean
0 and “true” to mean any non-zero value. A command returning “true” always returns a 1.

command

C equivalent

description

BITWISE_NOT

~

inverts all of the bits in its argument

LOGICAL_NOT !

replaces true by false, false by true

NEGATE

replaces x by -x

POSITIVE

none

true if and only if the argument is greater than zero

NEGATIVE

none

true if and only if the argument is less than zero

NONZERO

none

true (1) if and only if the argument is true (non-zero)

Mathematical commands (binary)

These commands take two arguments from the top of the stack, then return a single value as a result. The order of
the arguments, when important, is the standard one in mathematics; for example, to compute 1 – 2, you write “1 2
MINUS”. These commands all have equivalents in C (and most other languages), listed in the “C equivalent” column
below.

Pololu Maestro Servo Controller User's Guide

© 2001–2014 Pololu Corporation

6. The Maestro Scripting Language

Page 54 of 73