comparison ppc/test/callshare.p @ 0:bfdcc3820b32

Basis
author Mike Spivey <mike@cs.ox.ac.uk>
date Thu, 05 Oct 2017 08:04:15 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:bfdcc3820b32
1 var x, y: integer;
2
3 proc f(n: integer): integer;
4 begin x := x + n; return x end;
5
6 begin
7 x := 2;
8 y := f(3) + 1;
9 y := f(3) + 1;
10 print_num(x); newline()
11 end.
12
13 (*<<
14 8
15 >>*)
16
17 (*[[
18 MODULE Main 0 0
19 IMPORT Lib 0
20 ENDHDR
21
22 PROC _f 0 0 0
23 ! begin x := x + n; return x end;
24 LDGW _x
25 LDLW 16
26 PLUS
27 STGW _x
28 LDGW _x
29 RETURNW
30 END
31
32 PROC MAIN 0 0 0
33 ! x := 2;
34 CONST 2
35 STGW _x
36 ! y := f(3) + 1;
37 CONST 3
38 CONST 0
39 GLOBAL _f
40 PCALLW 1
41 CONST 1
42 PLUS
43 STGW _y
44 ! y := f(3) + 1;
45 CONST 3
46 CONST 0
47 GLOBAL _f
48 PCALLW 1
49 CONST 1
50 PLUS
51 STGW _y
52 ! print_num(x); newline()
53 LDGW _x
54 CONST 0
55 GLOBAL lib.print_num
56 PCALL 1
57 CONST 0
58 GLOBAL lib.newline
59 PCALL 0
60 RETURN
61 END
62
63 GLOVAR _x 4
64 GLOVAR _y 4
65 ! End
66 ]]*)