annotate ppc/test/gcd.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 (* gcd.p *)
mike@0 2
mike@0 3 var x, y: integer;
mike@0 4
mike@0 5 begin
mike@0 6 x := 3 * 37; y := 5 * 37;
mike@0 7 while x <> y do
mike@0 8 if x > y then
mike@0 9 x := x - y
mike@0 10 else
mike@0 11 y := y - x
mike@0 12 end
mike@0 13 end;
mike@0 14 print_num(x); newline();
mike@0 15 end.
mike@0 16
mike@0 17 (*<<
mike@0 18 37
mike@0 19 >>*)
mike@0 20
mike@0 21 (*[[
mike@0 22 MODULE Main 0 0
mike@0 23 IMPORT Lib 0
mike@0 24 ENDHDR
mike@0 25
mike@0 26 PROC MAIN 0 0 0
mike@0 27 ! x := 3 * 37; y := 5 * 37;
mike@0 28 CONST 111
mike@0 29 STGW _x
mike@0 30 CONST 185
mike@0 31 STGW _y
mike@0 32 ! while x <> y do
mike@0 33 JUMP L2
mike@0 34 LABEL L1
mike@0 35 ! if x > y then
mike@0 36 LDGW _x
mike@0 37 LDGW _y
mike@0 38 JLEQ L5
mike@0 39 ! x := x - y
mike@0 40 LDGW _x
mike@0 41 LDGW _y
mike@0 42 MINUS
mike@0 43 STGW _x
mike@0 44 JUMP L2
mike@0 45 LABEL L5
mike@0 46 ! y := y - x
mike@0 47 LDGW _y
mike@0 48 LDGW _x
mike@0 49 MINUS
mike@0 50 STGW _y
mike@0 51 LABEL L2
mike@0 52 LDGW _x
mike@0 53 LDGW _y
mike@0 54 JNEQ L1
mike@0 55 ! print_num(x); newline();
mike@0 56 LDGW _x
mike@0 57 CONST 0
mike@0 58 GLOBAL lib.print_num
mike@0 59 PCALL 1
mike@0 60 CONST 0
mike@0 61 GLOBAL lib.newline
mike@0 62 PCALL 0
mike@0 63 ! end.
mike@0 64 RETURN
mike@0 65 END
mike@0 66
mike@0 67 GLOVAR _x 4
mike@0 68 GLOVAR _y 4
mike@0 69 ! End
mike@0 70 ]]*)