1 /////////////////////////////////////////////////////////////////////////
2 // $Id: bcd.cc,v 1.25 2008/09/19 19:18:56 sshwarts Exp $
3 /////////////////////////////////////////////////////////////////////////
5 // Copyright (C) 2002 MandrakeSoft S.A.
9 // 75002 Paris - France
10 // http://www.linux-mandrake.com/
11 // http://www.mandrakesoft.com/
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.
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.
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 /////////////////////////////////////////////////////////////////////////
28 #define NEED_CPU_REG_SHORTCUTS 1
31 #define LOG_THIS BX_CPU_THIS_PTR
33 void BX_CPP_AttrRegparmN(1) BX_CPU_C::AAA(bxInstruction_c
*i
)
36 * Note: This instruction incorrectly documented in Intel's materials.
37 * The right description is:
39 * IF (((AL and 0FH) > 9) or (AF==1)
41 * IF CPU<286 THEN { AL <- AL+6 }
53 /* Validated against Intel Pentium family hardware. */
55 /* AAA affects the following flags: A,C */
57 if (((AL
& 0x0f) > 9) || get_AF())
70 /* AAA affects also the following flags: Z,S,O,P */
71 /* modification of the flags is undocumented */
73 /* The following behaviour seems to match the P6 and
74 its derived processors. */
76 clear_SF(); /* sign is always 0 because bits 4-7 of AL are zeroed */
81 void BX_CPP_AttrRegparmN(1) BX_CPU_C::AAS(bxInstruction_c
*i
)
83 /* AAS affects the following flags: A,C */
85 if (((AL
& 0x0F) > 0x09) || get_AF())
98 /* AAS affects also the following flags: Z,S,O,P */
99 /* modification of the flags is undocumented */
101 /* The following behaviour seems to match the P6 and
102 its derived processors. */
104 clear_SF(); /* sign is always 0 because bits 4-7 of AL are zeroed */
109 void BX_CPP_AttrRegparmN(1) BX_CPU_C::AAM(bxInstruction_c
*i
)
111 Bit8u al
, imm8
= i
->Ib();
114 exception(BX_DE_EXCEPTION
, 0, 0);
120 /* modification of flags A,C,O is undocumented */
121 /* The following behaviour seems to match the P6 and
122 its derived processors. */
123 SET_FLAGS_OSZAPC_LOGIC_8(AL
);
126 void BX_CPP_AttrRegparmN(1) BX_CPU_C::AAD(bxInstruction_c
*i
)
134 /* modification of flags A,C,O is undocumented */
135 /* The following behaviour seems to match the P6 and
136 its derived processors. */
137 SET_FLAGS_OSZAPC_LOGIC_8(AL
);
140 void BX_CPP_AttrRegparmN(1) BX_CPU_C::DAA(bxInstruction_c
*i
)
145 /* Validated against Intel Pentium family hardware. */
147 // DAA affects the following flags: S,Z,A,P,C
149 if (((tmpAL
& 0x0F) > 0x09) || get_AF())
151 tmpCF
= ((AL
> 0xF9) || get_CF());
158 if ((tmpAL
> 0x99) || get_CF())
166 clear_OF(); /* undocumented flag modification */
173 void BX_CPP_AttrRegparmN(1) BX_CPU_C::DAS(bxInstruction_c
*i
)
175 /* The algorithm for DAS is fashioned after the pseudo code in the
176 * Pentium Processor Family Developer's Manual, volume 3. It seems
177 * to have changed from earlier processor's manuals. I'm not sure
178 * if this is a correction in the algorithm printed, or Intel has
179 * changed the handling of instruction. Validated against Intel
180 * Pentium family hardware.
186 /* DAS effect the following flags: A,C,S,Z,P */
188 if (((tmpAL
& 0x0F) > 0x09) || get_AF())
190 tmpCF
= (AL
< 0x06) || get_CF();
197 if ((tmpAL
> 0x99) || get_CF())
203 clear_OF(); /* undocumented flag modification */