         Edinburgh IMP77 Compiler - Version 8.4
    1 %begin
				.option nopic
		.Ltext0:
				.align	1
		ONE.6021:
		.LFB187:
		.LVL13:
				add	sp,sp,-1312
				sd	ra,1304(sp)
				sd	s0,1296(sp)
				lui	a5,%hi(__stack_chk_guard)
				ld	a5,%lo(__stack_chk_guard)(a5)
				sd	a5,1288(sp)
    2
				call	_imp_initialise
		.LVL14:
		.LBB44:
		.LBB45:
				lui	a5,%hi(_imp_OutStream)
				sw	zero,%lo(_imp_OutStream)(a5)
				lui	a5,%hi(_imp_outfile+8)
				ld	a4,%lo(_imp_outfile+8)(a5)
				lui	a5,%hi(_imp_OutFile)
				sd	a4,%lo(_imp_OutFile)(a5)
				lui	a0,%hi(.LANCHOR0)
				addi	s0,a0,%lo(.LANCHOR0)
				addi	a0,a0,%lo(.LANCHOR0)
				call	check_outstream
		.LVL15:
		.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
				li	a2,256
				add	a1,s0,24
				add	a0,sp,1032
				call	memcpy
		.LVL16:
				li	a2,256
				add	a1,sp,1032
				add	a0,sp,264
				call	memcpy
		.LVL17:
				li	a2,256
				add	a1,sp,264
				add	a0,sp,1032
				call	memcpy
		.LVL18:
		.LBE46:
		.LBB47:
		.LBB48:
				li	a2,256
				add	a1,sp,1032
				mv	a0,sp
				call	memcpy
		.LVL19:
				mv	a0,sp
				call	_imp_printstring
		.LVL20:
		.LBE48:
		.LBE47:
		.LBB49:
		.LBB50:
				call	_imp_newline
		.LVL21:
		.LBE50:
		.LBE49:
		.LBB51:
		.LBB52:
		.LBB53:
		.LBB54:
   10     css
   11     printstring("end %SPEC test"); newline
				li	a2,256
				add	a1,s0,280
				add	a0,sp,776
				call	memcpy
		.LVL24:
				li	a2,256
				add	a1,sp,776
				add	a0,sp,520
				call	memcpy
		.LVL25:
				li	a2,256
				add	a1,sp,520
				add	a0,sp,776
				call	memcpy
		.LVL26:
		.LBE57:
		.LBB58:
		.LBB59:
				li	a2,256
				add	a1,sp,776
				mv	a0,sp
				call	memcpy
		.LVL27:
				mv	a0,sp
				call	_imp_printstring
		.LVL28:
		.LBE59:
		.LBE58:
		.LBB60:
		.LBB61:
				call	_imp_newline
		.LVL29:
		.LBE61:
		.LBE60:
		.LBB62:
		.LBB63:
				li	a0,0
				call	exit
		.LVL30:
		.LBE63:
		.LBE62:
		.LFE185:
				.section	.rodata
				.align	3
				.set	.LANCHOR0,. + 0
		__PRETTY_FUNCTION__.5605:
				.string	"_imp_SELECTOUTPUT"
				.zero	6
		.LC0:
				.byte	16
				.string	"start %SPEC test"
				.zero	238
		.LC1:
				.byte	14
				.string	"end %SPEC test"
				.zero	240
				.section	.sbss,"aw",@nobits
				.align	2
		CALLCOUNT.6027:
				.zero	4
		.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)
		.LVL0:
				add	sp,sp,-32
				sd	ra,24(sp)
				sd	s0,16(sp)
				sd	s1,8(sp)
				sd	s2,0(sp)
		.LVL1:
   22             %integer a1,b1,c1,d1
   23             %owninteger callcount
   24
   25             %begin
   26                 a1 = p1
   27                 b1 = 2*p1
				sllw	s2,a0,1
		.LVL2:
   28                 c1 = 3*p1
				addw	s0,s2,a0
		.LVL3:
   29                 callcount = callcount + 1
				lui	a4,%hi(CALLCOUNT.6027)
				lw	a5,%lo(CALLCOUNT.6027)(a4)
				addw	a5,a5,1
				sext.w	a3,a5
				sw	a5,%lo(CALLCOUNT.6027)(a4)
		.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
				li	a5,9
				bgt	a3,a5,.L4
		.LVL4:
		.LBB20:
		.LBB21:
   35             %result = d1
   36         %end
				ld	ra,24(sp)
				ld	s0,16(sp)
		.LVL9:
				ld	s1,8(sp)
				ld	s2,0(sp)
		.LVL10:
				add	sp,sp,32
				jr	ra
		.LVL11:
		.L4:
   37
   38         b = 3
				li	a0,-1
		.LVL12:
				j	.L3
		.LFE187:
				.align	1
				.globl	main
		main:
		.LFB185:
   39
   40         %integerfn three(%integer p1,p2,p3)
   41             %integer a3,b3
   42             a3 = one(p1)
				call	ONE.6021
		.LVL5:
				mv	s1,a0
		.LVL6:
		.LBB22:
		.LBB23:
				li	a0,3
				call	ONE.6021
		.LVL22:
		.LBB55:
		.LBB56:
				li	a0,13
				call	ONE.6021
		.LVL23:
		.LBE56:
		.LBE55:
		.LBE54:
		.LBE53:
		.LBE52:
		.LBE51:
		.LBB57:
   43             b3 = two(p2,p3)
   44             %result = a3 + b3
				addw	a0,a0,s1
		.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)
				addw	a0,s2,s0
				call	ONE.6021
		.LVL7:
		.LBE23:
		.LBE22:
   53         %end
?B2 unused
?A2 unused
   54
   55     %end
   56
   57 %endofprogram
   39 Statements compiled
