comparison lab4/test/negate.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 (* Negation of booleans and integers *)
2
3 var x, y: boolean;
4 var u, v: integer;
5
6 begin
7 x := true;
8 y := not x;
9 y := not y;
10 if x = y then
11 print_string("OK"); newline()
12 end;
13
14 u := 37;
15 v := -u;
16 v := -v;
17 if u = v then
18 print_string("OK2"); newline()
19 end
20 end.
21
22 (*<<
23 OK
24 OK2
25 >>*)
26
27 (*[[
28 @ picoPascal compiler output
29 .include "fixup.s"
30 .global pmain
31
32 .text
33 pmain:
34 mov ip, sp
35 stmfd sp!, {r4-r10, fp, ip, lr}
36 mov fp, sp
37 @ x := true;
38 mov r4, #1
39 set r0, _x
40 strb r4, [r0]
41 @ y := not x;
42 eor r5, r4, #1
43 set r6, _y
44 strb r5, [r6]
45 @ y := not y;
46 eor r5, r5, #1
47 strb r5, [r6]
48 @ if x = y then
49 cmp r4, r5
50 bne .L6
51 @ print_string("OK"); newline()
52 mov r1, #2
53 set r0, g1
54 bl print_string
55 bl newline
56 .L6:
57 @ u := 37;
58 mov r4, #37
59 set r0, _u
60 str r4, [r0]
61 @ v := -u;
62 neg r5, r4
63 set r6, _v
64 str r5, [r6]
65 @ v := -v;
66 neg r5, r5
67 str r5, [r6]
68 @ if u = v then
69 cmp r4, r5
70 bne .L3
71 @ print_string("OK2"); newline()
72 mov r1, #3
73 set r0, g2
74 bl print_string
75 bl newline
76 .L3:
77 ldmfd fp, {r4-r10, fp, sp, pc}
78 .ltorg
79
80 .comm _x, 1, 4
81 .comm _y, 1, 4
82 .comm _u, 4, 4
83 .comm _v, 4, 4
84 .data
85 g1:
86 .byte 79, 75
87 .byte 0
88 g2:
89 .byte 79, 75, 50
90 .byte 0
91 @ End
92 ]]*)