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