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

	.include "media/testutils.inc"

	start

	.global addl
init:
	pta wrong, tr0

addl0:
	movi 1, r63
	add.l r63, r63, r1
	bnei r1, 0, tr0

addl1:
	movi 10, r0
	movi 0, r1
	add.l r0, r1, r3
	movi 10, r4
	bne r3, r4, tr0

addl2:
	movi 0, r0
	movi 10, r1
	add.l r0, r1, r2
	movi 10, r3
	bne r2, r3, tr0

addl3:
	movi 10, r0
	add.l r63, r0, r1
	movi 10, r2
	bne r1, r2, tr0

addl4:
	movi 10, r0
	add.l r0, r63, r1
	movi 10, r2
	bne r1, r2, tr0

addl5:
	# Ensure top 32-bits are discarded when adding.
	movi 10, r0
	shlli r0, 32, r0
	addi r0, 10, r0
	movi 10, r1
	shlli r1, 32, r1
	addi r1, 10, r1
	add.l r0, r1, r2
	movi 20, r3
	bne r2, r3, tr0
	
okay:	
	pass

wrong:
	fail
