# fr30 testcase for reti
# mach(): fr30

	.include "testutils.inc"

	START

	.text
	.global reti
reti:
	; Test reti with low reset of ilm allowed
	mvr_h_gr	sp,r8		; Save stack pointer
	set_s_system
	set_i		1
	set_ilm		15		; attempt reset of low range	 
	set_cc          0x0f		; Condition codes should not change
	save_ps
	inci_h_gr	-4,sp
	mvi_h_mem	ret1,sp
	set_i		0		; Set opposite of expected
	set_ilm		0 		; attempt reset of low range	 
	set_cc          0x00		; Set opposite of expected

	reti
	fail

ret1:
	test_cc		1 1 1 1
	test_s_system
	test_i		1
	test_ilm	15
	testr_h_gr	r8,sp

	; Test reti with low reset of ilm not allowed
	mvr_h_gr	sp,r8		; Save stack pointer
	set_s_system
	set_i		0
	set_ilm		15		; attempt reset of low range	 
	set_cc          0x0f		; Condition codes should not change
	save_ps
	inci_h_gr	-4,sp
	mvi_h_mem	ret2,sp
	set_i		0		; Set opposite of expected
	set_ilm		16 		; disallow reset of low range
	set_cc          0x00		; Set opposite of expected

	reti
	fail

ret2:
	test_cc		1 1 1 1
	test_s_system
	test_i		0
	test_ilm	31
	testr_h_gr	r8,sp

	pass
