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