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