annotate ppc/test/baz.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 (* baz.p *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
2
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
3 var x: integer;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
5 proc baz(u: integer): integer;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
6 begin
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
7 x := u;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
8 return x
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
9 end;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
10
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
11 begin
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
12 print_num(baz(37)); newline();
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
13 print_num(x); newline()
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
14 end.
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
15
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
16 (*<<
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
17 37
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
18 37
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
19 >>*)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
20
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
21 (*[[
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
22 MODULE Main 0 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
23 IMPORT Lib 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
24 ENDHDR
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
25
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
26 PROC _baz 0 0 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
27 ! x := u;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
28 LDLW 16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
29 STGW _x
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
30 ! return x
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
31 LDGW _x
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
32 RETURNW
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
33 END
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
34
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
35 PROC MAIN 0 0 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
36 ! print_num(baz(37)); newline();
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
37 CONST 37
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
38 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
39 GLOBAL _baz
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
40 PCALLW 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
41 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
42 GLOBAL lib.print_num
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
43 PCALL 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
44 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
45 GLOBAL lib.newline
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
46 PCALL 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
47 ! print_num(x); newline()
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
48 LDGW _x
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
49 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
50 GLOBAL lib.print_num
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
51 PCALL 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
52 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
53 GLOBAL lib.newline
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
54 PCALL 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
55 RETURN
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
56 END
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
57
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
58 GLOVAR _x 4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
59 ! End
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
60 ]]*)