MPE/iX Shell and Utilities Reference Manual, Vol 1

dc(1) MPE/iX Shell and Utilities dc(1)
Other Commands
!command
executes the rest of the line as a system command. For example,
!cp file1 file2
executes the given cp command.
? reads an input line from the input source (for example, the terminal) and executes
that line. This is useful when you are executing a command string but want to obtain
input in the middle of the string.
EXAMPLE
The following sequence of commands prints out the first 12 elements of the Fibonacci
sequence. In this sequence, the first two values are 1, and each subsequent value is the sum of
the previous two values. Registers a and b hold the two most recent values of the sequence;
new values are calculated in the stack. Register z holds the code needed to calculate new val-
ues, and register c holds a count of how many values have been printed.
1sa
1sb
2sc
[lalb+plbsasblc1+dsc13>z]sz
lapsxlppsxlzx
The first three lines set up registers a and b with the value 1, and c with the count of values
that have already been calculated (the first two). The next line loads z with the main code to
execute. This code loads the values in a and b, adds them and prints the result, moves the
value of b to a, then saves the newly calculated value in b. The count in c is then incre-
mented; the commands
dsc
make a duplicate copy of the count and save this duplicate back in c. The final part of the
code checks the count to see if it is less than 13; if this is true, the contents of z are executed
again to get the next value. The final line in the program prints the first two values of the
sequence and then executes the code in z.
1-164 Commands and Utilities