annotate ppc/test/prob3-3.p @ 1:b5139af1a420 tip basis

Fixed permissions on compile scripts
author Mike Spivey <mike@cs.ox.ac.uk>
date Fri, 13 Oct 2017 17:27:58 +0100
parents bfdcc3820b32
children
rev   line source
mike@0 1 proc double(x: integer): integer;
mike@0 2 begin
mike@0 3 return x + x
mike@0 4 end;
mike@0 5
mike@0 6 proc apply3(proc f(x:integer): integer): integer;
mike@0 7 begin
mike@0 8 return f(3)
mike@0 9 end;
mike@0 10
mike@0 11 begin
mike@0 12 print_num(apply3(double));
mike@0 13 newline()
mike@0 14 end.
mike@0 15
mike@0 16 (*<<
mike@0 17 6
mike@0 18 >>*)
mike@0 19
mike@0 20 (*[[
mike@0 21 MODULE Main 0 0
mike@0 22 IMPORT Lib 0
mike@0 23 ENDHDR
mike@0 24
mike@0 25 PROC _double 0 0 0
mike@0 26 ! return x + x
mike@0 27 LDLW 16
mike@0 28 LDLW 16
mike@0 29 PLUS
mike@0 30 RETURNW
mike@0 31 END
mike@0 32
mike@0 33 PROC _apply3 0 0 0
mike@0 34 ! return f(3)
mike@0 35 CONST 3
mike@0 36 LDLW 20
mike@0 37 LDLW 16
mike@0 38 PCALLW 1
mike@0 39 RETURNW
mike@0 40 END
mike@0 41
mike@0 42 PROC MAIN 0 0 0
mike@0 43 ! print_num(apply3(double));
mike@0 44 CONST 0
mike@0 45 GLOBAL _double
mike@0 46 CONST 0
mike@0 47 GLOBAL _apply3
mike@0 48 PCALLW 2
mike@0 49 CONST 0
mike@0 50 GLOBAL lib.print_num
mike@0 51 PCALL 1
mike@0 52 ! newline()
mike@0 53 CONST 0
mike@0 54 GLOBAL lib.newline
mike@0 55 PCALL 0
mike@0 56 RETURN
mike@0 57 END
mike@0 58
mike@0 59 ! End
mike@0 60 ]]*)