annotate ppc/test/repchar.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 repchar(c: char; n: integer);
mike@0 2 var i: integer;
mike@0 3 begin
mike@0 4 if n > 0 then
mike@0 5 print_char(c);
mike@0 6 repchar(c, n-1)
mike@0 7 end
mike@0 8 end;
mike@0 9
mike@0 10 begin
mike@0 11 repchar('A', 3);
mike@0 12 repchar('B', 5);
mike@0 13 newline()
mike@0 14 end.
mike@0 15
mike@0 16 (*<<
mike@0 17 AAABBBBB
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 _repchar 4 0 0
mike@0 26 ! if n > 0 then
mike@0 27 LDLW 20
mike@0 28 JGTZ L1
mike@0 29 JUMP L3
mike@0 30 LABEL L1
mike@0 31 ! print_char(c);
mike@0 32 LDLC 16
mike@0 33 CONST 0
mike@0 34 GLOBAL lib.print_char
mike@0 35 PCALL 1
mike@0 36 ! repchar(c, n-1)
mike@0 37 LDLW 20
mike@0 38 CONST 1
mike@0 39 MINUS
mike@0 40 LDLC 16
mike@0 41 CONST 0
mike@0 42 GLOBAL _repchar
mike@0 43 PCALL 2
mike@0 44 LABEL L3
mike@0 45 RETURN
mike@0 46 END
mike@0 47
mike@0 48 PROC MAIN 0 0 0
mike@0 49 ! repchar('A', 3);
mike@0 50 CONST 3
mike@0 51 CONST 65
mike@0 52 CONST 0
mike@0 53 GLOBAL _repchar
mike@0 54 PCALL 2
mike@0 55 ! repchar('B', 5);
mike@0 56 CONST 5
mike@0 57 CONST 66
mike@0 58 CONST 0
mike@0 59 GLOBAL _repchar
mike@0 60 PCALL 2
mike@0 61 ! newline()
mike@0 62 CONST 0
mike@0 63 GLOBAL lib.newline
mike@0 64 PCALL 0
mike@0 65 RETURN
mike@0 66 END
mike@0 67
mike@0 68 ! End
mike@0 69 ]]*)