~ubuntu-branches/ubuntu/saucy/bochs/saucy-proposed

« back to all changes in this revision

Viewing changes to cpu/ctrl_xfer8.cc

  • Committer: Bazaar Package Importer
  • Author(s): David Futcher
  • Date: 2009-04-30 07:46:11 UTC
  • mfrom: (1.1.11 upstream) (4.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090430074611-6dih80a5mk2uvxhk
Tags: 2.3.7+20090416-1ubuntu1
* Merge from debian unstable (LP: #370427), remaining changes:
  - debian/patches/12_no-ssp.patch: Build bios with -fno-stack-protector
  - Add Replaces/Conflicts for bochsbios-qemu (<< 2.3.6-2)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/////////////////////////////////////////////////////////////////////////
2
 
// $Id: ctrl_xfer8.cc,v 1.27 2008/03/22 21:29:39 sshwarts Exp $
3
 
/////////////////////////////////////////////////////////////////////////
4
 
//
5
 
//  Copyright (C) 2001  MandrakeSoft S.A.
6
 
//
7
 
//    MandrakeSoft S.A.
8
 
//    43, rue d'Aboukir
9
 
//    75002 Paris - France
10
 
//    http://www.linux-mandrake.com/
11
 
//    http://www.mandrakesoft.com/
12
 
//
13
 
//  This library is free software; you can redistribute it and/or
14
 
//  modify it under the terms of the GNU Lesser General Public
15
 
//  License as published by the Free Software Foundation; either
16
 
//  version 2 of the License, or (at your option) any later version.
17
 
//
18
 
//  This library is distributed in the hope that it will be useful,
19
 
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21
 
//  Lesser General Public License for more details.
22
 
//
23
 
//  You should have received a copy of the GNU Lesser General Public
24
 
//  License along with this library; if not, write to the Free Software
25
 
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
26
 
/////////////////////////////////////////////////////////////////////////
27
 
 
28
 
#define NEED_CPU_REG_SHORTCUTS 1
29
 
#include "bochs.h"
30
 
#include "cpu.h"
31
 
#define LOG_THIS BX_CPU_THIS_PTR
32
 
 
33
 
void BX_CPP_AttrRegparmN(1) BX_CPU_C::JCXZ_Jb(bxInstruction_c *i)
34
 
{
35
 
  // it is impossible to get this instruction in long mode
36
 
  BX_ASSERT(i->as64L() == 0);
37
 
 
38
 
  Bit32u temp_ECX;
39
 
 
40
 
  if (i->as32L())
41
 
    temp_ECX = ECX;
42
 
  else
43
 
    temp_ECX = CX;
44
 
 
45
 
  if (temp_ECX == 0) {
46
 
    Bit32u new_EIP = EIP + (Bit32s) i->Id();
47
 
    if (i->os32L()==0) new_EIP &= 0x0000ffff;
48
 
    branch_near32(new_EIP);
49
 
    BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP);
50
 
    return;
51
 
  }
52
 
 
53
 
  BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID);
54
 
}
55
 
 
56
 
//
57
 
// There is some weirdness in LOOP instructions definition. If an exception
58
 
// was generated during the instruction execution (for example #GP fault
59
 
// because EIP was beyond CS segment limits) CPU state should restore the
60
 
// state prior to instruction execution.
61
 
//
62
 
// The final point that we are not allowed to decrement ECX register before
63
 
// it is known that no exceptions can happen.
64
 
//
65
 
 
66
 
void BX_CPP_AttrRegparmN(1) BX_CPU_C::LOOPNE_Jb(bxInstruction_c *i)
67
 
{
68
 
  // it is impossible to get this instruction in long mode
69
 
  BX_ASSERT(i->as64L() == 0);
70
 
 
71
 
  Bit32u count;
72
 
 
73
 
#if BX_CPU_LEVEL >= 3
74
 
  if (i->as32L())
75
 
    count = ECX;
76
 
  else
77
 
#endif
78
 
    count = CX;
79
 
 
80
 
  count--;
81
 
  if ((count!=0) && (get_ZF()==0)) {
82
 
    Bit32u new_EIP = EIP + (Bit32s) i->Id();
83
 
    if (i->os32L()==0) new_EIP &= 0x0000ffff;
84
 
    branch_near32(new_EIP);
85
 
    BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP);
86
 
  }
87
 
#if BX_INSTRUMENTATION
88
 
  else {
89
 
    BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID);
90
 
  }
91
 
#endif
92
 
 
93
 
  if (i->as32L())
94
 
    ECX--;
95
 
  else
96
 
     CX--;
97
 
}
98
 
 
99
 
void BX_CPP_AttrRegparmN(1) BX_CPU_C::LOOPE_Jb(bxInstruction_c *i)
100
 
{
101
 
  // it is impossible to get this instruction in long mode
102
 
  BX_ASSERT(i->as64L() == 0);
103
 
 
104
 
  Bit32u count;
105
 
 
106
 
#if BX_CPU_LEVEL >= 3
107
 
  if (i->as32L())
108
 
    count = ECX;
109
 
  else
110
 
#endif
111
 
    count = CX;
112
 
 
113
 
  count--;
114
 
  if ((count!=0) && get_ZF()) {
115
 
    Bit32u new_EIP = EIP + (Bit32s) i->Id();
116
 
    if (i->os32L()==0) new_EIP &= 0x0000ffff;
117
 
    branch_near32(new_EIP);
118
 
    BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP);
119
 
  }
120
 
#if BX_INSTRUMENTATION
121
 
  else {
122
 
    BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID);
123
 
  }
124
 
#endif
125
 
 
126
 
  if (i->as32L())
127
 
    ECX--;
128
 
  else
129
 
     CX--;
130
 
}
131
 
 
132
 
void BX_CPP_AttrRegparmN(1) BX_CPU_C::LOOP_Jb(bxInstruction_c *i)
133
 
{
134
 
  // it is impossible to get this instruction in long mode
135
 
  BX_ASSERT(i->as64L() == 0);
136
 
 
137
 
  Bit32u count;
138
 
 
139
 
#if BX_CPU_LEVEL >= 3
140
 
  if (i->as32L())
141
 
    count = ECX;
142
 
  else
143
 
#endif
144
 
    count = CX;
145
 
 
146
 
  count--;
147
 
  if (count != 0) {
148
 
    Bit32u new_EIP = EIP + (Bit32s) i->Id();
149
 
    if (i->os32L()==0) new_EIP &= 0x0000ffff;
150
 
    branch_near32(new_EIP);
151
 
    BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP);
152
 
  }
153
 
#if BX_INSTRUMENTATION
154
 
  else {
155
 
    BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID);
156
 
  }
157
 
#endif
158
 
 
159
 
  if (i->as32L())
160
 
    ECX--;
161
 
  else
162
 
     CX--;
163
 
}