# sh testcase for ftrv xmtrx, $fvn -*- Asm -*-
# mach: all
# as: -isa=shcompact
# ld: -m shelf32

	.include "compact/testutils.inc"

	# set the fr bit in the fpscr
	.macro _setfr
	sts fpscr, r7
	mov #32, r8
	shll16 r8
	or r8, r7
	lds r7, fpscr
	.endm

	# clear the fr bit
	.macro _clrfr
	sts fpscr, r7
	mov #32, r8
	shll16 r8
	not r8, r8
	and r8, r7
	lds r7, fpscr
	.endm

	.macro incr old new
	fldi1 \new
	fadd \old, \new
	.endm

	start
	_setfr
popmtrx:
	# 1.0.
	fldi1 fr0
	# 2.0.
	fldi1 fr1
	fadd fr1, fr1

	incr fr1, fr2
	incr fr2, fr3
	incr fr3, fr4
	incr fr4, fr5
	incr fr5, fr6
	incr fr6, fr7
	incr fr7, fr8
	incr fr8, fr9
	incr fr9, fr10
	incr fr10, fr11
	incr fr11, fr12
	incr fr12, fr13
	incr fr13, fr14
	incr fr14, fr15

popvect:
	# Swtich fp banks.
	_clrfr
	fldi1 fr4
	fldi1 fr5
	fadd fr5, fr5
	fldi1 fr6
	fadd fr5, fr6
	fldi1 fr7
	fadd fr6, fr7

ftrv:
	# fr[4,7] should contain the results:
	# { 30, 70, 110, 150 }.
	ftrv xmtrx, fv4

okay:
	pass

