         Edinburgh IMP77 Compiler - Version 8.4
    1 %begin
				.section	".text"
		.Ltext0:
				.align 4
				.proc	04
		ONE.6076:
		.LFB187:
				.register	%g7, #ignore
		.LVL9:
				save	%sp, -1472, %sp
		.LVL10:
				ldx	[%g7+40], %g1
				stx	%g1, [%fp+2039]
				mov	0, %g1
    2
				mov	%i1, %o1
				call	_imp_initialise, 0
				 mov	%i0, %o0
		.LVL11:
		.LBB44:
		.LBB45:
				sethi	%hi(_imp_OutStream), %g1
				st	%g0, [%g1+%lo(_imp_OutStream)]
				sethi	%hi(_imp_outfile), %g1
				ldx	[%g1+%lo(_imp_outfile)+8], %g2
				sethi	%hi(_imp_OutFile), %g1
				stx	%g2, [%g1+%lo(_imp_OutFile)]
				sethi	%hi(__PRETTY_FUNCTION__.5660), %o0
				call	check_outstream, 0
				 or	%o0, %lo(__PRETTY_FUNCTION__.5660), %o0
		.LVL12:
		.LBE45:
		.LBE44:
		.LBB46:
    3     ! An example program which uses a %routinespec and a call
    4     ! to the routine BEFORE actually the routine implementation
    5
    6     %routinespec css
    7
    8     selectoutput(0)
    9     printstring("start %SPEC test"); newline
				mov	256, %o2
				sethi	%hi(.LC0), %o1
				or	%o1, %lo(.LC0), %o1
				call	memcpy, 0
				 add	%fp, 1783, %o0
		.LVL13:
				mov	256, %o2
				add	%fp, 1783, %o1
				call	memcpy, 0
				 add	%fp, 1015, %o0
		.LVL14:
				mov	256, %o2
				add	%fp, 1015, %o1
				call	memcpy, 0
				 add	%fp, 1783, %o0
		.LVL15:
		.LBE46:
		.LBB47:
		.LBB48:
				mov	256, %o2
				add	%fp, 1783, %o1
				call	memcpy, 0
				 add	%fp, 751, %o0
		.LVL16:
				call	_imp_printstring, 0
				 add	%fp, 751, %o0
		.LVL17:
		.LBE48:
		.LBE47:
		.LBB49:
		.LBB50:
				call	_imp_newline, 0
				 nop
		.LVL18:
		.LBE50:
		.LBE49:
		.LBB51:
		.LBB52:
		.LBB53:
		.LBB54:
   10     css
   11     printstring("end %SPEC test"); newline
				mov	256, %o2
				sethi	%hi(.LC1), %o1
				or	%o1, %lo(.LC1), %o1
				call	memcpy, 0
				 add	%fp, 1527, %o0
		.LVL21:
				mov	256, %o2
				add	%fp, 1527, %o1
				call	memcpy, 0
				 add	%fp, 1271, %o0
		.LVL22:
				mov	256, %o2
				add	%fp, 1271, %o1
				call	memcpy, 0
				 add	%fp, 1527, %o0
		.LVL23:
		.LBE57:
		.LBB58:
		.LBB59:
				mov	256, %o2
				add	%fp, 1527, %o1
				call	memcpy, 0
				 add	%fp, 751, %o0
		.LVL24:
				call	_imp_printstring, 0
				 add	%fp, 751, %o0
		.LVL25:
		.LBE59:
		.LBE58:
		.LBB60:
		.LBB61:
				call	_imp_newline, 0
				 nop
		.LVL26:
		.LBE61:
		.LBE60:
		.LBB62:
		.LBB63:
				call	exit, 0
				 mov	0, %o0
		.LVL27:
		.LBE63:
		.LBE62:
				nop
		.LFE185:
				.common	CALLCOUNT.6082,4,4
				.section	".rodata"
				.align 8
		__PRETTY_FUNCTION__.5660:
				.asciz	"_imp_SELECTOUTPUT"
				.section	".text"
		.Letext0:
   12
   13     %routine css
   14         %integer a,b,c
   15
   16         %integerfnspec three(%integer p1,p2,p3)
   17         %integerfnspec two(%integer p1,p2)
   18
   19         c = 5
   20
   21         %integerfn one(%integer p1)
				.register	%g2, #scratch
		.LVL0:
				save	%sp, -176, %sp
		.LVL1:
   22             %integer a1,b1,c1,d1
   23             %owninteger callcount
   24
   25             %begin
   26                 a1 = p1
   27                 b1 = 2*p1
				add	%i0, %i0, %i5
		.LVL2:
   28                 c1 = 3*p1
				add	%i5, %i0, %i4
		.LVL3:
   29                 callcount = callcount + 1
				sethi	%hi(CALLCOUNT.6082), %g2
				lduw	[%g2+%lo(CALLCOUNT.6082)], %g1
				add	%g1, 1, %g1
				st	%g1, [%g2+%lo(CALLCOUNT.6082)]
		.LDL1:
   30             %end
   31
   32             ! Use callcount as a defence against repeated calls to routine 'three'
   33             ! which would cause a stack overflow.
   34             %if (callcount < 10) %then d1 = three(a1,b1,c1) %else d1 = -1
				cmp	%g1, 9
				bg,pn	%icc, .L3
				 mov	-1, %o0
		.LVL4:
		.LBB20:
		.LBB21:
   35             %result = d1
   36         %end
				sra	%o0, 0, %i0
				return	%i7+8
				 nop
		.LFE187:
				.section	".rodata"
		.LC0:
				.byte	16
				.asciz	"start %SPEC test"
				.skip	238
		.LC1:
				.byte	14
				.asciz	"end %SPEC test"
				.skip	240
				.section	".text"
				.align 4
				.global main
				.proc	04
		main:
		.LFB185:
   37
   38         b = 3
   39
   40         %integerfn three(%integer p1,p2,p3)
   41             %integer a3,b3
   42             a3 = one(p1)
				call	ONE.6076, 0
				 mov	%i0, %o0
		.LVL5:
				mov	%o0, %i0
		.LVL6:
		.LBB22:
		.LBB23:
				call	ONE.6076, 0
				 mov	3, %o0
		.LVL19:
		.LBB55:
		.LBB56:
				call	ONE.6076, 0
				 mov	13, %o0
		.LVL20:
		.LBE56:
		.LBE55:
		.LBE54:
		.LBE53:
		.LBE52:
		.LBE51:
		.LBB57:
   43             b3 = two(p2,p3)
   44             %result = a3 + b3
				add	%o0, %i0, %o0
		.LVL8:
		.L2:
		.L3:
		.LBE21:
		.LBE20:
   45         %end
   46
   47         a = three(b,c,b+c)
   48
   49         %integerfn two(%integer p1,p2)
   50             %integer a2,b2
   51
   52             %result = one(p1+p2)
				add	%i5, %i4, %o0
				call	ONE.6076, 0
				 sra	%o0, 0, %o0
		.LVL7:
		.LBE23:
		.LBE22:
   53         %end
?B2 unused
?A2 unused
   54
   55     %end
   56
   57 %endofprogram
   39 Statements compiled
