annotate 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
rev   line source
mike@0 1 var x, y: integer;
mike@0 2
mike@0 3 proc f(n: integer): integer;
mike@0 4 begin x := x + n; return x end;
mike@0 5
mike@0 6 begin
mike@0 7 x := 2;
mike@0 8 y := f(3) + 1;
mike@0 9 y := f(3) + 1;
mike@0 10 print_num(x); newline()
mike@0 11 end.
mike@0 12
mike@0 13 (*<<
mike@0 14 8
mike@0 15 >>*)
mike@0 16
mike@0 17 (*[[
mike@0 18 MODULE Main 0 0
mike@0 19 IMPORT Lib 0
mike@0 20 ENDHDR
mike@0 21
mike@0 22 PROC _f 0 0 0
mike@0 23 ! begin x := x + n; return x end;
mike@0 24 LDGW _x
mike@0 25 LDLW 16
mike@0 26 PLUS
mike@0 27 STGW _x
mike@0 28 LDGW _x
mike@0 29 RETURNW
mike@0 30 END
mike@0 31
mike@0 32 PROC MAIN 0 0 0
mike@0 33 ! x := 2;
mike@0 34 CONST 2
mike@0 35 STGW _x
mike@0 36 ! y := f(3) + 1;
mike@0 37 CONST 3
mike@0 38 CONST 0
mike@0 39 GLOBAL _f
mike@0 40 PCALLW 1
mike@0 41 CONST 1
mike@0 42 PLUS
mike@0 43 STGW _y
mike@0 44 ! y := f(3) + 1;
mike@0 45 CONST 3
mike@0 46 CONST 0
mike@0 47 GLOBAL _f
mike@0 48 PCALLW 1
mike@0 49 CONST 1
mike@0 50 PLUS
mike@0 51 STGW _y
mike@0 52 ! print_num(x); newline()
mike@0 53 LDGW _x
mike@0 54 CONST 0
mike@0 55 GLOBAL lib.print_num
mike@0 56 PCALL 1
mike@0 57 CONST 0
mike@0 58 GLOBAL lib.newline
mike@0 59 PCALL 0
mike@0 60 RETURN
mike@0 61 END
mike@0 62
mike@0 63 GLOVAR _x 4
mike@0 64 GLOVAR _y 4
mike@0 65 ! End
mike@0 66 ]]*)