#
# 68k_test_8
#
# eighth test file for the 68k core testing program
#
# tests misc instructions in the 0x4xxx range
#

# $Id$

#
# NOTE: Someone plays fast and loose with flags...
#

# test NOP instruction
start nop, take 1
set mem 0x002000 = 0x4e71
set pc 0x002000
set cycles 4
run
check pc 0x002002
check cycles 0
done

# test LEA instruction
start lea (a1), a0, take 1
set mem 0x002000 = 0x41d1
set reg a0 = 0x00004000
set reg a1 = 0x87654321
set pc 0x002000
set cycles 4
run
check pc 0x002002
check cycles 0
check reg a0 = 0x87654321
done

# FIXME: test MOVE USP behavior in user mode

# test MOVE to USP instruction
start move a0, usp, take 1
set mem 0x002000 = 0x4e60
set reg a0 = 0x87654321
set other_sp 0x12345678
set flags 0x2000
set pc 0x002000
set cycles 4
run
check pc 0x002002
check cycles 0
check other_sp 0x87654321
done

# test MOVE to CCR instruction
start move d0, ccr, take 1
set mem 0x002000 = 0x44c0
set reg d0 = 0x0000557f
set flags 0x2005
set pc 0x002000
set cycles 12
run
check flags 0x201f
check pc 0x002002
check cycles 0
done

# test MOVE to CCR instruction
start move d0, ccr, take 2
set mem 0x002000 = 0x44c0
set reg d0 = 0x0000556a
set flags 0x2005
set pc 0x002000
set cycles 12
run
check flags 0x200a
check pc 0x002002
check cycles 0
done

# FIXME: test MOVE SR behavior in user mode

# test MOVE to SR instruction
start move d0, sr, take 1
set mem 0x002000 = 0x46c0
set reg d0 = 0x0000201f
set reg a7 = 0x00600000
set other_sp 0x00500000
set flags 0x2000
set pc 0x002000
set cycles 12
run
check flags 0x201f
check reg a7 = 0x00600000
check other_sp 0x00500000
check pc 0x002002
check cycles 0
done

# test MOVE to SR instruction
start move d0, sr, take 2
set mem 0x002000 = 0x46c0
set reg d0 = 0x0000001f
set reg a7 = 0x00600000
set other_sp 0x00500000
set flags 0x2000
set pc 0x002000
set cycles 12
run
check flags 0x001f
check reg a7 = 0x00500000
check other_sp 0x00600000
check pc 0x002002
check cycles 0
done

# test MOVE from SR instruction
start move sr, d0, take 1
set mem 0x002000 = 0x40c0
set reg d0 = 0x55aa55aa
set flags 0x2015
set pc 0x002000
set cycles 6
run
check flags 0x2015
check reg d0 = 0x55aa2015
check pc 0x002002
check cycles 0
done

# test LINK instruction
start link a0, take 1
set mem 0x002000 = 0x4e50
set mem 0x002002 = 0x0000
set reg a0 = 0x87654321
set reg a7 = 0x00200000
set mem 0x1ffffe = 0x0000
set mem 0x1ffffc = 0x0000
set pc 0x002000
set cycles 16
run
check pc 0x002004
check reg a0 = 0x001ffffc
check reg a7 = 0x001ffffc
check mem 0x1ffffe = 0x4321
check mem 0x1ffffc = 0x8765
check cycles 0
done

# test LINK instruction
start link a0, take 2
set mem 0x002000 = 0x4e50
set mem 0x002002 = 0x7ffe
set reg a0 = 0x87654321
set reg a7 = 0x00200000
set mem 0x1ffffe = 0x0000
set mem 0x1ffffc = 0x0000
set pc 0x002000
set cycles 16
run
check pc 0x002004
check reg a0 = 0x001ffffc
check reg a7 = 0x00207ffa
check mem 0x1ffffe = 0x4321
check mem 0x1ffffc = 0x8765
check cycles 0
done

# test LINK instruction
start link a0, take 3
set mem 0x002000 = 0x4e50
set mem 0x002002 = 0xfffe
set reg a0 = 0x87654321
set reg a7 = 0x00200000
set mem 0x1ffffe = 0x0000
set mem 0x1ffffc = 0x0000
set pc 0x002000
set cycles 16
run
check pc 0x002004
check reg a0 = 0x001ffffc
check reg a7 = 0x001ffffa
check mem 0x1ffffe = 0x4321
check mem 0x1ffffc = 0x8765
check cycles 0
done

# test LINK instruction
start link a0, take 4
set mem 0x002000 = 0x4e50
set mem 0x002002 = 0x0002
set reg a0 = 0x87654321
set reg a7 = 0x00200000
set mem 0x1ffffe = 0x0000
set mem 0x1ffffc = 0x0000
set pc 0x002000
set cycles 16
run
check pc 0x002004
check reg a0 = 0x001ffffc
check reg a7 = 0x001ffffe
check mem 0x1ffffe = 0x4321
check mem 0x1ffffc = 0x8765
check cycles 0
done

# test UNLK instruction
start unlk a0, take 1
set mem 0x002000 = 0x4e58
set reg a0 = 0x001ffffc
set reg a7 = 0x87654321
set mem 0x1ffffc = 0x1234
set mem 0x1ffffe = 0x5678
set pc 0x002000
set cycles 12
run
check cycles 0
check pc 0x002002
check reg a0 = 0x12345678
check reg a7 = 0x00200000
done

#
# $Log$
#
