~parthm/nazgul/trunk

« back to all changes in this revision

Viewing changes to src/test/scala/e-sahf-16.scala

  • Committer: Parth Malwankar
  • Date: 2009-11-19 04:56:43 UTC
  • mfrom: (517.1.2 e-sahf-16)
  • Revision ID: parth.malwankar@gmail.com-20091119045643-01wqdpt4jjrsz3st
SAHF emulation

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// Copyright (C) 2009 Parth Malwankar  <parth.malwankar@gmail.com>
 
3
//
 
4
// This program is free software: you can redistribute it and/or modify
 
5
// it under the terms of the GNU General Public License as published by
 
6
// the Free Software Foundation, either version 3 of the License, or
 
7
// (at your option) any later version.
 
8
//
 
9
// This program is distributed in the hope that it will be useful,
 
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
// GNU General Public License for more details.
 
13
//
 
14
// You should have received a copy of the GNU General Public License
 
15
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
//
 
17
 
 
18
package nazgul.test
 
19
 
 
20
import org.scalatest.FunSuite
 
21
 
 
22
 
 
23
import nazgul.decoder._
 
24
import nazgul.decoder.argdata._
 
25
import nazgul.opcodes._
 
26
import nazgul.registers._
 
27
import nazgul.core.OperatingMode._
 
28
import nazgul.core.exceptions._
 
29
import nazgul.utils._
 
30
import nazgul.core.EFlags
 
31
 
 
32
class E16SAHFTest extends FunSuite {
 
33
  test("sahf; sf") {
 
34
    val pc = new PC
 
35
    val i = Common.decodeBytesAsInst(Mode16, 0x9e)
 
36
 
 
37
    pc.core.ah = EFlags.SF_MASK.toByte
 
38
 
 
39
    assert(pc.core.eflags.sf === false)
 
40
    i.encodedOp.op.execute(pc, i)
 
41
    assert(pc.core.eflags.sf === true)
 
42
  }
 
43
 
 
44
  test("sahf; zf") {
 
45
    val pc = new PC
 
46
    val i = Common.decodeBytesAsInst(Mode16, 0x9e)
 
47
 
 
48
    pc.core.ah = EFlags.ZF_MASK.toByte
 
49
 
 
50
    assert(pc.core.eflags.zf === false)
 
51
    i.encodedOp.op.execute(pc, i)
 
52
    assert(pc.core.eflags.zf === true)
 
53
  }
 
54
 
 
55
  test("sahf; af") {
 
56
    val pc = new PC
 
57
    val i = Common.decodeBytesAsInst(Mode16, 0x9e)
 
58
 
 
59
    pc.core.ah = EFlags.AF_MASK.toByte
 
60
 
 
61
    assert(pc.core.eflags.af === false)
 
62
    i.encodedOp.op.execute(pc, i)
 
63
    assert(pc.core.eflags.af === true)
 
64
  }
 
65
 
 
66
  test("sahf; pf") {
 
67
    val pc = new PC
 
68
    val i = Common.decodeBytesAsInst(Mode16, 0x9e)
 
69
 
 
70
    pc.core.ah = EFlags.PF_MASK.toByte
 
71
 
 
72
    assert(pc.core.eflags.pf === false)
 
73
    i.encodedOp.op.execute(pc, i)
 
74
    assert(pc.core.eflags.pf === true)
 
75
  }
 
76
 
 
77
  test("sahf; cf") {
 
78
    val pc = new PC
 
79
    val i = Common.decodeBytesAsInst(Mode16, 0x9e)
 
80
 
 
81
    pc.core.ah = EFlags.CF_MASK.toByte
 
82
 
 
83
    assert(pc.core.eflags.cf === false)
 
84
    i.encodedOp.op.execute(pc, i)
 
85
    assert(pc.core.eflags.cf === true)
 
86
  }
 
87
 
 
88
}
 
89