# sh testcase for mac.w @${rm}+, @${rn}+
# mach: all
# as: -isa=shcompact
# ld: -m shelf32

	.include "compact/testutils.inc"

	start

	# Store some magic numbers in memory.
	mov #40, r1
	shll8 r1
	mov #85, r0
	mov.l r0, @r1
	# Keep for later.
	mov r1, r10
store2:
	mov #40, r1
	shll8 r1
	add #12, r1
	mov #17, r0
	mov.l r0, @r1
	# Keep for later.
	mov r1, r11

init:
	# Set up addresses.
	mov #40, r1
	shll8 r1
	mov #40, r2
	shll8 r2
	add #12, r2

	# Prime {MACL, MACH} to #1.
	mov #1, r3
	dmulu.l r3, r3

test:
	mac.w @r1+, @r2+

check:
	# Check result.
	sts mach, r5
	assert r5, #0

	sts macl, r6
	assert r6, #1

	# Ensure post-increment occurred.
	add #2, r10
	cmp/eq r10, r1
	bf wrong

	add #2, r11
	cmp/eq r11, r2
	bf wrong

doubleinc:
	mov #40, r0
	shll8 r0
	mov r0, r1
	mac.w @r0+, @r0+
	add #8, r1
	cmp/eq r0, r1
	bf wrong
	
okay:
	pass
wrong:
	fail
