annotate lab4/test/regkill.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 (* Aliasing in CSE *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
2
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
3 var x: integer;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
5 proc p();
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
6 var y, z: integer;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
7 begin
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
8 y := 1;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
9 z := y + 1;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
10 z := 3;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
11 z := y + 1;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
12 x := z
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
13 end;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
14
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
15 begin
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
16 p();
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
17 print_num(x);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
18 newline()
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
19 end.
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
20
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
21 (*<<
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
22 2
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
23 >>*)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
24
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
25 (*[[
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
26 @ picoPascal compiler output
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
27 .include "fixup.s"
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
28 .global pmain
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
29
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
30 @ proc p();
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
31 .text
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
32 _p:
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
33 mov ip, sp
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
34 stmfd sp!, {r4-r10, fp, ip, lr}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
35 mov fp, sp
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
36 @ y := 1;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
37 mov r4, #1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
38 @ z := y + 1;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
39 add r5, r4, #1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
40 @ z := 3;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
41 mov r5, #3
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
42 @ z := y + 1;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
43 add r5, r4, #1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
44 @ x := z
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
45 set r0, _x
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
46 str r5, [r0]
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
47 ldmfd fp, {r4-r10, fp, sp, pc}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
48 .ltorg
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
49
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
50 pmain:
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
51 mov ip, sp
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
52 stmfd sp!, {r4-r10, fp, ip, lr}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
53 mov fp, sp
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
54 @ p();
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
55 bl _p
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
56 @ print_num(x);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
57 set r0, _x
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
58 ldr r0, [r0]
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 @ newline()
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
61 bl newline
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
62 ldmfd fp, {r4-r10, fp, sp, pc}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
63 .ltorg
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
64
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
65 .comm _x, 4, 4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
66 @ End
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
67 ]]*)