# sh testcase for fmul -*- Asm -*-
# mach: all
# as: -isa=shcompact
# ld: -m shelf32

	.include "compact/testutils.inc"

	start
	# 0.0 - 0.0 = 0.0.
	fldi0 fr0
	fldi0 fr1
	fsub fr0, fr1
	fldi0 fr2
	fcmp/eq fr1, fr2
	bf wrong

	# 1.0 - 0.0 = 1.0.
	fldi0 fr0
	fldi1 fr1
	fsub fr0, fr1
	fldi1 fr2
	fcmp/eq fr1, fr2
	bf wrong

	# 1.0 - 1.0 = 0.0.
	fldi1 fr0
	fldi1 fr1
	fsub fr0, fr1
	fldi0 fr2
	fcmp/eq fr1, fr2
	bf wrong

	# 0.0 - 1.0 = -1.0.
	fldi1 fr0
	fldi0 fr1
	fsub fr0, fr1
	fldi1 fr2
	fneg fr2
	fcmp/eq fr1, fr2
	bf wrong

	bra double	
	nop

wrong:
	fail

double:
	# 0.0 - 0.0 = 0.0.
	fldi0 fr0
	fldi0 fr2
	_s2d fr0, dr0
	_s2d fr2, dr2
	_setpr
	fsub dr0, dr2
	_clrpr
	fldi0 fr4
	_s2d fr4, dr4
	_setpr
	fcmp/eq dr2, dr4
	bf wrong
	_clrpr

onezero:	
	# 1.0 - 0.0 = 1.0.
	fldi0 fr0
	fldi1 fr2
	_s2d fr0, dr0
	_s2d fr2, dr2
	_setpr
	fsub dr0, dr2
	_clrpr
	fldi1 fr4
	_s2d fr4, dr4
	_setpr
	fcmp/eq dr2, dr4
	bf wrong2
	_clrpr

oneone:	
	# 1.0 - 1.0 = 0.0.
	fldi1 fr0
	fldi1 fr2
	_s2d fr0, dr0
	_s2d fr2, dr2
	_setpr
	fsub dr0, dr2
	_clrpr
	fldi0 fr4
	_s2d fr4, dr4
	_setpr
	fcmp/eq dr2, dr4
	bf wrong2
	_clrpr

	bra zeroone
	nop

wrong2:
	fail

zeroone:	
	# 0.0 - 1.0 = -1.0.
	fldi1 fr0
	fldi0 fr2
	_s2d fr0, dr0
	_s2d fr2, dr2
	_setpr
	fsub dr0, dr2
	_clrpr
	fldi1 fr4
	fneg fr4
	_s2d fr4, dr4
	_setpr
	fcmp/eq dr2, dr4
	bf wrong2
	_clrpr
		
okay:
	pass
