2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2009-01-16 21:18:59 +03:00
|
|
|
// $Id: string.cc,v 1.70 2009-01-16 18:18:59 sshwarts Exp $
|
2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2001-04-10 06:20:02 +04:00
|
|
|
// Copyright (C) 2001 MandrakeSoft S.A.
|
2001-04-10 05:04:59 +04:00
|
|
|
//
|
|
|
|
// MandrakeSoft S.A.
|
|
|
|
// 43, rue d'Aboukir
|
|
|
|
// 75002 Paris - France
|
|
|
|
// http://www.linux-mandrake.com/
|
|
|
|
// http://www.mandrakesoft.com/
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
2009-01-16 21:18:59 +03:00
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA B 02110-1301 USA
|
2007-11-18 02:28:33 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-05-24 22:46:34 +04:00
|
|
|
#define NEED_CPU_REG_SHORTCUTS 1
|
2001-04-10 05:04:59 +04:00
|
|
|
#include "bochs.h"
|
2006-03-07 01:03:16 +03:00
|
|
|
#include "cpu.h"
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
#define LOG_THIS BX_CPU_THIS_PTR
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2002-09-15 09:09:18 +04:00
|
|
|
#if BX_SUPPORT_X86_64==0
|
|
|
|
#define RSI ESI
|
|
|
|
#define RDI EDI
|
|
|
|
#define RAX EAX
|
2007-09-27 20:11:32 +04:00
|
|
|
#define RCX ECX
|
2002-09-15 09:09:18 +04:00
|
|
|
#endif
|
|
|
|
|
2007-01-05 16:40:47 +03:00
|
|
|
//
|
|
|
|
// Repeat Speedups methods
|
|
|
|
//
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
|
2005-07-04 21:44:08 +04:00
|
|
|
#if BX_SupportRepeatSpeedups
|
|
|
|
Bit32u BX_CPU_C::FastRepMOVSB(bxInstruction_c *i, unsigned srcSeg, bx_address srcOff, unsigned dstSeg, bx_address dstOff, Bit32u count)
|
|
|
|
{
|
|
|
|
Bit32u bytesFitSrc, bytesFitDst;
|
|
|
|
signed int pointerDelta;
|
|
|
|
bx_address laddrDst, laddrSrc;
|
2007-10-29 18:39:18 +03:00
|
|
|
Bit8u *hostAddrSrc, *hostAddrDst;
|
2005-07-04 21:44:08 +04:00
|
|
|
|
2008-09-09 00:47:33 +04:00
|
|
|
BX_ASSERT(BX_CPU_THIS_PTR cpu_mode != BX_MODE_LONG_64);
|
|
|
|
|
2005-07-04 21:44:08 +04:00
|
|
|
bx_segment_reg_t *srcSegPtr = &BX_CPU_THIS_PTR sregs[srcSeg];
|
2008-09-09 00:47:33 +04:00
|
|
|
if (!(srcSegPtr->cache.valid & SegAccessROK))
|
|
|
|
return 0;
|
|
|
|
if ((srcOff | 0xfff) > srcSegPtr->cache.u.segment.limit_scaled)
|
2008-03-21 23:35:46 +03:00
|
|
|
return 0;
|
|
|
|
|
2005-07-04 21:44:08 +04:00
|
|
|
bx_segment_reg_t *dstSegPtr = &BX_CPU_THIS_PTR sregs[dstSeg];
|
2008-09-09 00:47:33 +04:00
|
|
|
if (!(dstSegPtr->cache.valid & SegAccessWOK))
|
|
|
|
return 0;
|
|
|
|
if ((dstOff | 0xfff) > dstSegPtr->cache.u.segment.limit_scaled)
|
2008-03-21 23:35:46 +03:00
|
|
|
return 0;
|
2005-07-04 21:44:08 +04:00
|
|
|
|
2008-04-07 22:39:17 +04:00
|
|
|
laddrSrc = BX_CPU_THIS_PTR get_laddr(srcSeg, srcOff);
|
2007-10-29 18:39:18 +03:00
|
|
|
|
2008-08-03 23:53:09 +04:00
|
|
|
hostAddrSrc = v2h_read_byte(laddrSrc, BX_CPU_THIS_PTR user_pl);
|
2005-07-04 21:44:08 +04:00
|
|
|
if (! hostAddrSrc) return 0;
|
|
|
|
|
2008-04-07 22:39:17 +04:00
|
|
|
laddrDst = BX_CPU_THIS_PTR get_laddr(dstSeg, dstOff);
|
2007-10-29 18:39:18 +03:00
|
|
|
|
2008-08-03 23:53:09 +04:00
|
|
|
hostAddrDst = v2h_write_byte(laddrDst, BX_CPU_THIS_PTR user_pl);
|
2008-10-21 23:50:05 +04:00
|
|
|
// Check that native host access was not vetoed for that page
|
|
|
|
if (!hostAddrDst) return 0;
|
2005-07-04 21:44:08 +04:00
|
|
|
|
|
|
|
// See how many bytes can fit in the rest of this page.
|
2006-05-07 22:27:36 +04:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
2005-07-04 21:44:08 +04:00
|
|
|
// Counting downward.
|
2007-12-27 02:07:44 +03:00
|
|
|
bytesFitSrc = 1 + PAGE_OFFSET(laddrSrc);
|
|
|
|
bytesFitDst = 1 + PAGE_OFFSET(laddrDst);
|
2005-07-04 21:44:08 +04:00
|
|
|
pointerDelta = (signed int) -1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Counting upward.
|
2007-12-27 02:07:44 +03:00
|
|
|
bytesFitSrc = 0x1000 - PAGE_OFFSET(laddrSrc);
|
|
|
|
bytesFitDst = 0x1000 - PAGE_OFFSET(laddrDst);
|
2005-07-04 21:44:08 +04:00
|
|
|
pointerDelta = (signed int) 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Restrict word count to the number that will fit in either
|
|
|
|
// source or dest pages.
|
|
|
|
if (count > bytesFitSrc)
|
|
|
|
count = bytesFitSrc;
|
|
|
|
if (count > bytesFitDst)
|
|
|
|
count = bytesFitDst;
|
|
|
|
if (count > bx_pc_system.getNumCpuTicksLeftNextEvent())
|
|
|
|
count = bx_pc_system.getNumCpuTicksLeftNextEvent();
|
|
|
|
|
|
|
|
// If after all the restrictions, there is anything left to do...
|
|
|
|
if (count) {
|
|
|
|
// Transfer data directly using host addresses
|
|
|
|
for (unsigned j=0; j<count; j++) {
|
|
|
|
* (Bit8u *) hostAddrDst = * (Bit8u *) hostAddrSrc;
|
|
|
|
hostAddrDst += pointerDelta;
|
|
|
|
hostAddrSrc += pointerDelta;
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Bit32u BX_CPU_C::FastRepMOVSW(bxInstruction_c *i, unsigned srcSeg, bx_address srcOff, unsigned dstSeg, bx_address dstOff, Bit32u count)
|
|
|
|
{
|
|
|
|
Bit32u wordsFitSrc, wordsFitDst;
|
|
|
|
signed int pointerDelta;
|
|
|
|
bx_address laddrDst, laddrSrc;
|
2007-10-29 18:39:18 +03:00
|
|
|
Bit8u *hostAddrSrc, *hostAddrDst;
|
2005-07-04 21:44:08 +04:00
|
|
|
|
2008-09-09 00:47:33 +04:00
|
|
|
BX_ASSERT(BX_CPU_THIS_PTR cpu_mode != BX_MODE_LONG_64);
|
|
|
|
|
2005-07-04 21:44:08 +04:00
|
|
|
bx_segment_reg_t *srcSegPtr = &BX_CPU_THIS_PTR sregs[srcSeg];
|
2008-09-09 00:47:33 +04:00
|
|
|
if (!(srcSegPtr->cache.valid & SegAccessROK))
|
|
|
|
return 0;
|
|
|
|
if ((srcOff | 0xfff) > srcSegPtr->cache.u.segment.limit_scaled)
|
2008-03-21 23:35:46 +03:00
|
|
|
return 0;
|
|
|
|
|
2005-07-04 21:44:08 +04:00
|
|
|
bx_segment_reg_t *dstSegPtr = &BX_CPU_THIS_PTR sregs[dstSeg];
|
2008-09-09 00:47:33 +04:00
|
|
|
if (!(dstSegPtr->cache.valid & SegAccessWOK))
|
|
|
|
return 0;
|
|
|
|
if ((dstOff | 0xfff) > dstSegPtr->cache.u.segment.limit_scaled)
|
2008-03-21 23:35:46 +03:00
|
|
|
return 0;
|
2005-07-04 21:44:08 +04:00
|
|
|
|
2008-04-07 22:39:17 +04:00
|
|
|
laddrSrc = BX_CPU_THIS_PTR get_laddr(srcSeg, srcOff);
|
2007-10-29 18:39:18 +03:00
|
|
|
|
2008-08-03 23:53:09 +04:00
|
|
|
hostAddrSrc = v2h_read_byte(laddrSrc, BX_CPU_THIS_PTR user_pl);
|
2005-07-04 21:44:08 +04:00
|
|
|
if (! hostAddrSrc) return 0;
|
|
|
|
|
2008-04-07 22:39:17 +04:00
|
|
|
laddrDst = BX_CPU_THIS_PTR get_laddr(dstSeg, dstOff);
|
2007-10-29 18:39:18 +03:00
|
|
|
|
2008-08-03 23:53:09 +04:00
|
|
|
hostAddrDst = v2h_write_byte(laddrDst, BX_CPU_THIS_PTR user_pl);
|
2008-10-21 23:50:05 +04:00
|
|
|
// Check that native host access was not vetoed for that page
|
|
|
|
if (!hostAddrDst) return 0;
|
2005-07-04 21:44:08 +04:00
|
|
|
|
|
|
|
// See how many words can fit in the rest of this page.
|
2006-05-07 22:27:36 +04:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
2005-07-04 21:44:08 +04:00
|
|
|
// Counting downward.
|
|
|
|
// Note: 1st word must not cross page boundary.
|
2007-12-17 22:52:01 +03:00
|
|
|
if (((laddrSrc & 0xfff) > 0xffe) || ((laddrDst & 0xfff) > 0xffe))
|
2005-07-04 21:44:08 +04:00
|
|
|
return 0;
|
2007-12-27 02:07:44 +03:00
|
|
|
wordsFitSrc = (2 + PAGE_OFFSET(laddrSrc)) >> 1;
|
|
|
|
wordsFitDst = (2 + PAGE_OFFSET(laddrDst)) >> 1;
|
2005-07-04 21:44:08 +04:00
|
|
|
pointerDelta = (signed int) -2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Counting upward.
|
2007-12-27 02:07:44 +03:00
|
|
|
wordsFitSrc = (0x1000 - PAGE_OFFSET(laddrSrc)) >> 1;
|
|
|
|
wordsFitDst = (0x1000 - PAGE_OFFSET(laddrDst)) >> 1;
|
2005-07-04 21:44:08 +04:00
|
|
|
pointerDelta = (signed int) 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Restrict word count to the number that will fit in either
|
|
|
|
// source or dest pages.
|
|
|
|
if (count > wordsFitSrc)
|
|
|
|
count = wordsFitSrc;
|
|
|
|
if (count > wordsFitDst)
|
|
|
|
count = wordsFitDst;
|
|
|
|
if (count > bx_pc_system.getNumCpuTicksLeftNextEvent())
|
|
|
|
count = bx_pc_system.getNumCpuTicksLeftNextEvent();
|
|
|
|
|
|
|
|
// If after all the restrictions, there is anything left to do...
|
|
|
|
if (count) {
|
|
|
|
// Transfer data directly using host addresses
|
|
|
|
for (unsigned j=0; j<count; j++) {
|
2008-02-07 23:43:13 +03:00
|
|
|
CopyHostWordLittleEndian(hostAddrDst, hostAddrSrc);
|
2005-07-04 21:44:08 +04:00
|
|
|
hostAddrDst += pointerDelta;
|
|
|
|
hostAddrSrc += pointerDelta;
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Bit32u BX_CPU_C::FastRepMOVSD(bxInstruction_c *i, unsigned srcSeg, bx_address srcOff, unsigned dstSeg, bx_address dstOff, Bit32u count)
|
|
|
|
{
|
|
|
|
Bit32u dwordsFitSrc, dwordsFitDst;
|
|
|
|
signed int pointerDelta;
|
|
|
|
bx_address laddrDst, laddrSrc;
|
2007-10-29 18:39:18 +03:00
|
|
|
Bit8u *hostAddrSrc, *hostAddrDst;
|
2005-07-04 21:44:08 +04:00
|
|
|
|
2008-09-09 00:47:33 +04:00
|
|
|
BX_ASSERT(BX_CPU_THIS_PTR cpu_mode != BX_MODE_LONG_64);
|
|
|
|
|
2005-07-04 21:44:08 +04:00
|
|
|
bx_segment_reg_t *srcSegPtr = &BX_CPU_THIS_PTR sregs[srcSeg];
|
2008-09-09 00:47:33 +04:00
|
|
|
if (!(srcSegPtr->cache.valid & SegAccessROK))
|
|
|
|
return 0;
|
|
|
|
if ((srcOff | 0xfff) > srcSegPtr->cache.u.segment.limit_scaled)
|
2008-03-21 23:35:46 +03:00
|
|
|
return 0;
|
|
|
|
|
2005-07-04 21:44:08 +04:00
|
|
|
bx_segment_reg_t *dstSegPtr = &BX_CPU_THIS_PTR sregs[dstSeg];
|
2008-09-09 00:47:33 +04:00
|
|
|
if (!(dstSegPtr->cache.valid & SegAccessWOK))
|
|
|
|
return 0;
|
|
|
|
if ((dstOff | 0xfff) > dstSegPtr->cache.u.segment.limit_scaled)
|
2008-03-21 23:35:46 +03:00
|
|
|
return 0;
|
2005-07-04 21:44:08 +04:00
|
|
|
|
2008-04-07 22:39:17 +04:00
|
|
|
laddrSrc = BX_CPU_THIS_PTR get_laddr(srcSeg, srcOff);
|
2007-10-29 18:39:18 +03:00
|
|
|
|
2008-08-03 23:53:09 +04:00
|
|
|
hostAddrSrc = v2h_read_byte(laddrSrc, BX_CPU_THIS_PTR user_pl);
|
2005-07-04 21:44:08 +04:00
|
|
|
if (! hostAddrSrc) return 0;
|
|
|
|
|
2008-04-07 22:39:17 +04:00
|
|
|
laddrDst = BX_CPU_THIS_PTR get_laddr(dstSeg, dstOff);
|
2007-10-29 18:39:18 +03:00
|
|
|
|
2008-08-03 23:53:09 +04:00
|
|
|
hostAddrDst = v2h_write_byte(laddrDst, BX_CPU_THIS_PTR user_pl);
|
2008-10-21 23:50:05 +04:00
|
|
|
// Check that native host access was not vetoed for that page
|
|
|
|
if (!hostAddrDst) return 0;
|
2005-07-04 21:44:08 +04:00
|
|
|
|
|
|
|
// See how many dwords can fit in the rest of this page.
|
2006-05-07 22:27:36 +04:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
2005-07-04 21:44:08 +04:00
|
|
|
// Counting downward.
|
|
|
|
// Note: 1st dword must not cross page boundary.
|
2007-12-17 22:52:01 +03:00
|
|
|
if (((laddrSrc & 0xfff) > 0xffc) || ((laddrDst & 0xfff) > 0xffc))
|
2008-02-03 00:46:54 +03:00
|
|
|
return 0;
|
2007-12-27 02:07:44 +03:00
|
|
|
dwordsFitSrc = (4 + PAGE_OFFSET(laddrSrc)) >> 2;
|
|
|
|
dwordsFitDst = (4 + PAGE_OFFSET(laddrDst)) >> 2;
|
2005-07-04 21:44:08 +04:00
|
|
|
pointerDelta = (signed int) -4;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Counting upward.
|
2007-12-27 02:07:44 +03:00
|
|
|
dwordsFitSrc = (0x1000 - PAGE_OFFSET(laddrSrc)) >> 2;
|
|
|
|
dwordsFitDst = (0x1000 - PAGE_OFFSET(laddrDst)) >> 2;
|
2005-07-04 21:44:08 +04:00
|
|
|
pointerDelta = (signed int) 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Restrict dword count to the number that will fit in either
|
|
|
|
// source or dest pages.
|
|
|
|
if (count > dwordsFitSrc)
|
|
|
|
count = dwordsFitSrc;
|
|
|
|
if (count > dwordsFitDst)
|
|
|
|
count = dwordsFitDst;
|
|
|
|
if (count > bx_pc_system.getNumCpuTicksLeftNextEvent())
|
|
|
|
count = bx_pc_system.getNumCpuTicksLeftNextEvent();
|
|
|
|
|
|
|
|
// If after all the restrictions, there is anything left to do...
|
|
|
|
if (count) {
|
|
|
|
// Transfer data directly using host addresses
|
|
|
|
for (unsigned j=0; j<count; j++) {
|
2008-02-07 23:43:13 +03:00
|
|
|
CopyHostDWordLittleEndian(hostAddrDst, hostAddrSrc);
|
2005-07-04 21:44:08 +04:00
|
|
|
hostAddrDst += pointerDelta;
|
|
|
|
hostAddrSrc += pointerDelta;
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Bit32u BX_CPU_C::FastRepSTOSB(bxInstruction_c *i, unsigned dstSeg, bx_address dstOff, Bit8u val, Bit32u count)
|
|
|
|
{
|
|
|
|
Bit32u bytesFitDst;
|
|
|
|
signed int pointerDelta;
|
|
|
|
bx_address laddrDst;
|
2007-10-29 18:39:18 +03:00
|
|
|
Bit8u *hostAddrDst;
|
2005-07-04 21:44:08 +04:00
|
|
|
|
2008-09-09 00:47:33 +04:00
|
|
|
BX_ASSERT(BX_CPU_THIS_PTR cpu_mode != BX_MODE_LONG_64);
|
|
|
|
|
2005-07-04 21:44:08 +04:00
|
|
|
bx_segment_reg_t *dstSegPtr = &BX_CPU_THIS_PTR sregs[dstSeg];
|
2008-09-09 00:47:33 +04:00
|
|
|
if (!(dstSegPtr->cache.valid & SegAccessWOK))
|
|
|
|
return 0;
|
|
|
|
if ((dstOff | 0xfff) > dstSegPtr->cache.u.segment.limit_scaled)
|
2008-03-21 23:35:46 +03:00
|
|
|
return 0;
|
2005-07-04 21:44:08 +04:00
|
|
|
|
2008-04-07 22:39:17 +04:00
|
|
|
laddrDst = BX_CPU_THIS_PTR get_laddr(dstSeg, dstOff);
|
2007-10-29 18:39:18 +03:00
|
|
|
|
2008-08-03 23:53:09 +04:00
|
|
|
hostAddrDst = v2h_write_byte(laddrDst, BX_CPU_THIS_PTR user_pl);
|
2008-10-21 23:50:05 +04:00
|
|
|
// Check that native host access was not vetoed for that page
|
|
|
|
if (!hostAddrDst) return 0;
|
2005-07-04 21:44:08 +04:00
|
|
|
|
|
|
|
// See how many bytes can fit in the rest of this page.
|
2006-05-07 22:27:36 +04:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
2005-07-04 21:44:08 +04:00
|
|
|
// Counting downward.
|
2007-12-27 02:07:44 +03:00
|
|
|
bytesFitDst = 1 + PAGE_OFFSET(laddrDst);
|
2005-07-04 21:44:08 +04:00
|
|
|
pointerDelta = (signed int) -1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Counting upward.
|
2007-12-27 02:07:44 +03:00
|
|
|
bytesFitDst = 0x1000 - PAGE_OFFSET(laddrDst);
|
2005-07-04 21:44:08 +04:00
|
|
|
pointerDelta = (signed int) 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Restrict word count to the number that will fit in either
|
|
|
|
// source or dest pages.
|
|
|
|
if (count > bytesFitDst)
|
|
|
|
count = bytesFitDst;
|
|
|
|
if (count > bx_pc_system.getNumCpuTicksLeftNextEvent())
|
|
|
|
count = bx_pc_system.getNumCpuTicksLeftNextEvent();
|
|
|
|
|
|
|
|
// If after all the restrictions, there is anything left to do...
|
|
|
|
if (count) {
|
|
|
|
// Transfer data directly using host addresses
|
|
|
|
for (unsigned j=0; j<count; j++) {
|
|
|
|
* (Bit8u *) hostAddrDst = val;
|
|
|
|
hostAddrDst += pointerDelta;
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Bit32u BX_CPU_C::FastRepSTOSW(bxInstruction_c *i, unsigned dstSeg, bx_address dstOff, Bit16u val, Bit32u count)
|
|
|
|
{
|
|
|
|
Bit32u wordsFitDst;
|
|
|
|
signed int pointerDelta;
|
|
|
|
bx_address laddrDst;
|
2007-10-29 18:39:18 +03:00
|
|
|
Bit8u *hostAddrDst;
|
2005-07-04 21:44:08 +04:00
|
|
|
|
2008-09-09 00:47:33 +04:00
|
|
|
BX_ASSERT(BX_CPU_THIS_PTR cpu_mode != BX_MODE_LONG_64);
|
|
|
|
|
2005-07-04 21:44:08 +04:00
|
|
|
bx_segment_reg_t *dstSegPtr = &BX_CPU_THIS_PTR sregs[dstSeg];
|
2008-09-09 00:47:33 +04:00
|
|
|
if (!(dstSegPtr->cache.valid & SegAccessWOK))
|
|
|
|
return 0;
|
|
|
|
if ((dstOff | 0xfff) > dstSegPtr->cache.u.segment.limit_scaled)
|
2008-03-21 23:35:46 +03:00
|
|
|
return 0;
|
2005-07-04 21:44:08 +04:00
|
|
|
|
2008-04-07 22:39:17 +04:00
|
|
|
laddrDst = BX_CPU_THIS_PTR get_laddr(dstSeg, dstOff);
|
2007-10-29 18:39:18 +03:00
|
|
|
|
2008-08-03 23:53:09 +04:00
|
|
|
hostAddrDst = v2h_write_byte(laddrDst, BX_CPU_THIS_PTR user_pl);
|
2008-10-21 23:50:05 +04:00
|
|
|
// Check that native host access was not vetoed for that page
|
|
|
|
if (!hostAddrDst) return 0;
|
2005-07-04 21:44:08 +04:00
|
|
|
|
|
|
|
// See how many words can fit in the rest of this page.
|
2006-05-07 22:27:36 +04:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
2005-07-04 21:44:08 +04:00
|
|
|
// Counting downward.
|
|
|
|
// Note: 1st word must not cross page boundary.
|
2007-10-29 18:39:18 +03:00
|
|
|
if ((laddrDst & 0xfff) > 0xffe) return 0;
|
2007-12-27 02:07:44 +03:00
|
|
|
wordsFitDst = (2 + PAGE_OFFSET(laddrDst)) >> 1;
|
2005-07-04 21:44:08 +04:00
|
|
|
pointerDelta = (signed int) -2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Counting upward.
|
2007-12-27 02:07:44 +03:00
|
|
|
wordsFitDst = (0x1000 - PAGE_OFFSET(laddrDst)) >> 1;
|
2005-07-04 21:44:08 +04:00
|
|
|
pointerDelta = (signed int) 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Restrict word count to the number that will fit in either
|
|
|
|
// source or dest pages.
|
|
|
|
if (count > wordsFitDst)
|
|
|
|
count = wordsFitDst;
|
|
|
|
if (count > bx_pc_system.getNumCpuTicksLeftNextEvent())
|
|
|
|
count = bx_pc_system.getNumCpuTicksLeftNextEvent();
|
|
|
|
|
|
|
|
// If after all the restrictions, there is anything left to do...
|
|
|
|
if (count) {
|
|
|
|
// Transfer data directly using host addresses
|
|
|
|
for (unsigned j=0; j<count; j++) {
|
2008-02-07 23:43:13 +03:00
|
|
|
WriteHostWordToLittleEndian(hostAddrDst, val);
|
2005-07-04 21:44:08 +04:00
|
|
|
hostAddrDst += pointerDelta;
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Bit32u BX_CPU_C::FastRepSTOSD(bxInstruction_c *i, unsigned dstSeg, bx_address dstOff, Bit32u val, Bit32u count)
|
|
|
|
{
|
|
|
|
Bit32u dwordsFitDst;
|
|
|
|
signed int pointerDelta;
|
|
|
|
bx_address laddrDst;
|
2007-10-29 18:39:18 +03:00
|
|
|
Bit8u *hostAddrDst;
|
2005-07-04 21:44:08 +04:00
|
|
|
|
2008-09-09 00:47:33 +04:00
|
|
|
BX_ASSERT(BX_CPU_THIS_PTR cpu_mode != BX_MODE_LONG_64);
|
|
|
|
|
2005-07-04 21:44:08 +04:00
|
|
|
bx_segment_reg_t *dstSegPtr = &BX_CPU_THIS_PTR sregs[dstSeg];
|
2008-09-09 00:47:33 +04:00
|
|
|
if (!(dstSegPtr->cache.valid & SegAccessWOK))
|
|
|
|
return 0;
|
|
|
|
if ((dstOff | 0xfff) > dstSegPtr->cache.u.segment.limit_scaled)
|
2008-03-21 23:35:46 +03:00
|
|
|
return 0;
|
2005-07-04 21:44:08 +04:00
|
|
|
|
2008-04-07 22:39:17 +04:00
|
|
|
laddrDst = BX_CPU_THIS_PTR get_laddr(dstSeg, dstOff);
|
2007-10-29 18:39:18 +03:00
|
|
|
|
2008-08-03 23:53:09 +04:00
|
|
|
hostAddrDst = v2h_write_byte(laddrDst, BX_CPU_THIS_PTR user_pl);
|
2008-10-21 23:50:05 +04:00
|
|
|
// Check that native host access was not vetoed for that page
|
|
|
|
if (!hostAddrDst) return 0;
|
2005-07-04 21:44:08 +04:00
|
|
|
|
|
|
|
// See how many dwords can fit in the rest of this page.
|
2006-05-07 22:27:36 +04:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
2005-07-04 21:44:08 +04:00
|
|
|
// Counting downward.
|
|
|
|
// Note: 1st dword must not cross page boundary.
|
2008-02-03 00:46:54 +03:00
|
|
|
if ((laddrDst & 0xfff) > 0xffc) return 0;
|
2007-12-27 02:07:44 +03:00
|
|
|
dwordsFitDst = (4 + PAGE_OFFSET(laddrDst)) >> 2;
|
2005-07-04 21:44:08 +04:00
|
|
|
pointerDelta = (signed int) -4;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Counting upward.
|
2007-12-27 02:07:44 +03:00
|
|
|
dwordsFitDst = (0x1000 - PAGE_OFFSET(laddrDst)) >> 2;
|
2005-07-04 21:44:08 +04:00
|
|
|
pointerDelta = (signed int) 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Restrict dword count to the number that will fit in either
|
|
|
|
// source or dest pages.
|
|
|
|
if (count > dwordsFitDst)
|
|
|
|
count = dwordsFitDst;
|
|
|
|
if (count > bx_pc_system.getNumCpuTicksLeftNextEvent())
|
|
|
|
count = bx_pc_system.getNumCpuTicksLeftNextEvent();
|
|
|
|
|
|
|
|
// If after all the restrictions, there is anything left to do...
|
|
|
|
if (count) {
|
|
|
|
// Transfer data directly using host addresses
|
|
|
|
for (unsigned j=0; j<count; j++) {
|
2008-02-07 23:43:13 +03:00
|
|
|
WriteHostDWordToLittleEndian(hostAddrDst, val);
|
2005-07-04 21:44:08 +04:00
|
|
|
hostAddrDst += pointerDelta;
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-01-05 16:40:47 +03:00
|
|
|
//
|
|
|
|
// REP MOVS methods
|
|
|
|
//
|
|
|
|
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::REP_MOVSB_XbYb(bxInstruction_c *i)
|
2007-01-05 16:40:47 +03:00
|
|
|
{
|
2007-12-17 22:52:01 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
if (i->as64L())
|
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::MOVSB64_XbYb);
|
|
|
|
else
|
|
|
|
#endif
|
2008-04-16 20:44:06 +04:00
|
|
|
if (i->as32L()) {
|
2007-12-17 22:52:01 +03:00
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::MOVSB32_XbYb);
|
2008-04-16 20:44:06 +04:00
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RSI); // always clear upper part of RSI/RDI
|
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RDI);
|
|
|
|
}
|
|
|
|
else {
|
2007-12-17 22:52:01 +03:00
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::MOVSB16_XbYb);
|
2008-04-16 20:44:06 +04:00
|
|
|
}
|
2007-01-05 16:40:47 +03:00
|
|
|
}
|
|
|
|
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::REP_MOVSW_XwYw(bxInstruction_c *i)
|
2007-01-05 16:40:47 +03:00
|
|
|
{
|
2007-12-17 22:52:01 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
if (i->as64L())
|
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::MOVSW64_XwYw);
|
|
|
|
else
|
|
|
|
#endif
|
2008-04-16 20:44:06 +04:00
|
|
|
if (i->as32L()) {
|
2007-12-17 22:52:01 +03:00
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::MOVSW32_XwYw);
|
2008-04-16 20:44:06 +04:00
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RSI); // always clear upper part of RSI/RDI
|
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RDI);
|
|
|
|
}
|
|
|
|
else {
|
2007-12-17 22:52:01 +03:00
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::MOVSW16_XwYw);
|
2008-04-16 20:44:06 +04:00
|
|
|
}
|
2007-01-05 16:40:47 +03:00
|
|
|
}
|
|
|
|
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::REP_MOVSD_XdYd(bxInstruction_c *i)
|
2007-01-05 16:40:47 +03:00
|
|
|
{
|
2007-12-17 22:52:01 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
if (i->as64L())
|
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::MOVSD64_XdYd);
|
|
|
|
else
|
|
|
|
#endif
|
2008-04-16 20:44:06 +04:00
|
|
|
if (i->as32L()) {
|
2007-12-17 22:52:01 +03:00
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::MOVSD32_XdYd);
|
2008-04-16 20:44:06 +04:00
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RSI); // always clear upper part of RSI/RDI
|
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RDI);
|
|
|
|
}
|
|
|
|
else {
|
2007-12-17 22:52:01 +03:00
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::MOVSD16_XdYd);
|
2008-04-16 20:44:06 +04:00
|
|
|
}
|
2007-01-05 16:40:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#if BX_SUPPORT_X86_64
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::REP_MOVSQ_XqYq(bxInstruction_c *i)
|
2007-01-05 16:40:47 +03:00
|
|
|
{
|
2008-04-16 20:44:06 +04:00
|
|
|
if (i->as64L()) {
|
2007-12-17 22:52:01 +03:00
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::MOVSQ64_XqYq);
|
2008-04-16 20:44:06 +04:00
|
|
|
}
|
|
|
|
else {
|
2007-12-17 22:52:01 +03:00
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::MOVSQ32_XqYq);
|
2008-04-16 20:44:06 +04:00
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RSI); // always clear upper part of RSI/RDI
|
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RDI);
|
|
|
|
}
|
2007-01-05 16:40:47 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//
|
|
|
|
// MOVSB/MOVSW/MOVSD/MOVSQ methods
|
|
|
|
//
|
2005-07-04 21:44:08 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
// 16 bit address size
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVSB16_XbYb(bxInstruction_c *i)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2008-06-25 14:34:21 +04:00
|
|
|
Bit8u temp8 = read_virtual_byte_32(i->seg(), SI);
|
|
|
|
write_virtual_byte_32(BX_SEG_REG_ES, DI, temp8);
|
2007-12-17 22:52:01 +03:00
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
/* decrement SI, DI */
|
2008-06-25 14:34:21 +04:00
|
|
|
SI--;
|
|
|
|
DI--;
|
2007-12-17 22:52:01 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* increment SI, DI */
|
2008-06-25 14:34:21 +04:00
|
|
|
SI++;
|
|
|
|
DI++;
|
2007-12-17 22:52:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 32 bit address size
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVSB32_XbYb(bxInstruction_c *i)
|
2007-12-17 22:52:01 +03:00
|
|
|
{
|
|
|
|
Bit8u temp8;
|
|
|
|
|
|
|
|
Bit32u incr = 1;
|
|
|
|
|
2007-10-29 18:39:18 +03:00
|
|
|
#if (BX_SupportRepeatSpeedups) && (BX_DEBUGGER == 0)
|
2007-12-17 22:52:01 +03:00
|
|
|
/* If conditions are right, we can transfer IO to physical memory
|
|
|
|
* in a batch, rather than one instruction at a time */
|
|
|
|
if (i->repUsedL() && !BX_CPU_THIS_PTR async_event)
|
|
|
|
{
|
|
|
|
Bit32u byteCount = FastRepMOVSB(i, i->seg(), ESI, BX_SEG_REG_ES, EDI, ECX);
|
|
|
|
if (byteCount) {
|
|
|
|
// Decrement the ticks count by the number of iterations, minus
|
|
|
|
// one, since the main cpu loop will decrement one. Also,
|
|
|
|
// the count is predecremented before examined, so defintely
|
|
|
|
// don't roll it under zero.
|
|
|
|
BX_TICKN(byteCount-1);
|
|
|
|
|
|
|
|
// Decrement eCX. Note, the main loop will decrement 1 also, so
|
|
|
|
// decrement by one less than expected, like the case above.
|
|
|
|
RCX = ECX - (byteCount-1);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
incr = byteCount;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
else {
|
2007-12-20 23:58:38 +03:00
|
|
|
temp8 = read_virtual_byte(i->seg(), ESI);
|
2007-12-20 21:29:42 +03:00
|
|
|
write_virtual_byte(BX_SEG_REG_ES, EDI, temp8);
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
|
|
|
}
|
2007-12-17 22:52:01 +03:00
|
|
|
else
|
2007-10-11 02:20:32 +04:00
|
|
|
#endif
|
2007-12-17 22:52:01 +03:00
|
|
|
{
|
2007-12-20 23:58:38 +03:00
|
|
|
temp8 = read_virtual_byte(i->seg(), ESI);
|
2007-12-20 21:29:42 +03:00
|
|
|
write_virtual_byte(BX_SEG_REG_ES, EDI, temp8);
|
2007-12-17 22:52:01 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
RSI = ESI - incr;
|
|
|
|
RDI = EDI - incr;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
RSI = ESI + incr;
|
|
|
|
RDI = EDI + incr;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
// 64 bit address size
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVSB64_XbYb(bxInstruction_c *i)
|
2007-12-17 22:52:01 +03:00
|
|
|
{
|
|
|
|
Bit8u temp8;
|
|
|
|
|
|
|
|
Bit64u rsi = RSI;
|
|
|
|
Bit64u rdi = RDI;
|
|
|
|
|
2008-05-10 22:10:53 +04:00
|
|
|
temp8 = read_virtual_byte_64(i->seg(), rsi);
|
|
|
|
write_virtual_byte_64(BX_SEG_REG_ES, rdi, temp8);
|
2007-12-17 22:52:01 +03:00
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
/* decrement RSI, RDI */
|
|
|
|
rsi--;
|
|
|
|
rdi--;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* increment RSI, RDI */
|
|
|
|
rsi++;
|
|
|
|
rdi++;
|
|
|
|
}
|
|
|
|
|
|
|
|
RSI = rsi;
|
|
|
|
RDI = rdi;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* 16 bit opsize mode, 16 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVSW16_XwYw(bxInstruction_c *i)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2007-12-17 22:52:01 +03:00
|
|
|
Bit16u si = SI;
|
|
|
|
Bit16u di = DI;
|
|
|
|
|
2008-06-25 14:34:21 +04:00
|
|
|
Bit16u temp16 = read_virtual_word_32(i->seg(), si);
|
|
|
|
write_virtual_word_32(BX_SEG_REG_ES, di, temp16);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
/* decrement SI, DI */
|
2008-06-25 14:34:21 +04:00
|
|
|
si -= 2;
|
|
|
|
di -= 2;
|
2007-12-17 22:52:01 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* increment SI, DI */
|
2008-06-25 14:34:21 +04:00
|
|
|
si += 2;
|
|
|
|
di += 2;
|
2007-12-17 22:52:01 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
SI = si;
|
|
|
|
DI = di;
|
|
|
|
}
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
/* 16 bit opsize mode, 32 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVSW32_XwYw(bxInstruction_c *i)
|
2007-12-17 22:52:01 +03:00
|
|
|
{
|
|
|
|
Bit16u temp16;
|
|
|
|
|
|
|
|
Bit32u esi = ESI;
|
|
|
|
Bit32u edi = EDI;
|
|
|
|
|
2007-12-20 23:58:38 +03:00
|
|
|
temp16 = read_virtual_word(i->seg(), esi);
|
2007-12-20 21:29:42 +03:00
|
|
|
write_virtual_word(BX_SEG_REG_ES, edi, temp16);
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
esi -= 2;
|
|
|
|
edi -= 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
esi += 2;
|
|
|
|
edi += 2;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
// zero extension of RSI/RDI
|
|
|
|
RSI = esi;
|
|
|
|
RDI = edi;
|
|
|
|
}
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
/* 16 bit opsize mode, 64 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVSW64_XwYw(bxInstruction_c *i)
|
2007-12-17 22:52:01 +03:00
|
|
|
{
|
|
|
|
Bit16u temp16;
|
|
|
|
|
|
|
|
Bit64u rsi = RSI;
|
|
|
|
Bit64u rdi = RDI;
|
|
|
|
|
2008-05-10 22:10:53 +04:00
|
|
|
temp16 = read_virtual_word_64(i->seg(), rsi);
|
|
|
|
write_virtual_word_64(BX_SEG_REG_ES, rdi, temp16);
|
2007-12-17 22:52:01 +03:00
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
rsi -= 2;
|
|
|
|
rdi -= 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rsi += 2;
|
|
|
|
rdi += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
RSI = rsi;
|
|
|
|
RDI = rdi;
|
|
|
|
}
|
2007-10-11 02:20:32 +04:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
/* 32 bit opsize mode, 16 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVSD16_XdYd(bxInstruction_c *i)
|
2007-12-17 22:52:01 +03:00
|
|
|
{
|
|
|
|
Bit32u temp32;
|
|
|
|
|
|
|
|
Bit16u si = SI;
|
|
|
|
Bit16u di = DI;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2008-06-12 23:14:40 +04:00
|
|
|
temp32 = read_virtual_dword_32(i->seg(), si);
|
|
|
|
write_virtual_dword_32(BX_SEG_REG_ES, di, temp32);
|
2007-12-17 22:52:01 +03:00
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
si -= 4;
|
|
|
|
di -= 4;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
si += 4;
|
|
|
|
di += 4;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2007-12-17 22:52:01 +03:00
|
|
|
|
|
|
|
SI = si;
|
|
|
|
DI = di;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
/* 32 bit opsize mode, 32 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVSD32_XdYd(bxInstruction_c *i)
|
2004-11-21 02:26:32 +03:00
|
|
|
{
|
|
|
|
Bit32u temp32;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
Bit32u incr = 4;
|
|
|
|
|
|
|
|
Bit32u esi = ESI;
|
|
|
|
Bit32u edi = EDI;
|
|
|
|
|
|
|
|
#if (BX_SupportRepeatSpeedups) && (BX_DEBUGGER == 0)
|
|
|
|
/* If conditions are right, we can transfer IO to physical memory
|
|
|
|
* in a batch, rather than one instruction at a time.
|
|
|
|
*/
|
|
|
|
if (i->repUsedL() && !BX_CPU_THIS_PTR async_event)
|
|
|
|
{
|
|
|
|
Bit32u dwordCount = FastRepMOVSD(i, i->seg(), esi, BX_SEG_REG_ES, edi, ECX);
|
|
|
|
if (dwordCount) {
|
|
|
|
// Decrement the ticks count by the number of iterations, minus
|
|
|
|
// one, since the main cpu loop will decrement one. Also,
|
|
|
|
// the count is predecremented before examined, so defintely
|
|
|
|
// don't roll it under zero.
|
|
|
|
BX_TICKN(dwordCount-1);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
// Decrement eCX. Note, the main loop will decrement 1 also, so
|
|
|
|
// decrement by one less than expected, like the case above.
|
|
|
|
RCX = ECX - (dwordCount-1);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
incr = dwordCount << 2; // count * 4
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
|
|
|
else {
|
2007-12-20 23:58:38 +03:00
|
|
|
temp32 = read_virtual_dword(i->seg(), esi);
|
2007-12-20 21:29:42 +03:00
|
|
|
write_virtual_dword(BX_SEG_REG_ES, edi, temp32);
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2007-12-17 22:52:01 +03:00
|
|
|
#endif
|
2004-11-21 02:26:32 +03:00
|
|
|
{
|
2007-12-20 23:58:38 +03:00
|
|
|
temp32 = read_virtual_dword(i->seg(), esi);
|
2007-12-20 21:29:42 +03:00
|
|
|
write_virtual_dword(BX_SEG_REG_ES, edi, temp32);
|
2007-12-17 22:52:01 +03:00
|
|
|
}
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
esi -= incr;
|
|
|
|
edi -= incr;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
esi += incr;
|
|
|
|
edi += incr;
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
// zero extension of RSI/RDI
|
|
|
|
RSI = esi;
|
|
|
|
RDI = edi;
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
/* 32 bit opsize mode, 64 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVSD64_XdYd(bxInstruction_c *i)
|
2007-12-17 22:52:01 +03:00
|
|
|
{
|
|
|
|
Bit32u temp32;
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
Bit64u rsi = RSI;
|
|
|
|
Bit64u rdi = RDI;
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2008-05-10 22:10:53 +04:00
|
|
|
temp32 = read_virtual_dword_64(i->seg(), rsi);
|
|
|
|
write_virtual_dword_64(BX_SEG_REG_ES, rdi, temp32);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
rsi -= 4;
|
|
|
|
rdi -= 4;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rsi += 4;
|
|
|
|
rdi += 4;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
RSI = rsi;
|
|
|
|
RDI = rdi;
|
|
|
|
}
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
/* 64 bit opsize mode, 32 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVSQ32_XqYq(bxInstruction_c *i)
|
2004-11-21 02:26:32 +03:00
|
|
|
{
|
|
|
|
Bit64u temp64;
|
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
Bit32u esi = ESI;
|
|
|
|
Bit32u edi = EDI;
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2008-05-10 22:10:53 +04:00
|
|
|
temp64 = read_virtual_qword_64(i->seg(), esi);
|
|
|
|
write_virtual_qword_64(BX_SEG_REG_ES, edi, temp64);
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
esi -= 8;
|
|
|
|
edi -= 8;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2007-12-17 22:52:01 +03:00
|
|
|
else {
|
|
|
|
esi += 8;
|
|
|
|
edi += 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
// zero extension of RSI/RDI
|
|
|
|
RSI = esi;
|
|
|
|
RDI = edi;
|
|
|
|
}
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
/* 64 bit opsize mode, 64 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVSQ64_XqYq(bxInstruction_c *i)
|
2007-12-17 22:52:01 +03:00
|
|
|
{
|
|
|
|
Bit64u temp64;
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
Bit64u rsi = RSI;
|
|
|
|
Bit64u rdi = RDI;
|
|
|
|
|
2008-05-10 22:10:53 +04:00
|
|
|
temp64 = read_virtual_qword_64(i->seg(), rsi);
|
|
|
|
write_virtual_qword_64(BX_SEG_REG_ES, rdi, temp64);
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
rsi -= 8;
|
|
|
|
rdi -= 8;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rsi += 8;
|
|
|
|
rdi += 8;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2007-12-17 22:52:01 +03:00
|
|
|
|
|
|
|
RSI = rsi;
|
|
|
|
RDI = rdi;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2004-11-21 02:26:32 +03:00
|
|
|
#endif
|
|
|
|
|
2007-01-05 16:40:47 +03:00
|
|
|
//
|
|
|
|
// REP CMPS methods
|
|
|
|
//
|
|
|
|
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::REP_CMPSB_XbYb(bxInstruction_c *i)
|
2007-01-05 16:40:47 +03:00
|
|
|
{
|
2007-12-17 21:48:26 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2008-10-09 00:15:37 +04:00
|
|
|
if (i->as64L()) {
|
2008-10-09 00:40:26 +04:00
|
|
|
BX_CPU_THIS_PTR repeat_ZF(i, &BX_CPU_C::CMPSB64_XbYb);
|
2008-10-09 00:15:37 +04:00
|
|
|
}
|
2007-12-17 21:48:26 +03:00
|
|
|
else
|
|
|
|
#endif
|
2008-04-16 20:44:06 +04:00
|
|
|
if (i->as32L()) {
|
2008-10-09 00:40:26 +04:00
|
|
|
BX_CPU_THIS_PTR repeat_ZF(i, &BX_CPU_C::CMPSB32_XbYb);
|
2008-04-16 20:44:06 +04:00
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RSI); // always clear upper part of RSI/RDI
|
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RDI);
|
|
|
|
}
|
|
|
|
else {
|
2008-10-09 00:40:26 +04:00
|
|
|
BX_CPU_THIS_PTR repeat_ZF(i, &BX_CPU_C::CMPSB16_XbYb);
|
2008-04-16 20:44:06 +04:00
|
|
|
}
|
2007-01-05 16:40:47 +03:00
|
|
|
}
|
|
|
|
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::REP_CMPSW_XwYw(bxInstruction_c *i)
|
2007-01-05 16:40:47 +03:00
|
|
|
{
|
2007-12-17 21:48:26 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2008-10-09 00:15:37 +04:00
|
|
|
if (i->as64L()) {
|
2008-10-09 00:40:26 +04:00
|
|
|
BX_CPU_THIS_PTR repeat_ZF(i, &BX_CPU_C::CMPSW64_XwYw);
|
2008-10-09 00:15:37 +04:00
|
|
|
}
|
2007-12-17 21:48:26 +03:00
|
|
|
else
|
|
|
|
#endif
|
2008-04-16 20:44:06 +04:00
|
|
|
if (i->as32L()) {
|
2008-10-09 00:40:26 +04:00
|
|
|
BX_CPU_THIS_PTR repeat_ZF(i, &BX_CPU_C::CMPSW32_XwYw);
|
2008-04-16 20:44:06 +04:00
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RSI); // always clear upper part of RSI/RDI
|
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RDI);
|
|
|
|
}
|
|
|
|
else {
|
2008-10-09 00:40:26 +04:00
|
|
|
BX_CPU_THIS_PTR repeat_ZF(i, &BX_CPU_C::CMPSW16_XwYw);
|
2008-04-16 20:44:06 +04:00
|
|
|
}
|
2007-01-05 16:40:47 +03:00
|
|
|
}
|
|
|
|
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::REP_CMPSD_XdYd(bxInstruction_c *i)
|
2007-01-05 16:40:47 +03:00
|
|
|
{
|
2007-12-17 21:48:26 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2008-10-09 00:15:37 +04:00
|
|
|
if (i->as64L()) {
|
2008-10-09 00:40:26 +04:00
|
|
|
BX_CPU_THIS_PTR repeat_ZF(i, &BX_CPU_C::CMPSD64_XdYd);
|
2008-10-09 00:15:37 +04:00
|
|
|
}
|
2007-12-17 21:48:26 +03:00
|
|
|
else
|
|
|
|
#endif
|
2008-04-16 20:44:06 +04:00
|
|
|
if (i->as32L()) {
|
2008-10-09 00:40:26 +04:00
|
|
|
BX_CPU_THIS_PTR repeat_ZF(i, &BX_CPU_C::CMPSD32_XdYd);
|
2008-04-16 20:44:06 +04:00
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RSI); // always clear upper part of RSI/RDI
|
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RDI);
|
|
|
|
}
|
|
|
|
else {
|
2008-10-09 00:40:26 +04:00
|
|
|
BX_CPU_THIS_PTR repeat_ZF(i, &BX_CPU_C::CMPSD16_XdYd);
|
2008-04-16 20:44:06 +04:00
|
|
|
}
|
2007-01-05 16:40:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#if BX_SUPPORT_X86_64
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::REP_CMPSQ_XqYq(bxInstruction_c *i)
|
2007-01-05 16:40:47 +03:00
|
|
|
{
|
2008-04-16 20:44:06 +04:00
|
|
|
if (i->as64L()) {
|
2008-10-09 00:40:26 +04:00
|
|
|
BX_CPU_THIS_PTR repeat_ZF(i, &BX_CPU_C::CMPSQ64_XqYq);
|
2008-04-16 20:44:06 +04:00
|
|
|
}
|
|
|
|
else {
|
2008-10-09 00:40:26 +04:00
|
|
|
BX_CPU_THIS_PTR repeat_ZF(i, &BX_CPU_C::CMPSQ32_XqYq);
|
2008-04-16 20:44:06 +04:00
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RSI); // always clear upper part of RSI/RDI
|
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RDI);
|
|
|
|
}
|
2007-01-05 16:40:47 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//
|
|
|
|
// CMPSB/CMPSW/CMPSD/CMPSQ methods
|
|
|
|
//
|
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
/* 16 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::CMPSB16_XbYb(bxInstruction_c *i)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
Bit8u op1_8, op2_8, diff_8;
|
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit16u si = SI;
|
|
|
|
Bit16u di = DI;
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2008-06-12 23:14:40 +04:00
|
|
|
op1_8 = read_virtual_byte_32(i->seg(), si);
|
|
|
|
op2_8 = read_virtual_byte_32(BX_SEG_REG_ES, di);
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
diff_8 = op1_8 - op2_8;
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
SET_FLAGS_OSZAPC_SUB_8(op1_8, op2_8, diff_8);
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
si--;
|
|
|
|
di--;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
si++;
|
|
|
|
di++;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
DI = di;
|
|
|
|
SI = si;
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
/* 32 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::CMPSB32_XbYb(bxInstruction_c *i)
|
2007-12-17 21:48:26 +03:00
|
|
|
{
|
|
|
|
Bit8u op1_8, op2_8, diff_8;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit32u esi = ESI;
|
|
|
|
Bit32u edi = EDI;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-20 23:58:38 +03:00
|
|
|
op1_8 = read_virtual_byte(i->seg(), esi);
|
|
|
|
op2_8 = read_virtual_byte(BX_SEG_REG_ES, edi);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
diff_8 = op1_8 - op2_8;
|
|
|
|
|
|
|
|
SET_FLAGS_OSZAPC_SUB_8(op1_8, op2_8, diff_8);
|
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
esi--;
|
|
|
|
edi--;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
esi++;
|
|
|
|
edi++;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
// zero extension of RSI/RDI
|
|
|
|
RDI = edi;
|
|
|
|
RSI = esi;
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
/* 64 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::CMPSB64_XbYb(bxInstruction_c *i)
|
2007-12-17 21:48:26 +03:00
|
|
|
{
|
|
|
|
Bit8u op1_8, op2_8, diff_8;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit64u rsi = RSI;
|
|
|
|
Bit64u rdi = RDI;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2008-05-10 22:10:53 +04:00
|
|
|
op1_8 = read_virtual_byte_64(i->seg(), rsi);
|
|
|
|
op2_8 = read_virtual_byte_64(BX_SEG_REG_ES, rdi);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
diff_8 = op1_8 - op2_8;
|
|
|
|
|
|
|
|
SET_FLAGS_OSZAPC_SUB_8(op1_8, op2_8, diff_8);
|
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
rsi--;
|
|
|
|
rdi--;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2007-12-17 21:48:26 +03:00
|
|
|
else {
|
|
|
|
rsi++;
|
|
|
|
rdi++;
|
|
|
|
}
|
|
|
|
|
|
|
|
RDI = rdi;
|
|
|
|
RSI = rsi;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2007-12-17 21:48:26 +03:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
/* 16 bit opsize mode, 16 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::CMPSW16_XwYw(bxInstruction_c *i)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2004-11-21 02:26:32 +03:00
|
|
|
Bit16u op1_16, op2_16, diff_16;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit16u si = SI;
|
|
|
|
Bit16u di = DI;
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2008-06-12 23:14:40 +04:00
|
|
|
op1_16 = read_virtual_word_32(i->seg(), si);
|
|
|
|
op2_16 = read_virtual_word_32(BX_SEG_REG_ES, di);
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
diff_16 = op1_16 - op2_16;
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
SET_FLAGS_OSZAPC_SUB_16(op1_16, op2_16, diff_16);
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
si -= 2;
|
|
|
|
di -= 2;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2007-12-17 21:48:26 +03:00
|
|
|
else {
|
|
|
|
si += 2;
|
|
|
|
di += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
DI = di;
|
|
|
|
SI = si;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 16 bit opsize mode, 32 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::CMPSW32_XwYw(bxInstruction_c *i)
|
2007-12-17 21:48:26 +03:00
|
|
|
{
|
|
|
|
Bit16u op1_16, op2_16, diff_16;
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit32u esi = ESI;
|
|
|
|
Bit32u edi = EDI;
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-20 23:58:38 +03:00
|
|
|
op1_16 = read_virtual_word(i->seg(), esi);
|
|
|
|
op2_16 = read_virtual_word(BX_SEG_REG_ES, edi);
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
diff_16 = op1_16 - op2_16;
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
SET_FLAGS_OSZAPC_SUB_16(op1_16, op2_16, diff_16);
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
esi -= 2;
|
|
|
|
edi -= 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
esi += 2;
|
|
|
|
edi += 2;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
// zero extension of RSI/RDI
|
|
|
|
RDI = edi;
|
|
|
|
RSI = esi;
|
|
|
|
}
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
/* 16 bit opsize mode, 64 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::CMPSW64_XwYw(bxInstruction_c *i)
|
2007-12-17 21:48:26 +03:00
|
|
|
{
|
|
|
|
Bit16u op1_16, op2_16, diff_16;
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit64u rsi = RSI;
|
|
|
|
Bit64u rdi = RDI;
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2008-05-10 22:10:53 +04:00
|
|
|
op1_16 = read_virtual_word_64(i->seg(), rsi);
|
|
|
|
op2_16 = read_virtual_word_64(BX_SEG_REG_ES, rdi);
|
2007-12-17 21:48:26 +03:00
|
|
|
|
|
|
|
diff_16 = op1_16 - op2_16;
|
|
|
|
|
|
|
|
SET_FLAGS_OSZAPC_SUB_16(op1_16, op2_16, diff_16);
|
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
rsi -= 2;
|
|
|
|
rdi -= 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rsi += 2;
|
|
|
|
rdi += 2;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2007-12-17 21:48:26 +03:00
|
|
|
|
|
|
|
RDI = rdi;
|
|
|
|
RSI = rsi;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2007-12-17 21:48:26 +03:00
|
|
|
#endif
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
/* 32 bit opsize mode, 16 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::CMPSD16_XdYd(bxInstruction_c *i)
|
2004-11-21 02:26:32 +03:00
|
|
|
{
|
|
|
|
Bit32u op1_32, op2_32, diff_32;
|
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit16u si = SI;
|
|
|
|
Bit16u di = DI;
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2008-06-12 23:14:40 +04:00
|
|
|
op1_32 = read_virtual_dword_32(i->seg(), si);
|
|
|
|
op2_32 = read_virtual_dword_32(BX_SEG_REG_ES, di);
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
diff_32 = op1_32 - op2_32;
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
SET_FLAGS_OSZAPC_SUB_32(op1_32, op2_32, diff_32);
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
si -= 4;
|
|
|
|
di -= 4;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
si += 4;
|
|
|
|
di += 4;
|
|
|
|
}
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
DI = di;
|
|
|
|
SI = si;
|
|
|
|
}
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
/* 32 bit opsize mode, 32 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::CMPSD32_XdYd(bxInstruction_c *i)
|
2007-12-17 21:48:26 +03:00
|
|
|
{
|
|
|
|
Bit32u op1_32, op2_32, diff_32;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit32u esi = ESI;
|
|
|
|
Bit32u edi = EDI;
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-20 23:58:38 +03:00
|
|
|
op1_32 = read_virtual_dword(i->seg(), esi);
|
|
|
|
op2_32 = read_virtual_dword(BX_SEG_REG_ES, edi);
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
diff_32 = op1_32 - op2_32;
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
SET_FLAGS_OSZAPC_SUB_32(op1_32, op2_32, diff_32);
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
esi -= 4;
|
|
|
|
edi -= 4;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
esi += 4;
|
|
|
|
edi += 4;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
// zero extension of RSI/RDI
|
|
|
|
RDI = edi;
|
|
|
|
RSI = esi;
|
|
|
|
}
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
/* 32 bit opsize mode, 64 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::CMPSD64_XdYd(bxInstruction_c *i)
|
2007-12-17 21:48:26 +03:00
|
|
|
{
|
|
|
|
Bit32u op1_32, op2_32, diff_32;
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit64u rsi = RSI;
|
|
|
|
Bit64u rdi = RDI;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2008-05-10 22:10:53 +04:00
|
|
|
op1_32 = read_virtual_dword_64(i->seg(), rsi);
|
|
|
|
op2_32 = read_virtual_dword_64(BX_SEG_REG_ES, rdi);
|
2007-12-17 21:48:26 +03:00
|
|
|
|
|
|
|
diff_32 = op1_32 - op2_32;
|
|
|
|
|
|
|
|
SET_FLAGS_OSZAPC_SUB_32(op1_32, op2_32, diff_32);
|
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
rsi -= 4;
|
|
|
|
rdi -= 4;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rsi += 4;
|
|
|
|
rdi += 4;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
RDI = rdi;
|
|
|
|
RSI = rsi;
|
|
|
|
}
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
/* 64 bit opsize mode, 32 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::CMPSQ32_XqYq(bxInstruction_c *i)
|
2004-11-21 02:26:32 +03:00
|
|
|
{
|
|
|
|
Bit64u op1_64, op2_64, diff_64;
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit32u esi = ESI;
|
|
|
|
Bit32u edi = EDI;
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2008-05-10 22:10:53 +04:00
|
|
|
op1_64 = read_virtual_qword_64(i->seg(), esi);
|
|
|
|
op2_64 = read_virtual_qword_64(BX_SEG_REG_ES, edi);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
diff_64 = op1_64 - op2_64;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
SET_FLAGS_OSZAPC_SUB_64(op1_64, op2_64, diff_64);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
esi -= 8;
|
|
|
|
edi -= 8;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
esi += 8;
|
|
|
|
edi += 8;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
// zero extension of RSI/RDI
|
|
|
|
RDI = edi;
|
|
|
|
RSI = esi;
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
/* 64 bit opsize mode, 64 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::CMPSQ64_XqYq(bxInstruction_c *i)
|
2007-12-17 21:48:26 +03:00
|
|
|
{
|
|
|
|
Bit64u op1_64, op2_64, diff_64;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit64u rsi = RSI;
|
|
|
|
Bit64u rdi = RDI;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2008-05-10 22:10:53 +04:00
|
|
|
op1_64 = read_virtual_qword_64(i->seg(), rsi);
|
|
|
|
op2_64 = read_virtual_qword_64(BX_SEG_REG_ES, rdi);
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
diff_64 = op1_64 - op2_64;
|
|
|
|
|
|
|
|
SET_FLAGS_OSZAPC_SUB_64(op1_64, op2_64, diff_64);
|
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
rsi -= 8;
|
|
|
|
rdi -= 8;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2007-12-17 21:48:26 +03:00
|
|
|
else {
|
|
|
|
rsi += 8;
|
|
|
|
rdi += 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
RDI = rdi;
|
|
|
|
RSI = rsi;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2007-01-05 16:40:47 +03:00
|
|
|
//
|
|
|
|
// REP SCAS methods
|
|
|
|
//
|
|
|
|
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::REP_SCASB_ALXb(bxInstruction_c *i)
|
2007-01-05 16:40:47 +03:00
|
|
|
{
|
2007-12-17 21:48:26 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2008-10-09 00:15:37 +04:00
|
|
|
if (i->as64L()) {
|
2008-10-09 00:40:26 +04:00
|
|
|
BX_CPU_THIS_PTR repeat_ZF(i, &BX_CPU_C::SCASB64_ALXb);
|
2008-10-09 00:15:37 +04:00
|
|
|
}
|
2007-12-17 21:48:26 +03:00
|
|
|
else
|
|
|
|
#endif
|
2008-04-16 20:44:06 +04:00
|
|
|
if (i->as32L()) {
|
2008-10-09 00:40:26 +04:00
|
|
|
BX_CPU_THIS_PTR repeat_ZF(i, &BX_CPU_C::SCASB32_ALXb);
|
2008-04-16 20:44:06 +04:00
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RDI); // always clear upper part of RDI
|
|
|
|
}
|
|
|
|
else {
|
2008-10-09 00:40:26 +04:00
|
|
|
BX_CPU_THIS_PTR repeat_ZF(i, &BX_CPU_C::SCASB16_ALXb);
|
2008-04-16 20:44:06 +04:00
|
|
|
}
|
2007-01-05 16:40:47 +03:00
|
|
|
}
|
|
|
|
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::REP_SCASW_AXXw(bxInstruction_c *i)
|
2007-01-05 16:40:47 +03:00
|
|
|
{
|
2007-12-17 21:48:26 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2008-10-09 00:15:37 +04:00
|
|
|
if (i->as64L()) {
|
2008-10-09 00:40:26 +04:00
|
|
|
BX_CPU_THIS_PTR repeat_ZF(i, &BX_CPU_C::SCASW64_AXXw);
|
2008-10-09 00:15:37 +04:00
|
|
|
}
|
2007-12-17 21:48:26 +03:00
|
|
|
else
|
|
|
|
#endif
|
2008-04-16 20:44:06 +04:00
|
|
|
if (i->as32L()) {
|
2008-10-09 00:40:26 +04:00
|
|
|
BX_CPU_THIS_PTR repeat_ZF(i, &BX_CPU_C::SCASW32_AXXw);
|
2008-04-16 20:44:06 +04:00
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RDI); // always clear upper part of RDI
|
|
|
|
}
|
|
|
|
else {
|
2008-10-09 00:40:26 +04:00
|
|
|
BX_CPU_THIS_PTR repeat_ZF(i, &BX_CPU_C::SCASW16_AXXw);
|
2008-04-16 20:44:06 +04:00
|
|
|
}
|
2007-01-05 16:40:47 +03:00
|
|
|
}
|
|
|
|
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::REP_SCASD_EAXXd(bxInstruction_c *i)
|
2007-01-05 16:40:47 +03:00
|
|
|
{
|
2007-12-17 21:48:26 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2008-10-09 00:15:37 +04:00
|
|
|
if (i->as64L()) {
|
2008-10-09 00:40:26 +04:00
|
|
|
BX_CPU_THIS_PTR repeat_ZF(i, &BX_CPU_C::SCASD64_EAXXd);
|
2008-10-09 00:15:37 +04:00
|
|
|
}
|
2007-12-17 21:48:26 +03:00
|
|
|
else
|
|
|
|
#endif
|
2008-04-16 20:44:06 +04:00
|
|
|
if (i->as32L()) {
|
2008-10-09 00:40:26 +04:00
|
|
|
BX_CPU_THIS_PTR repeat_ZF(i, &BX_CPU_C::SCASD32_EAXXd);
|
2008-04-16 20:44:06 +04:00
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RDI); // always clear upper part of RDI
|
|
|
|
}
|
|
|
|
else {
|
2008-10-09 00:40:26 +04:00
|
|
|
BX_CPU_THIS_PTR repeat_ZF(i, &BX_CPU_C::SCASD16_EAXXd);
|
2008-04-16 20:44:06 +04:00
|
|
|
}
|
2007-01-05 16:40:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#if BX_SUPPORT_X86_64
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::REP_SCASQ_RAXXq(bxInstruction_c *i)
|
2007-01-05 16:40:47 +03:00
|
|
|
{
|
2008-04-16 20:44:06 +04:00
|
|
|
if (i->as64L()) {
|
2008-10-09 00:40:26 +04:00
|
|
|
BX_CPU_THIS_PTR repeat_ZF(i, &BX_CPU_C::SCASQ64_RAXXq);
|
2008-04-16 20:44:06 +04:00
|
|
|
}
|
|
|
|
else {
|
2008-10-09 00:40:26 +04:00
|
|
|
BX_CPU_THIS_PTR repeat_ZF(i, &BX_CPU_C::SCASQ32_RAXXq);
|
2008-04-16 20:44:06 +04:00
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RDI); // always clear upper part of RDI
|
|
|
|
}
|
2007-01-05 16:40:47 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//
|
|
|
|
// SCASB/SCASW/SCASD/SCASQ methods
|
|
|
|
//
|
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
/* 16 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::SCASB16_ALXb(bxInstruction_c *i)
|
2004-11-21 02:26:32 +03:00
|
|
|
{
|
2006-05-25 00:57:37 +04:00
|
|
|
Bit8u op1_8 = AL, op2_8, diff_8;
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit16u di = DI;
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2008-06-12 23:14:40 +04:00
|
|
|
op2_8 = read_virtual_byte_32(BX_SEG_REG_ES, di);
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
diff_8 = op1_8 - op2_8;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
SET_FLAGS_OSZAPC_SUB_8(op1_8, op2_8, diff_8);
|
2008-02-03 00:46:54 +03:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
di--;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
di++;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
DI = di;
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
/* 32 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::SCASB32_ALXb(bxInstruction_c *i)
|
2007-12-17 21:48:26 +03:00
|
|
|
{
|
|
|
|
Bit8u op1_8 = AL, op2_8, diff_8;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit32u edi = EDI;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-20 23:58:38 +03:00
|
|
|
op2_8 = read_virtual_byte(BX_SEG_REG_ES, edi);
|
2007-12-17 21:48:26 +03:00
|
|
|
diff_8 = op1_8 - op2_8;
|
|
|
|
|
|
|
|
SET_FLAGS_OSZAPC_SUB_8(op1_8, op2_8, diff_8);
|
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
edi--;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
edi++;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
// zero extension of RDI
|
|
|
|
RDI = edi;
|
|
|
|
}
|
2002-10-08 02:51:58 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
/* 64 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::SCASB64_ALXb(bxInstruction_c *i)
|
2007-12-17 21:48:26 +03:00
|
|
|
{
|
|
|
|
Bit8u op1_8 = AL, op2_8, diff_8;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit64u rdi = RDI;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2008-05-10 22:10:53 +04:00
|
|
|
op2_8 = read_virtual_byte_64(BX_SEG_REG_ES, rdi);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
diff_8 = op1_8 - op2_8;
|
|
|
|
|
|
|
|
SET_FLAGS_OSZAPC_SUB_8(op1_8, op2_8, diff_8);
|
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
rdi--;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2007-12-17 21:48:26 +03:00
|
|
|
else {
|
|
|
|
rdi++;
|
|
|
|
}
|
|
|
|
|
|
|
|
RDI = rdi;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2007-12-17 21:48:26 +03:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
/* 16 bit opsize mode, 16 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::SCASW16_AXXw(bxInstruction_c *i)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2006-05-25 00:57:37 +04:00
|
|
|
Bit16u op1_16 = AX, op2_16, diff_16;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit16u di = DI;
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2008-06-12 23:14:40 +04:00
|
|
|
op2_16 = read_virtual_word_32(BX_SEG_REG_ES, di);
|
2007-12-17 21:48:26 +03:00
|
|
|
diff_16 = op1_16 - op2_16;
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
SET_FLAGS_OSZAPC_SUB_16(op1_16, op2_16, diff_16);
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
di -= 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
di += 2;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
DI = di;
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
/* 16 bit opsize mode, 32 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::SCASW32_AXXw(bxInstruction_c *i)
|
2007-12-17 21:48:26 +03:00
|
|
|
{
|
|
|
|
Bit16u op1_16 = AX, op2_16, diff_16;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit32u edi = EDI;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-20 23:58:38 +03:00
|
|
|
op2_16 = read_virtual_word(BX_SEG_REG_ES, edi);
|
2007-12-17 21:48:26 +03:00
|
|
|
diff_16 = op1_16 - op2_16;
|
|
|
|
|
|
|
|
SET_FLAGS_OSZAPC_SUB_16(op1_16, op2_16, diff_16);
|
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
edi -= 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
edi += 2;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
// zero extension of RDI
|
|
|
|
RDI = edi;
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
/* 16 bit opsize mode, 64 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::SCASW64_AXXw(bxInstruction_c *i)
|
2007-12-17 21:48:26 +03:00
|
|
|
{
|
|
|
|
Bit16u op1_16 = AX, op2_16, diff_16;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit64u rdi = RDI;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2008-05-10 22:10:53 +04:00
|
|
|
op2_16 = read_virtual_word_64(BX_SEG_REG_ES, rdi);
|
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
diff_16 = op1_16 - op2_16;
|
|
|
|
|
|
|
|
SET_FLAGS_OSZAPC_SUB_16(op1_16, op2_16, diff_16);
|
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
rdi -= 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rdi += 2;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2007-12-17 21:48:26 +03:00
|
|
|
|
|
|
|
RDI = rdi;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2007-12-17 21:48:26 +03:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
/* 32 bit opsize mode, 16 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::SCASD16_EAXXd(bxInstruction_c *i)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2006-05-25 00:57:37 +04:00
|
|
|
Bit32u op1_32 = EAX, op2_32, diff_32;
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit16u di = DI;
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2008-06-12 23:14:40 +04:00
|
|
|
op2_32 = read_virtual_dword_32(BX_SEG_REG_ES, di);
|
2007-12-17 21:48:26 +03:00
|
|
|
diff_32 = op1_32 - op2_32;
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
SET_FLAGS_OSZAPC_SUB_32(op1_32, op2_32, diff_32);
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
di -= 4;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
di += 4;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
DI = di;
|
|
|
|
}
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
/* 32 bit opsize mode, 32 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::SCASD32_EAXXd(bxInstruction_c *i)
|
2007-12-17 21:48:26 +03:00
|
|
|
{
|
|
|
|
Bit32u op1_32 = EAX, op2_32, diff_32;
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit32u edi = EDI;
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-20 23:58:38 +03:00
|
|
|
op2_32 = read_virtual_dword(BX_SEG_REG_ES, edi);
|
2007-12-17 21:48:26 +03:00
|
|
|
diff_32 = op1_32 - op2_32;
|
|
|
|
|
|
|
|
SET_FLAGS_OSZAPC_SUB_32(op1_32, op2_32, diff_32);
|
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
edi -= 4;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
edi += 4;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
// zero extension of RDI
|
|
|
|
RDI = edi;
|
|
|
|
}
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
/* 32 bit opsize mode, 64 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::SCASD64_EAXXd(bxInstruction_c *i)
|
2007-12-17 21:48:26 +03:00
|
|
|
{
|
|
|
|
Bit32u op1_32 = EAX, op2_32, diff_32;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit64u rdi = RDI;
|
|
|
|
|
2008-05-10 22:10:53 +04:00
|
|
|
op2_32 = read_virtual_dword_64(BX_SEG_REG_ES, rdi);
|
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
diff_32 = op1_32 - op2_32;
|
|
|
|
|
|
|
|
SET_FLAGS_OSZAPC_SUB_32(op1_32, op2_32, diff_32);
|
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
rdi -= 4;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rdi += 4;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
RDI = rdi;
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
/* 64 bit opsize mode, 32 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::SCASQ32_RAXXq(bxInstruction_c *i)
|
2004-11-21 02:26:32 +03:00
|
|
|
{
|
2006-05-25 00:57:37 +04:00
|
|
|
Bit64u op1_64 = RAX, op2_64, diff_64;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit32u edi = EDI;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2008-05-10 22:10:53 +04:00
|
|
|
op2_64 = read_virtual_qword_64(BX_SEG_REG_ES, edi);
|
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
diff_64 = op1_64 - op2_64;
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
SET_FLAGS_OSZAPC_SUB_64(op1_64, op2_64, diff_64);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
edi -= 8;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
edi += 8;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
// zero extension of RDI
|
|
|
|
RDI = edi;
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
/* 64 bit opsize mode, 64 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::SCASQ64_RAXXq(bxInstruction_c *i)
|
2007-12-17 21:48:26 +03:00
|
|
|
{
|
|
|
|
Bit64u op1_64 = RAX, op2_64, diff_64;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit64u rdi = RDI;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2008-05-10 22:10:53 +04:00
|
|
|
op2_64 = read_virtual_qword_64(BX_SEG_REG_ES, rdi);
|
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
diff_64 = op1_64 - op2_64;
|
|
|
|
|
|
|
|
SET_FLAGS_OSZAPC_SUB_64(op1_64, op2_64, diff_64);
|
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
rdi -= 8;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rdi += 8;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2007-12-17 21:48:26 +03:00
|
|
|
|
|
|
|
RDI = rdi;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2002-10-03 22:12:40 +04:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-01-05 16:40:47 +03:00
|
|
|
//
|
|
|
|
// REP STOS methods
|
|
|
|
//
|
|
|
|
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::REP_STOSB_YbAL(bxInstruction_c *i)
|
2007-01-05 16:40:47 +03:00
|
|
|
{
|
2007-12-17 22:52:01 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
if (i->as64L())
|
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::STOSB64_YbAL);
|
|
|
|
else
|
|
|
|
#endif
|
2008-04-16 20:44:06 +04:00
|
|
|
if (i->as32L()) {
|
2007-12-17 22:52:01 +03:00
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::STOSB32_YbAL);
|
2008-04-16 20:44:06 +04:00
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RDI); // always clear upper part of RDI
|
|
|
|
}
|
|
|
|
else {
|
2007-12-17 22:52:01 +03:00
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::STOSB16_YbAL);
|
2008-04-16 20:44:06 +04:00
|
|
|
}
|
2007-01-05 16:40:47 +03:00
|
|
|
}
|
|
|
|
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::REP_STOSW_YwAX(bxInstruction_c *i)
|
2007-01-05 16:40:47 +03:00
|
|
|
{
|
2007-12-17 22:52:01 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
if (i->as64L())
|
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::STOSW64_YwAX);
|
|
|
|
else
|
|
|
|
#endif
|
2008-04-16 20:44:06 +04:00
|
|
|
if (i->as32L()) {
|
2007-12-17 22:52:01 +03:00
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::STOSW32_YwAX);
|
2008-04-16 20:44:06 +04:00
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RDI); // always clear upper part of RDI
|
|
|
|
}
|
|
|
|
else {
|
2007-12-17 22:52:01 +03:00
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::STOSW16_YwAX);
|
2008-04-16 20:44:06 +04:00
|
|
|
}
|
2007-01-05 16:40:47 +03:00
|
|
|
}
|
|
|
|
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::REP_STOSD_YdEAX(bxInstruction_c *i)
|
2007-01-05 16:40:47 +03:00
|
|
|
{
|
2007-12-17 22:52:01 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
if (i->as64L())
|
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::STOSD64_YdEAX);
|
|
|
|
else
|
|
|
|
#endif
|
2008-04-16 20:44:06 +04:00
|
|
|
if (i->as32L()) {
|
2007-12-17 22:52:01 +03:00
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::STOSD32_YdEAX);
|
2008-04-16 20:44:06 +04:00
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RDI); // always clear upper part of RDI
|
|
|
|
}
|
|
|
|
else {
|
2007-12-17 22:52:01 +03:00
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::STOSD16_YdEAX);
|
2008-04-16 20:44:06 +04:00
|
|
|
}
|
2007-01-05 16:40:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#if BX_SUPPORT_X86_64
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::REP_STOSQ_YqRAX(bxInstruction_c *i)
|
2007-01-05 16:40:47 +03:00
|
|
|
{
|
2008-04-16 20:44:06 +04:00
|
|
|
if (i->as64L()) {
|
2007-12-17 22:52:01 +03:00
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::STOSQ64_YqRAX);
|
2008-04-16 20:44:06 +04:00
|
|
|
}
|
|
|
|
else {
|
2007-12-17 22:52:01 +03:00
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::STOSQ32_YqRAX);
|
2008-04-16 20:44:06 +04:00
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RDI); // always clear upper part of RDI
|
|
|
|
}
|
2007-01-05 16:40:47 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//
|
|
|
|
// STOSB/STOSW/STOSD/STOSQ methods
|
|
|
|
//
|
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
// 16 bit address size
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::STOSB16_YbAL(bxInstruction_c *i)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2007-12-17 22:52:01 +03:00
|
|
|
Bit16u di = DI;
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2008-06-12 23:14:40 +04:00
|
|
|
write_virtual_byte_32(BX_SEG_REG_ES, di, AL);
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
di--;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
di++;
|
|
|
|
}
|
|
|
|
|
|
|
|
DI = di;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 32 bit address size
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::STOSB32_YbAL(bxInstruction_c *i)
|
2007-12-17 22:52:01 +03:00
|
|
|
{
|
|
|
|
Bit32u incr = 1;
|
|
|
|
Bit32u edi = EDI;
|
|
|
|
|
|
|
|
#if (BX_SupportRepeatSpeedups) && (BX_DEBUGGER == 0)
|
|
|
|
/* If conditions are right, we can transfer IO to physical memory
|
|
|
|
* in a batch, rather than one instruction at a time.
|
|
|
|
*/
|
|
|
|
if (i->repUsedL() && !BX_CPU_THIS_PTR async_event)
|
|
|
|
{
|
2007-12-23 21:09:34 +03:00
|
|
|
Bit32u byteCount = FastRepSTOSB(i, BX_SEG_REG_ES, edi, AL, ECX);
|
2007-12-17 22:52:01 +03:00
|
|
|
if (byteCount) {
|
|
|
|
// Decrement the ticks count by the number of iterations, minus
|
|
|
|
// one, since the main cpu loop will decrement one. Also,
|
|
|
|
// the count is predecremented before examined, so defintely
|
|
|
|
// don't roll it under zero.
|
|
|
|
BX_TICKN(byteCount-1);
|
|
|
|
|
|
|
|
// Decrement eCX. Note, the main loop will decrement 1 also, so
|
|
|
|
// decrement by one less than expected, like the case above.
|
|
|
|
RCX = ECX - (byteCount-1);
|
|
|
|
|
|
|
|
incr = byteCount;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2002-09-15 09:09:18 +04:00
|
|
|
else {
|
2007-12-23 21:09:34 +03:00
|
|
|
write_virtual_byte(BX_SEG_REG_ES, edi, AL);
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
|
|
|
}
|
2002-09-15 09:09:18 +04:00
|
|
|
else
|
2007-12-17 22:52:01 +03:00
|
|
|
#endif
|
2002-09-15 09:09:18 +04:00
|
|
|
{
|
2007-12-23 21:09:34 +03:00
|
|
|
write_virtual_byte(BX_SEG_REG_ES, edi, AL);
|
2007-12-17 22:52:01 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
edi -= incr;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
edi += incr;
|
|
|
|
}
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
// zero extension of RDI
|
|
|
|
RDI = edi;
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
// 64 bit address size
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::STOSB64_YbAL(bxInstruction_c *i)
|
2007-12-17 22:52:01 +03:00
|
|
|
{
|
|
|
|
Bit64u rdi = RDI;
|
|
|
|
|
2008-05-10 22:10:53 +04:00
|
|
|
write_virtual_byte_64(BX_SEG_REG_ES, rdi, AL);
|
2007-12-17 22:52:01 +03:00
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
rdi--;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rdi++;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2007-12-17 22:52:01 +03:00
|
|
|
|
|
|
|
RDI = rdi;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2007-12-17 22:52:01 +03:00
|
|
|
#endif
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
/* 16 bit opsize mode, 16 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::STOSW16_YwAX(bxInstruction_c *i)
|
2004-11-21 02:26:32 +03:00
|
|
|
{
|
2007-12-17 22:52:01 +03:00
|
|
|
Bit16u di = DI;
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2008-06-12 23:14:40 +04:00
|
|
|
write_virtual_word_32(BX_SEG_REG_ES, di, AX);
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
di -= 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
di += 2;
|
|
|
|
}
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
DI = di;
|
|
|
|
}
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
/* 16 bit opsize mode, 32 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::STOSW32_YwAX(bxInstruction_c *i)
|
2007-12-17 22:52:01 +03:00
|
|
|
{
|
|
|
|
Bit32u edi = EDI;
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-23 21:09:34 +03:00
|
|
|
write_virtual_word(BX_SEG_REG_ES, edi, AX);
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
edi -= 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
edi += 2;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
// zero extension of RDI
|
|
|
|
RDI = edi;
|
|
|
|
}
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
/* 16 bit opsize mode, 32 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::STOSW64_YwAX(bxInstruction_c *i)
|
2007-12-17 22:52:01 +03:00
|
|
|
{
|
|
|
|
Bit64u rdi = RDI;
|
|
|
|
|
2008-05-10 22:10:53 +04:00
|
|
|
write_virtual_word_64(BX_SEG_REG_ES, rdi, AX);
|
2007-12-17 22:52:01 +03:00
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
rdi -= 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rdi += 2;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2007-12-17 22:52:01 +03:00
|
|
|
|
|
|
|
RDI = rdi;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2007-12-17 22:52:01 +03:00
|
|
|
#endif
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
/* 32 bit opsize mode, 16 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::STOSD16_YdEAX(bxInstruction_c *i)
|
2004-11-21 02:26:32 +03:00
|
|
|
{
|
2007-12-17 22:52:01 +03:00
|
|
|
Bit16u di = DI;
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2008-06-12 23:14:40 +04:00
|
|
|
write_virtual_dword_32(BX_SEG_REG_ES, di, EAX);
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
di -= 4;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
di += 4;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
DI = di;
|
|
|
|
}
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
/* 32 bit opsize mode, 32 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::STOSD32_YdEAX(bxInstruction_c *i)
|
2007-12-17 22:52:01 +03:00
|
|
|
{
|
|
|
|
Bit32u edi = EDI;
|
|
|
|
|
2007-12-23 21:09:34 +03:00
|
|
|
write_virtual_dword(BX_SEG_REG_ES, edi, EAX);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
edi -= 4;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
edi += 4;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
// zero extension of RDI
|
|
|
|
RDI = edi;
|
|
|
|
}
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
|
|
|
|
/* 32 bit opsize mode, 32 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::STOSD64_YdEAX(bxInstruction_c *i)
|
2007-12-17 22:52:01 +03:00
|
|
|
{
|
|
|
|
Bit64u rdi = RDI;
|
|
|
|
|
2008-05-10 22:10:53 +04:00
|
|
|
write_virtual_dword_64(BX_SEG_REG_ES, rdi, EAX);
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
rdi -= 4;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rdi += 4;
|
2002-09-15 09:09:18 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
RDI = rdi;
|
|
|
|
}
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
/* 64 bit opsize mode, 32 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::STOSQ32_YqRAX(bxInstruction_c *i)
|
2004-11-21 02:26:32 +03:00
|
|
|
{
|
2007-12-17 22:52:01 +03:00
|
|
|
Bit32u edi = EDI;
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2008-05-10 22:10:53 +04:00
|
|
|
write_virtual_qword_64(BX_SEG_REG_ES, edi, RAX);
|
2005-02-22 21:24:19 +03:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
edi -= 8;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
edi += 8;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
// zero extension of RDI
|
|
|
|
RDI = edi;
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
/* 64 bit opsize mode, 64 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::STOSQ64_YqRAX(bxInstruction_c *i)
|
2007-12-17 22:52:01 +03:00
|
|
|
{
|
|
|
|
Bit64u rdi = RDI;
|
|
|
|
|
2008-05-10 22:10:53 +04:00
|
|
|
write_virtual_qword_64(BX_SEG_REG_ES, rdi, RAX);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 22:52:01 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
rdi -= 8;
|
2004-08-15 00:44:48 +04:00
|
|
|
}
|
2007-12-17 22:52:01 +03:00
|
|
|
else {
|
|
|
|
rdi += 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
RDI = rdi;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2004-11-21 02:26:32 +03:00
|
|
|
#endif
|
|
|
|
|
2007-01-05 16:40:47 +03:00
|
|
|
//
|
|
|
|
// REP LODS methods
|
|
|
|
//
|
|
|
|
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::REP_LODSB_ALXb(bxInstruction_c *i)
|
2007-01-05 16:40:47 +03:00
|
|
|
{
|
2007-12-17 21:48:26 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
if (i->as64L())
|
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::LODSB64_ALXb);
|
|
|
|
else
|
|
|
|
#endif
|
2008-04-16 20:44:06 +04:00
|
|
|
if (i->as32L()) {
|
2007-12-17 21:48:26 +03:00
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::LODSB32_ALXb);
|
2008-04-16 20:44:06 +04:00
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RSI); // always clear upper part of RSI
|
|
|
|
}
|
|
|
|
else {
|
2007-12-17 21:48:26 +03:00
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::LODSB16_ALXb);
|
2008-04-16 20:44:06 +04:00
|
|
|
}
|
2007-01-05 16:40:47 +03:00
|
|
|
}
|
|
|
|
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::REP_LODSW_AXXw(bxInstruction_c *i)
|
2007-01-05 16:40:47 +03:00
|
|
|
{
|
2007-12-17 21:48:26 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
if (i->as64L())
|
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::LODSW64_AXXw);
|
|
|
|
else
|
|
|
|
#endif
|
2008-04-16 20:44:06 +04:00
|
|
|
if (i->as32L()) {
|
2007-12-17 21:48:26 +03:00
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::LODSW32_AXXw);
|
2008-04-16 20:44:06 +04:00
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RSI); // always clear upper part of RSI
|
|
|
|
}
|
|
|
|
else {
|
2007-12-17 21:48:26 +03:00
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::LODSW16_AXXw);
|
2008-04-16 20:44:06 +04:00
|
|
|
}
|
2007-01-05 16:40:47 +03:00
|
|
|
}
|
|
|
|
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::REP_LODSD_EAXXd(bxInstruction_c *i)
|
2007-01-05 16:40:47 +03:00
|
|
|
{
|
2007-12-17 21:48:26 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
if (i->as64L())
|
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::LODSD64_EAXXd);
|
|
|
|
else
|
|
|
|
#endif
|
2008-04-16 20:44:06 +04:00
|
|
|
if (i->as32L()) {
|
2007-12-17 21:48:26 +03:00
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::LODSD32_EAXXd);
|
2008-04-16 20:44:06 +04:00
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RSI); // always clear upper part of RSI
|
|
|
|
}
|
|
|
|
else {
|
2007-12-17 21:48:26 +03:00
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::LODSD16_EAXXd);
|
2008-04-16 20:44:06 +04:00
|
|
|
}
|
2007-01-05 16:40:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#if BX_SUPPORT_X86_64
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::REP_LODSQ_RAXXq(bxInstruction_c *i)
|
2007-01-05 16:40:47 +03:00
|
|
|
{
|
2008-04-16 20:44:06 +04:00
|
|
|
if (i->as64L()) {
|
2007-12-17 21:48:26 +03:00
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::LODSQ64_RAXXq);
|
2008-04-16 20:44:06 +04:00
|
|
|
}
|
|
|
|
else {
|
2007-12-17 21:48:26 +03:00
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::LODSQ32_RAXXq);
|
2008-04-16 20:44:06 +04:00
|
|
|
BX_CLEAR_64BIT_HIGH(BX_64BIT_REG_RSI); // always clear upper part of RSI
|
|
|
|
}
|
2007-01-05 16:40:47 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//
|
|
|
|
// LODSB/LODSW/LODSD/LODSQ methods
|
|
|
|
//
|
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
/* 16 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::LODSB16_ALXb(bxInstruction_c *i)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit16u si = SI;
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2008-06-12 23:14:40 +04:00
|
|
|
AL = read_virtual_byte_32(i->seg(), si);
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
si--;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
si++;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
SI = si;
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
/* 32 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::LODSB32_ALXb(bxInstruction_c *i)
|
2007-12-17 21:48:26 +03:00
|
|
|
{
|
|
|
|
Bit32u esi = ESI;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-20 23:58:38 +03:00
|
|
|
AL = read_virtual_byte(i->seg(), esi);
|
2007-12-17 21:48:26 +03:00
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
esi--;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
esi++;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
// zero extension of RSI
|
|
|
|
RSI = esi;
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
/* 64 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::LODSB64_ALXb(bxInstruction_c *i)
|
2007-12-17 21:48:26 +03:00
|
|
|
{
|
|
|
|
Bit64u rsi = RSI;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2008-05-10 22:10:53 +04:00
|
|
|
AL = read_virtual_byte_64(i->seg(), rsi);
|
2007-12-17 21:48:26 +03:00
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
rsi--;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rsi++;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2007-12-17 21:48:26 +03:00
|
|
|
|
|
|
|
RSI = rsi;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2007-12-17 21:48:26 +03:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
/* 16 bit opsize mode, 16 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::LODSW16_AXXw(bxInstruction_c *i)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit16u si = SI;
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2008-06-12 23:14:40 +04:00
|
|
|
AX = read_virtual_word_32(i->seg(), si);
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
si -= 2;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2007-12-17 21:48:26 +03:00
|
|
|
else {
|
|
|
|
si += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
SI = si;
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
/* 16 bit opsize mode, 32 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::LODSW32_AXXw(bxInstruction_c *i)
|
2007-12-17 21:48:26 +03:00
|
|
|
{
|
|
|
|
Bit32u esi = ESI;
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-20 23:58:38 +03:00
|
|
|
AX = read_virtual_word(i->seg(), esi);
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
esi -= 2;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2007-12-17 21:48:26 +03:00
|
|
|
else {
|
|
|
|
esi += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
// zero extension of RSI
|
|
|
|
RSI = esi;
|
|
|
|
}
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
/* 16 bit opsize mode, 64 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::LODSW64_AXXw(bxInstruction_c *i)
|
2007-12-17 21:48:26 +03:00
|
|
|
{
|
|
|
|
Bit64u rsi = RSI;
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2008-05-10 22:10:53 +04:00
|
|
|
AX = read_virtual_word_64(i->seg(), rsi);
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
rsi -= 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rsi += 2;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2007-12-17 21:48:26 +03:00
|
|
|
|
|
|
|
RSI = rsi;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2007-12-17 21:48:26 +03:00
|
|
|
#endif
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
/* 32 bit opsize mode, 16 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::LODSD16_EAXXd(bxInstruction_c *i)
|
2004-11-21 02:26:32 +03:00
|
|
|
{
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit16u si = SI;
|
2002-09-15 09:09:18 +04:00
|
|
|
|
2008-06-12 23:14:40 +04:00
|
|
|
RAX = read_virtual_dword_32(i->seg(), si);
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
si -= 4;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
si += 4;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
SI = si;
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
/* 32 bit opsize mode, 32 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::LODSD32_EAXXd(bxInstruction_c *i)
|
2007-12-17 21:48:26 +03:00
|
|
|
{
|
|
|
|
Bit32u esi = ESI;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-20 23:58:38 +03:00
|
|
|
RAX = read_virtual_dword(i->seg(), esi);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
esi -= 4;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2007-12-17 21:48:26 +03:00
|
|
|
else {
|
|
|
|
esi += 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
// zero extension of RSI
|
|
|
|
RSI = esi;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2004-11-21 02:26:32 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
/* 32 bit opsize mode, 64 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::LODSD64_EAXXd(bxInstruction_c *i)
|
2004-11-21 02:26:32 +03:00
|
|
|
{
|
2007-12-17 21:48:26 +03:00
|
|
|
Bit64u rsi = RSI;
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2008-05-10 22:10:53 +04:00
|
|
|
RAX = read_virtual_dword_64(i->seg(), rsi);
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
rsi -= 4;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rsi += 4;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
RSI = rsi;
|
|
|
|
}
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2007-12-17 21:48:26 +03:00
|
|
|
/* 64 bit opsize mode, 32 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::LODSQ32_RAXXq(bxInstruction_c *i)
|
2007-12-17 21:48:26 +03:00
|
|
|
{
|
|
|
|
Bit32u esi = ESI;
|
2004-11-21 02:26:32 +03:00
|
|
|
|
2008-05-10 22:10:53 +04:00
|
|
|
RAX = read_virtual_qword_64(i->seg(), esi);
|
2007-12-17 21:48:26 +03:00
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
esi -= 8;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
esi += 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
// zero extension of RSI
|
|
|
|
RSI = esi;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 64 bit opsize mode, 64 bit address size */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::LODSQ64_RAXXq(bxInstruction_c *i)
|
2007-12-17 21:48:26 +03:00
|
|
|
{
|
|
|
|
Bit64u rsi = RSI;
|
|
|
|
|
2008-05-10 22:10:53 +04:00
|
|
|
RAX = read_virtual_qword_64(i->seg(), rsi);
|
2007-12-17 21:48:26 +03:00
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
rsi -= 8;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rsi += 8;
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2007-12-17 21:48:26 +03:00
|
|
|
|
|
|
|
RSI = rsi;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2004-11-21 02:26:32 +03:00
|
|
|
|
|
|
|
#endif
|