annotate lab4/test/rep2.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 var i: integer;
mike@0 2
mike@0 3 proc inc(var x: integer): integer;
mike@0 4 begin
mike@0 5 x := x+1;
mike@0 6 return x
mike@0 7 end;
mike@0 8
mike@0 9 begin
mike@0 10 i := 0;
mike@0 11 repeat until inc(i) > 10;
mike@0 12 print_num(i); newline()
mike@0 13 end.
mike@0 14
mike@0 15 (*<<
mike@0 16 11
mike@0 17 >>*)
mike@0 18
mike@0 19 (*[[
mike@0 20 @ picoPascal compiler output
mike@0 21 .include "fixup.s"
mike@0 22 .global pmain
mike@0 23
mike@0 24 @ proc inc(var x: integer): integer;
mike@0 25 .text
mike@0 26 _inc:
mike@0 27 mov ip, sp
mike@0 28 stmfd sp!, {r0-r1}
mike@0 29 stmfd sp!, {r4-r10, fp, ip, lr}
mike@0 30 mov fp, sp
mike@0 31 @ x := x+1;
mike@0 32 ldr r4, [fp, #40]
mike@0 33 ldr r0, [r4]
mike@0 34 add r0, r0, #1
mike@0 35 str r0, [r4]
mike@0 36 @ return x
mike@0 37 ldr r0, [fp, #40]
mike@0 38 ldr r0, [r0]
mike@0 39 ldmfd fp, {r4-r10, fp, sp, pc}
mike@0 40 .ltorg
mike@0 41
mike@0 42 pmain:
mike@0 43 mov ip, sp
mike@0 44 stmfd sp!, {r4-r10, fp, ip, lr}
mike@0 45 mov fp, sp
mike@0 46 @ i := 0;
mike@0 47 mov r0, #0
mike@0 48 set r1, _i
mike@0 49 str r0, [r1]
mike@0 50 .L3:
mike@0 51 @ repeat until inc(i) > 10;
mike@0 52 set r0, _i
mike@0 53 bl _inc
mike@0 54 cmp r0, #10
mike@0 55 ble .L3
mike@0 56 @ print_num(i); newline()
mike@0 57 set r0, _i
mike@0 58 ldr r0, [r0]
mike@0 59 bl print_num
mike@0 60 bl newline
mike@0 61 ldmfd fp, {r4-r10, fp, sp, pc}
mike@0 62 .ltorg
mike@0 63
mike@0 64 .comm _i, 4, 4
mike@0 65 @ End
mike@0 66 ]]*)