⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lazycodeblockmemory.java

📁 JPC: x86 PC Hardware Emulator. 牛津大学开发的一个纯JAVA的x86系统结构硬件模拟器。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    }    private void removeVirtual8086CodeBlockAt(int offset)    {        Virtual8086ModeCodeBlock b = virtual8086CodeBuffer[offset];        if ((b == null) || (b == PLACEHOLDER))            return;        virtual8086CodeBuffer[offset] = null;        int len = b.getX86Length();        for (int i=offset+1; (i<offset + len) && (i < virtual8086CodeBuffer.length); i++)        {            if (virtual8086CodeBuffer[i] == PLACEHOLDER)                virtual8086CodeBuffer[i] = null;        }           for (int i=Math.min(offset + len, virtual8086CodeBuffer.length)-1; i>=0; i--)        {            if (virtual8086CodeBuffer[i] == null)            {                if (i < offset)                    break;                else                    continue;            }            if (virtual8086CodeBuffer[i] == PLACEHOLDER)                continue;            Virtual8086ModeCodeBlock bb = virtual8086CodeBuffer[i];            len = bb.getX86Length();            for (int j=i+1; (j<i+len) && (j<virtual8086CodeBuffer.length); j++)            {                if (virtual8086CodeBuffer[j] == null)                    virtual8086CodeBuffer[j] = PLACEHOLDER;            }        }    }    private void removeProtectedCodeBlockAt(int offset)    {        ProtectedModeCodeBlock b = protectedCodeBuffer[offset];        if ((b == null) || (b == PLACEHOLDER))            return;        protectedCodeBuffer[offset] = null;        int len = b.getX86Length();        for (int i=offset+1; (i<offset + len) && (i < protectedCodeBuffer.length); i++)        {            if (protectedCodeBuffer[i] == PLACEHOLDER)                protectedCodeBuffer[i] = null;        }           for (int i=Math.min(offset + len, protectedCodeBuffer.length)-1; i>=0; i--)        {            if (protectedCodeBuffer[i] == null)            {                if (i < offset)                    break;                else                    continue;            }            if (protectedCodeBuffer[i] == PLACEHOLDER)                continue;            ProtectedModeCodeBlock bb = protectedCodeBuffer[i];            len = bb.getX86Length();            for (int j=i+1; (j<i+len) && (j<protectedCodeBuffer.length); j++)            {                if (protectedCodeBuffer[j] == null)                    protectedCodeBuffer[j] = PLACEHOLDER;            }        }    }    private void removeRealCodeBlockAt(int offset)    {        RealModeCodeBlock b = realCodeBuffer[offset];        if ((b == null) || (b == PLACEHOLDER))            return;        realCodeBuffer[offset] = null;        int len = b.getX86Length();        for (int i=offset+1; (i<offset + len) && (i < realCodeBuffer.length); i++)        {            if (realCodeBuffer[i] == PLACEHOLDER)                realCodeBuffer[i] = null;        }           for (int i=Math.min(offset + len, realCodeBuffer.length)-1; i>=0; i--)        {            if (realCodeBuffer[i] == null)            {                if (i < offset)                    break;                else                    continue;            }            if (realCodeBuffer[i] == PLACEHOLDER)                continue;            RealModeCodeBlock bb = realCodeBuffer[i];            len = bb.getX86Length();            for (int j=i+1; (j<i+len) && (j<realCodeBuffer.length); j++)            {                if (realCodeBuffer[j] == null)                    realCodeBuffer[j] = PLACEHOLDER;            }        }    }    public void setVirtual8086CodeBlockAt(int offset, Virtual8086ModeCodeBlock block)    {        removeVirtual8086CodeBlockAt(offset);        if (block == null)            return;        virtual8086CodeBuffer[offset] = block;        int len = block.getX86Length();        for (int i=offset+1; (i<offset+len) && (i<virtual8086CodeBuffer.length); i++)        {            if (virtual8086CodeBuffer[i] == null)                virtual8086CodeBuffer[i] = PLACEHOLDER;        }    }    public void setProtectedCodeBlockAt(int offset, ProtectedModeCodeBlock block)    {        removeProtectedCodeBlockAt(offset);        if (block == null)            return;        protectedCodeBuffer[offset] = block;        int len = block.getX86Length();        for (int i=offset+1; (i<offset+len) && (i<protectedCodeBuffer.length); i++)        {            if (protectedCodeBuffer[i] == null)                protectedCodeBuffer[i] = PLACEHOLDER;        }    }    public void setRealCodeBlockAt(int offset, RealModeCodeBlock block)    {        removeRealCodeBlockAt(offset);        if (block == null)            return;        realCodeBuffer[offset] = block;        int len = block.getX86Length();        for (int i=offset+1; (i<offset+len) && (i<realCodeBuffer.length); i++)        {            if (realCodeBuffer[i] == null)                realCodeBuffer[i] = PLACEHOLDER;        }    }    protected void regionAltered(int start, int end)    {        for (int i=end; i>=0; i--)        {            RealModeCodeBlock b = realCodeBuffer[i];            if (b == null)             {                if (i < start)                    break;                else                    continue;            }            if (b == PLACEHOLDER)                continue;                        if (!b.handleMemoryRegionChange(start, end))                removeRealCodeBlockAt(i);        }         for (int i=end; i>=0; i--)        {            ProtectedModeCodeBlock b = protectedCodeBuffer[i];            if (b == null)             {                if (i < start)                    break;                else                    continue;            }            if (b == PLACEHOLDER)                continue;                        if (!b.handleMemoryRegionChange(start, end))                removeProtectedCodeBlockAt(i);        }         for (int i=end; i>=0; i--)        {            Virtual8086ModeCodeBlock b = virtual8086CodeBuffer[i];            if (b == null)             {                if (i < start)                    break;                else                    continue;            }            if (b == PLACEHOLDER)                continue;                        if (!b.handleMemoryRegionChange(start, end))                removeVirtual8086CodeBlockAt(i);        }     }    public void copyContentsFrom(int address, byte[] buf, int off, int len)    {        super.copyContentsFrom(address, buf, off, len);        regionAltered(address, address + len - 1);    }    public void setByte(int offset, byte data)    {        if (super.getByte(offset) == data)            return;        super.setByte(offset, data);        regionAltered(offset, offset);    }    public void setWord(int offset, short data)    {        if (super.getWord(offset) == data)            return;        super.setWord(offset, data);        regionAltered(offset, offset + 1);    }    public void setDoubleWord(int offset, int data)    {        if (super.getDoubleWord(offset) == data)            return;        super.setDoubleWord(offset, data);        regionAltered(offset, offset + 3);    }    public void clear()    {	constructCodeBlocksArray();	super.clear();    }    public String toString()    {        return "LazyCodeBlockMemory["+getSize()+"]";    }            public static void dispose()    {        if (codeBlockManager != null)            codeBlockManager.dispose();        codeBlockManager = null;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -