Back to table

One-stage pipeline

The following is a valid µOCCAM program that performs I/O. It implements a single-step pipeline: input values are held in the variable x and then retransmitted, until a zero comes along.

Program file: /public/cs3/web/ipptests/pipe.io

INT x:
SEQ
  stdin ? x
  WHILE x<>0
    SEQ
      stdout ! x
      stdin ? x

When provided with this input: /public/cs3/web/ipptests/pipe.in

5
4
3
2
1
0

it should generate the following output: /public/cs3/web/ipptests/pipe.out

==> 5
==> 4
==> 3
==> 2
==> 1