annotate lab4/test/forloop.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: integer;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
2
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
3 begin
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
4 for i := 1 to 5 do
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
5 print_num(i);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
6 newline()
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 (*<<
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
11 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
12 2
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
13 3
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
14 4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
15 5
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 @ for i := 1 to 5 do
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
29 mov r0, #1
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 mov r4, #5
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
33 .L2:
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
34 set r0, _i
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
35 ldr r5, [r0]
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
36 cmp r5, r4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
37 bgt .L1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
38 @ print_num(i);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
39 mov r0, r5
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
40 bl print_num
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
41 @ newline()
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
42 bl newline
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
43 set r5, _i
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
44 ldr r0, [r5]
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
45 add r0, r0, #1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
46 str r0, [r5]
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
47 b .L2
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
48 .L1:
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
49 ldmfd fp, {r4-r10, fp, sp, pc}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
50 .ltorg
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
51
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
52 .comm _i, 4, 4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
53 @ End
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
54 ]]*)