OSDN Git Service

[VM][I386][OOPS] Fix OOPS.
[csp-qt/common_source_project-fm7.git] / source / src / vm / libcpu_newdev / libcpu_i386 / i386_opdef.h
index e64b8ae..a5fcbda 100644 (file)
@@ -18,7 +18,8 @@
 
 #define U64(v) UINT64(v)
 
-#define fatalerror(...) exit(1)
+//#define fatalerror(...) exit(1)
+#define fatalerror(...)
 #define logerror(...)
 #define popmessage(...)
 
@@ -553,6 +554,7 @@ public:
        void i386_vtlb_free(void);
        void i386_free_state(void);
 
+       i386_state *get_cpu_state(void) { return cpustate; }
        int get_extra_clock() { return cpustate->extra_cycles; }
        void set_extra_clock(int n) { cpustate->extra_cycles += n; }
 
@@ -608,8 +610,9 @@ public:
        }
        
        virtual bool write_debug_reg(const _TCHAR *reg, uint32_t data) { return false; }
-       virtual void get_debug_regs_info(_TCHAR *buffer, size_t buffer_len) {};
+
        virtual int debug_dasm(uint32_t pc, _TCHAR *buffer, size_t buffer_len) { return 0;}
+       void vtlb_flush_dynamic(void) { vtlb_flush_dynamic(cpustate->vtlb); }
 
        void save_state(FILEIO *state_fio);
        bool load_state(FILEIO *state_fio);
@@ -1757,6 +1760,7 @@ protected:
        INLINE void PUSH16(UINT16 value);
        INLINE UINT16 POP16();
        INLINE void PUSH32(UINT32 value);
+       INLINE void PUSH32SEG(UINT32 value);
        INLINE UINT32 POP32();
        
        INLINE UINT8 OR8(UINT8 dst, UINT8 src);
@@ -1985,7 +1989,7 @@ INLINE UINT16 I386_OPS_BASE::FETCH16()
        UINT16 value;
        UINT32 address = cpustate->pc, error;
 
