# sh testcase for nsb $rm, $rd -*- Asm -*-
# mach: all
# as: -isa=shmedia
# ld: -m shelf64

	.include "media/testutils.inc"

	start
init:
	pta wrong, tr0

nsb0:
	movi 0, r0
	nsb r0, r1
check0:
	movi 63, r4
	bne r1, r4, tr0

nsb1:
	# set up a loop target reg.
	pta again1, tr1
	# r4 holds the loop count.
	movi 62, r4
	movi 1, r0
again1:
	nsb r0, r1
	bne r1, r4, tr0
	# okay? go around again.
	shlli r0, 1, r0
	addi r4, -1, r4
	bnei r4, 0, tr1

nsb2:
	# set up a loop target reg.
	pta again2, tr1
	# r4 holds the loop count.
	movi 63, r4
	movi -1, r0
again2:
	nsb r0, r1
	bne r1, r4, tr0
	# okay? go around again.
	shlli r0, 1, r0
	addi r4, -1, r4
	bnei r4, 0, tr1

nsb3:
	movi 1, r0
	shlli r0, 63, r0
	nsb r0, r1
check3:
	movi 0, r4
	bne r1, r4, tr0

nsb4:
	movi 7, r0
	shlli r0, 61, r0
	nsb r0, r1
check4:
	movi 2, r4
	bne r1, r4, tr0

okay:
	pass
wrong:
	fail
