comparison lab4/test/rep1.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 var i, j, k: integer;
2 begin
3 i := 0;
4 repeat
5 j := 1;
6 repeat
7 j := j+1; k := k+1;
8 until j > i;
9 i := i+1
10 until i > 10;
11 print_num(k); newline()
12 end.
13
14 (*<<
15 56
16 >>*)
17
18 (*[[
19 @ picoPascal compiler output
20 .include "fixup.s"
21 .global pmain
22
23 .text
24 pmain:
25 mov ip, sp
26 stmfd sp!, {r4-r10, fp, ip, lr}
27 mov fp, sp
28 @ i := 0;
29 mov r0, #0
30 set r1, _i
31 str r0, [r1]
32 .L2:
33 @ j := 1;
34 mov r0, #1
35 set r1, _j
36 str r0, [r1]
37 .L4:
38 @ j := j+1; k := k+1;
39 set r4, _j
40 ldr r0, [r4]
41 add r5, r0, #1
42 str r5, [r4]
43 set r4, _k
44 ldr r0, [r4]
45 add r6, r0, #1
46 str r6, [r4]
47 @ until j > i;
48 set r4, _i
49 ldr r7, [r4]
50 cmp r5, r7
51 ble .L4
52 @ i := i+1
53 add r5, r7, #1
54 str r5, [r4]
55 cmp r5, #10
56 ble .L2
57 @ print_num(k); newline()
58 mov r0, r6
59 bl print_num
60 bl newline
61 ldmfd fp, {r4-r10, fp, sp, pc}
62 .ltorg
63
64 .comm _i, 4, 4
65 .comm _j, 4, 4
66 .comm _k, 4, 4
67 @ End
68 ]]*)