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