# fr30 testcase for
# mach(): fr30
#  sth $Ri,@$Rj

	.include "testutils.inc"

	START

	.text
	.global sth
sth:
	mvr_h_gr	sp,r9		; Save stack pointer
	; Test sth $Ri,@Rj
	mvi_h_mem	0xdeadbeef,sp
	mvi_h_gr	0xaaaabeef,r8
	set_cc          0x0f		; Condition codes should not change
	sth      	r8,@sp
	test_cc		1 1 1 1
	test_h_mem	0xbeefbeef,sp
	test_h_gr	0xaaaabeef,r8

	; Test sth $Ri,@(R13,Rj)
	mvi_h_mem	0xbeefdead,sp
	mvi_h_gr	0xaaaadead,r8
	mvr_h_gr	sp,r1
	inci_h_gr	-8,sp
	mvr_h_gr	sp,r2
	mvi_h_mem	0xbeefdead,sp
	inci_h_gr	4,sp
	mvi_h_mem	0xbeefdead,sp

	mvi_h_gr	4,r13
	set_cc          0x0e		; Condition codes should not change
	sth      	r8,@(r13,sp)
	test_cc		1 1 1 0
	test_h_mem	0xdeaddead,r1
	test_h_gr	0xaaaadead,r8

	mvi_h_gr	0,r13
	set_cc          0x0d		; Condition codes should not change
	sth      	r8,@(r13,sp)
	test_cc		1 1 0 1
	test_h_mem	0xdeaddead,sp
	test_h_gr	0xaaaadead,r8

	mvi_h_gr	-4,r13
	set_cc          0x0c		; Condition codes should not change
	sth      	r8,@(r13,sp)
	test_cc		1 1 0 0
	test_h_mem	0xdeaddead,r2
	test_h_gr	0xaaaadead,r8

	; Test sth $Ri,@(R14,$disp9)
	mvr_h_gr	r9,sp		; Restore stack pointer
	mvi_h_gr	0xaaaaabcd,r8
	mvi_h_mem	0xdeadbeef,sp
	mvr_h_gr	sp,r14
	inci_h_gr	-256,r14	; must be aligned
	mvr_h_gr	r14,r2
	mvi_h_mem	0xdeadbeef,r14
	inci_h_gr	-256,r14
	mvr_h_gr	r14,r3
	mvi_h_mem	0xdeadbeef,r14
	inci_h_gr	258,r14

	set_cc          0x0b		; Condition codes should not change
	sth      	r8,@(r14,254)
	test_cc		1 0 1 1
	test_h_mem	0xabcdbeef,r1
	test_h_gr	0xaaaaabcd,r8

	set_cc          0x0a		; Condition codes should not change
	sth      	r8,@(r14,0)
	test_cc		1 0 1 0
	test_h_mem	0xdeadabcd,r2
	test_h_gr	0xaaaaabcd,r8

	set_cc          0x09		; Condition codes should not change
	sth      	r8,@(r14,-256)
	test_cc		1 0 0 1
	test_h_mem	0xdeadabcd,r3
	test_h_gr	0xaaaaabcd,r8

	pass