-       if( address & 0x1 ) {       /* Unaligned read */
+       if( !WORD_ALIGNED(address) ) {       /* Unaligned read */
                value = (FETCH() << 0);
                value |= (FETCH() << 8);
        } else {
@@ -2003,7 +2007,7 @@ INLINE UINT32 I386_OPS_BASE::FETCH32()
        UINT32 value;
        UINT32 address = cpustate->pc, error;
 
-       if( cpustate->pc & 0x3 ) {      /* Unaligned read */
+       if( !DWORD_ALIGNED(cpustate->pc) ) {      /* Unaligned read */
                value = (FETCH() << 0);
                value |= (FETCH() << 8);
                value |= (FETCH() << 16);
@@ -2036,7 +2040,7 @@ INLINE UINT16 I386_OPS_BASE::READ16(UINT32 ea)
        UINT16 value;
        UINT32 address = ea, error;
 
-       if( ea & 0x1 ) {        /* Unaligned read */
+       if( !WORD_ALIGNED(ea) ) {      /* Unaligned read */
                value = (READ8(address+0) << 0);
                value |= (READ8(address+1) << 8);
        } else {
@@ -2053,7 +2057,7 @@ INLINE UINT32 I386_OPS_BASE::READ32(UINT32 ea)
        UINT32 value;
        UINT32 address = ea, error;
 
-       if( ea & 0x3 ) {        /* Unaligned read */
+       if( !DWORD_ALIGNED(ea) ) {      /* Unaligned read */
                value = (READ8(address+0) << 0);
                value |= (READ8(address+1) << 8);
                value |= (READ8(address+2) << 16),
@@ -2073,7 +2077,7 @@ INLINE UINT64 I386_OPS_BASE::READ64(UINT32 ea)
        UINT64 value;
        UINT32 address = ea, error;
 
-       if( ea & 0x7 ) {        /* Unaligned read */
+       if( !QWORD_ALIGNED(ea) ) {      /* Unaligned read */
                value = (((UINT64) READ8( address+0 )) << 0);
                value |= (((UINT64) READ8( address+1 )) << 8);
                value |= (((UINT64) READ8( address+2 )) << 16);
@@ -2109,7 +2113,7 @@ INLINE UINT16 I386_OPS_BASE::READ16PL0(UINT32 ea)
        UINT16 value;
        UINT32 address = ea, error;
 
-       if( ea & 0x1 ) {        /* Unaligned read */
+       if( !WORD_ALIGNED(ea) ) {      /* Unaligned read */
                value = (READ8PL0( address+0 ) << 0);
                value |= (READ8PL0( address+1 ) << 8);
        } else {
@@ -2127,7 +2131,7 @@ INLINE UINT32 I386_OPS_BASE::READ32PL0(UINT32 ea)
        UINT32 value;
        UINT32 address = ea, error;
 
-       if( ea & 0x3 ) {        /* Unaligned read */
+       if( !DWORD_ALIGNED(ea) ) {      /* Unaligned read */
                value = (READ8PL0( address+0 ) << 0);
                value |= (READ8PL0( address+1 ) << 8);
                value |= (READ8PL0( address+2 ) << 16);
@@ -2164,7 +2168,7 @@ INLINE void I386_OPS_BASE::WRITE16(UINT32 ea, UINT16 value)
 {
        UINT32 address = ea, error;
 
-       if( ea & 0x1 ) {        /* Unaligned write */
+       if( !WORD_ALIGNED(ea) ) {      /* Unaligned write */
                WRITE8( address+0, value & 0xff );
                WRITE8( address+1, (value >> 8) & 0xff );
        } else {
@@ -2180,7 +2184,7 @@ INLINE void I386_OPS_BASE::WRITE32(UINT32 ea, UINT32 value)
 {
        UINT32 address = ea, error;
 
-       if( ea & 0x3 ) {        /* Unaligned write */
+       if( !DWORD_ALIGNED(ea) ) {      /* Unaligned write */
                WRITE8( address+0, value & 0xff );
                WRITE8( address+1, (value >> 8) & 0xff );
                WRITE8( address+2, (value >> 16) & 0xff );
@@ -2198,7 +2202,7 @@ INLINE void I386_OPS_BASE::WRITE64(UINT32 ea, UINT64 value)
 {
        UINT32 address = ea, error;
 
-       if( ea & 0x7 ) {        /* Unaligned write */
+       if( !QWORD_ALIGNED(ea) ) {      /* Unaligned write */
                WRITE8( address+0, value & 0xff );
                WRITE8( address+1, (value >> 8) & 0xff );
                WRITE8( address+2, (value >> 16) & 0xff );
@@ -2435,6 +2439,23 @@ INLINE void I386_OPS_BASE::PUSH32(UINT32 value)
                REG16(SP) = new_esp;
        }
 }
+
+INLINE void I386_OPS_BASE::PUSH32SEG(UINT32 value)
+{
+       UINT32 ea, new_esp;
+       if( STACK_32BIT ) {
+               new_esp = REG32(ESP) - 4;
+               ea = i386_translate(SS, new_esp, 1);
+               ((cpustate->cpu_version & 0xf00) == 0x300) ? WRITE16(ea, value) : WRITE32(ea, value ); // 486 also?
+               REG32(ESP) = new_esp;
+       } else {
+               new_esp = (REG16(SP) - 4) & 0xffff;
+               ea = i386_translate(SS, new_esp, 1);
+               ((cpustate->cpu_version & 0xf00) == 0x300) ? WRITE16(ea, value) : WRITE32(ea, value );
+               REG16(SP) = new_esp;
+       }
+}
+
 INLINE void I386_OPS_BASE::PUSH8(UINT8 value)
 {
        if( cpustate->operand_size ) {