~parthm/nazgul/trunk

« back to all changes in this revision

Viewing changes to src/main/scala/opcodes/sahf.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.opcodes
 
19
 
 
20
import nazgul.decoder.argdata._
 
21
import nazgul.core.exceptions._
 
22
import nazgul.decoder.Instruction
 
23
import nazgul.core.Core
 
24
import nazgul.core.EFlags
 
25
import nazgul.core.EFlags._
 
26
import nazgul.registers._
 
27
import nazgul.PC
 
28
 
 
29
case object OpSAHF extends Opcode {
 
30
  override def execute(pc: PC, inst: Instruction): Unit = {
 
31
    super.execute(pc, inst)
 
32
    val MASK = 0xffffffff & ~SF_MASK & ~ZF_MASK & ~AF_MASK & ~PF_MASK & ~CF_MASK
 
33
    val f = pc.core.eflags.flags & MASK
 
34
    pc.core.eflags.flags = pc.core.ah | f
 
35
  }
 
36
}
 
37