annotate lab4/test/baz.p @ 1:b5139af1a420 tip basis

Fixed permissions on compile scripts
author Mike Spivey <mike@cs.ox.ac.uk>
date Fri, 13 Oct 2017 17:27:58 +0100
parents bfdcc3820b32
children
rev   line source
mike@0 1 (* Assigning to a global variable from a procedure *)
mike@0 2
mike@0 3 var x: integer;
mike@0 4
mike@0 5 proc baz(u: integer): integer;
mike@0 6 begin
mike@0 7 x := u;
mike@0 8 return x
mike@0 9 end;
mike@0 10
mike@0 11 begin
mike@0 12 print_num(baz(37)); newline();
mike@0 13 print_num(x); newline()
mike@0 14 end.
mike@0 15
mike@0 16 (*<<
mike@0 17 37
mike@0 18 37
mike@0 19 >>*)
mike@0 20
mike@0 21 (*[[
mike@0 22 @ picoPascal compiler output
mike@0 23 .include "fixup.s"
mike@0 24 .global pmain
mike@0 25
mike@0 26 @ proc baz(u: integer): integer;
mike@0 27 .text
mike@0 28 _baz:
mike@0 29 mov ip, sp
mike@0 30 stmfd sp!, {r0-r1}
mike@0 31 stmfd sp!, {r4-r10, fp, ip, lr}
mike@0 32 mov fp, sp
mike@0 33 @ x := u;
mike@0 34 ldr r4, [fp, #40]
mike@0 35 set r0, _x
mike@0 36 str r4, [r0]
mike@0 37 @ return x
mike@0 38 mov r0, r4
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 @ print_num(baz(37)); newline();
mike@0 47 mov r0, #37
mike@0 48 bl _baz
mike@0 49 bl print_num
mike@0 50 bl newline
mike@0 51 @ print_num(x); newline()
mike@0 52 set r0, _x
mike@0 53 ldr r0, [r0]
mike@0 54 bl print_num
mike@0 55 bl newline
mike@0 56 ldmfd fp, {r4-r10, fp, sp, pc}
mike@0 57 .ltorg
mike@0 58
mike@0 59 .comm _x, 4, 4
mike@0 60 @ End
mike@0 61 ]]*)