annotate ppc/test/nest.p @ 0:bfdcc3820b32

Basis
author Mike Spivey <mike@cs.ox.ac.uk>
date Thu, 05 Oct 2017 08:04:15 +0100
parents
children
rev   line source
0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
1 proc f(x: integer): integer; begin return 2*x end;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
2 begin print_num(f(f(3))); newline() end.
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
3
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
4 (*<<
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
5 12
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
6 >>*)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
7
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
8 (*[[
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
9 MODULE Main 0 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
10 IMPORT Lib 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
11 ENDHDR
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
12
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
13 PROC _f 0 0 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
14 ! proc f(x: integer): integer; begin return 2*x end;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
15 CONST 2
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
16 LDLW 16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
17 TIMES
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
18 RETURNW
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
19 END
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
20
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
21 PROC MAIN 0 0 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
22 ! begin print_num(f(f(3))); newline() end.
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
23 CONST 3
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
24 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
25 GLOBAL _f
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
26 PCALLW 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
27 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
28 GLOBAL _f
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
29 PCALLW 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
30 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
31 GLOBAL lib.print_num
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
32 PCALL 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
33 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
34 GLOBAL lib.newline
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
35 PCALL 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
36 RETURN
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
37 END
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
38
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
39 ! End
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
40 ]]*)