annotate lab4/test/bitnot.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 (* Bitwise NOT function *)
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 begin
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
5 x := 314159265;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
6 x := bitnot(x);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
7 print_num(x); newline()
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 -314159266
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
12 >>*)
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 @ picoPascal compiler output
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
16 .include "fixup.s"
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
17 .global pmain
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
18
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
19 .text
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
20 pmain:
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
21 mov ip, sp
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
22 stmfd sp!, {r4-r10, fp, ip, lr}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
23 mov fp, sp
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
24 @ x := 314159265;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
25 set r4, #314159265
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
26 set r5, _x
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
27 str r4, [r5]
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
28 @ x := bitnot(x);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
29 mvn r4, r4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
30 str r4, [r5]
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
31 @ print_num(x); newline()
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
32 mov r0, r4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
33 bl print_num
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
34 bl newline
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
35 ldmfd fp, {r4-r10, fp, sp, pc}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
36 .ltorg
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
37
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
38 .comm _x, 4, 4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
39 @ End
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
40 ]]*)