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

	.include "media/testutils.inc"

	start
	pta wrong, tr0
init:
	# Put a distinctive pattern in r0.
	movi 10, r0
	shlli r0, 8, r0
	ori r0, 20, r0
	shlli r0, 8, r0
	ori r0, 30, r0
	shlli r0, 8, r0
	ori r0, 40, r0
	shlli r0, 8, r0
	ori r0, 50, r0
	shlli r0, 8, r0
	ori r0, 60, r0
	shlli r0, 8, r0
	ori r0, 70, r0
	shlli r0, 8, r0
	ori r0, 80, r0

byterev:
	byterev r0, r1

check:
	andi r1, 255, r2
	movi 10, r3
	bne r2, r3, tr0
	shlri r1, 8, r1
	andi r1, 255, r2
	movi 20, r3
	bne r2, r3, tr0
	shlri r1, 8, r1
	andi r1, 255, r2
	movi 30, r3
	bne r2, r3, tr0
	shlri r1, 8, r1
	andi r1, 255, r2
	movi 40, r3
	bne r2, r3, tr0
	shlri r1, 8, r1
	andi r1, 255, r2
	movi 50, r3
	bne r2, r3, tr0
	shlri r1, 8, r1
	andi r1, 255, r2
	movi 60, r3
	bne r2, r3, tr0
	shlri r1, 8, r1
	andi r1, 255, r2
	movi 70, r3
	bne r2, r3, tr0
	shlri r1, 8, r1
	andi r1, 255, r2
	movi 80, r3
	bne r2, r3, tr0

okay:
	pass
wrong:
	fail
