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