annotate lab4/test/nest.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 (* Nested calls *)
mike@0 2
mike@0 3 proc f(x: integer): integer; begin return 2*x end;
mike@0 4 begin print_num(f(f(3))); newline() end.
mike@0 5
mike@0 6 (*<<
mike@0 7 12
mike@0 8 >>*)
mike@0 9
mike@0 10 (*[[
mike@0 11 @ picoPascal compiler output
mike@0 12 .include "fixup.s"
mike@0 13 .global pmain
mike@0 14
mike@0 15 @ proc f(x: integer): integer; begin return 2*x end;
mike@0 16 .text
mike@0 17 _f:
mike@0 18 mov ip, sp
mike@0 19 stmfd sp!, {r0-r1}
mike@0 20 stmfd sp!, {r4-r10, fp, ip, lr}
mike@0 21 mov fp, sp
mike@0 22 @ proc f(x: integer): integer; begin return 2*x end;
mike@0 23 ldr r0, [fp, #40]
mike@0 24 lsl r0, r0, #1
mike@0 25 ldmfd fp, {r4-r10, fp, sp, pc}
mike@0 26 .ltorg
mike@0 27
mike@0 28 pmain:
mike@0 29 mov ip, sp
mike@0 30 stmfd sp!, {r4-r10, fp, ip, lr}
mike@0 31 mov fp, sp
mike@0 32 @ begin print_num(f(f(3))); newline() end.
mike@0 33 mov r0, #3
mike@0 34 bl _f
mike@0 35 bl _f
mike@0 36 bl print_num
mike@0 37 bl newline
mike@0 38 ldmfd fp, {r4-r10, fp, sp, pc}
mike@0 39 .ltorg
mike@0 40
mike@0 41 @ End
mike@0 42 ]]*)