#
# 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

# test LEA instruction
start lea (xxx).W, a0, take 1
set mem 0x002000 = 0x41f8
set reg a0 = 0x00004000
set mem 0x002002 = 0xc321
set pc 0x002000
set cycles 8
run
check pc 0x002004
check cycles 0
check reg a0 = 0xffffc321
done

# test PEA instruction
start pea (a1), a0, take 1
set mem 0x002000 = 0x4851
set reg a0 = 0x00004000
set reg a1 = 0x87654321
set reg a7 = 0x00008000
set mem 0x007ffe = 0x0000
set mem 0x007ffc = 0x0000
set pc 0x002000
set cycles 12
run
check pc 0x002002
check cycles 0
check reg a0 = 0x00004000
check mem 0x007ffc = 0x8765
check mem 0x007ffe = 0x4321
check reg a7 = 0x00007ffc
done

# test PEA instruction
start pea (xxx).W, a0, take 1
set mem 0x002000 = 0x4878
set reg a0 = 0x00004000
set mem 0x002002 = 0xc321
set reg a7 = 0x00008000
set mem 0x007ffe = 0x0000
set mem 0x007ffc = 0x0000
set pc 0x002000
set cycles 16
run
check pc 0x002004
check cycles 0
check reg a0 = 0x00004000
check mem 0x007ffc = 0xffff
check mem 0x007ffe = 0xc321
check reg a7 = 0x00007ffc
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

# test SWAP instruction
start swap d0, take 1
set mem 0x002000 = 0x4840
set reg d0 = 0x12345678
set pc 0x002000
set cycles 4
set flags 0x001f
run
check cycles 0
check pc 0x002002
check reg d0 = 0x56781234
check flags 0x0010
done

# test SWAP instruction
start swap d7, take 1
set mem 0x002000 = 0x4847
set reg d7 = 0x43218765
set pc 0x002000
set cycles 4
set flags 0x001f
run
check cycles 0
check pc 0x002002
check reg d7 = 0x87654321
check flags 0x0018
done

# test NEG instruction
start neg.b d0, take 1
set mem 0x002000 = 0x4400
set reg d0 = 0x87654320
set flags 0x001f
set pc 0x002000
set cycles 4
run
check cycles 0
check pc 0x002002
check reg d0 = 0x876543e0
check flags 0x0019
done

# test NEG instruction
start neg.b d0, take 2
set mem 0x002000 = 0x4400
set reg d0 = 0x876543ff
set flags 0x0000
set pc 0x002000
set cycles 4
run
check cycles 0
check pc 0x002002
check reg d0 = 0x87654301
check flags 0x0011
done

# test NEG instruction
start neg.b d0, take 3
set mem 0x002000 = 0x4400
set reg d0 = 0x87654300
set flags 0x001f
set pc 0x002000
set cycles 4
run
check cycles 0
check pc 0x002002
check reg d0 = 0x87654300
check flags 0x0004
done

# test NEG instruction
start neg.w d0, take 1
set mem 0x002000 = 0x4440
set reg d0 = 0x87652040
set flags 0x001f
set pc 0x002000
set cycles 4
run
check cycles 0
check pc 0x002002
check reg d0 = 0x8765dfc0
check flags 0x0019
done

# test NEG instruction
start neg.w d0, take 2
set mem 0x002000 = 0x4440
set reg d0 = 0x8765ffff
set flags 0x0000
set pc 0x002000
set cycles 4
run
check cycles 0
check pc 0x002002
check reg d0 = 0x87650001
check flags 0x0011
done

# test NEG instruction
start neg.w d0, take 3
set mem 0x002000 = 0x4440
set reg d0 = 0x87650000
set flags 0x001f
set pc 0x002000
set cycles 4
run
check cycles 0
check pc 0x002002
check reg d0 = 0x87650000
check flags 0x0004
done

# test NEG instruction
start neg.l d0, take 1
set mem 0x002000 = 0x4480
set reg d0 = 0x20400000
set flags 0x001f
set pc 0x002000
set cycles 6
run
check cycles 0
check pc 0x002002
check reg d0 = 0xdfc00000
check flags 0x0019
done

# test NEG instruction
start neg.l d0, take 2
set mem 0x002000 = 0x4480
set reg d0 = 0xffffffff
set flags 0x0000
set pc 0x002000
set cycles 6
run
check cycles 0
check pc 0x002002
check reg d0 = 0x00000001
check flags 0x0011
done

# test NEG instruction
start neg.l d0, take 3
set mem 0x002000 = 0x4480
set reg d0 = 0x00000000
set flags 0x001f
set pc 0x002000
set cycles 6
run
check cycles 0
check pc 0x002002
check reg d0 = 0x00000000
check flags 0x0004
done

#
# $Log$
#
