Changeset 1656

Show
Ignore:
Timestamp:
07/21/08 00:36:15 (1 month ago)
Author:
common
Message:

libemu

  • porting to big endian broke cmp for lil endian, as endian.h was not included, and the big endian code did not honor argumentsizes for cmp reg{16,32} , imm8
    fixed
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • libemu/trunk/src/functions/cmp.c

    r1639 r1656  
    2626 *******************************************************************************/ 
    2727 
     28#include <endian.h> 
    2829#include <stdint.h> 
    2930 
     
    3435bcopy(&(a), &operand_a, bits/8); \ 
    3536bcopy(&(b), &operand_b, bits/8); \ 
    36 UINT(bits) operation_result = operand_a operation operand_b;    
     37UINT(bits) operation_result = operand_a operation operand_b; 
    3738#else // ENDIAN 
    3839#define INSTR_CALC(bits, a, b, operation)                       \ 
     
    4748 
    4849#include "emu/emu_memory.h" 
    49  
    5050 
    5151#ifdef INSTR_CALC_AND_SET_FLAGS 
     
    355355                                                                         *i->imm16,  
    356356                                                                         -) 
    357  
    358                         MEM_WORD_WRITE(c, i->modrm.ea, dst); 
    359  
    360357                } 
    361358                else 
     
    373370                                                                         i->imm,  
    374371                                                                         -) 
    375  
    376                         MEM_DWORD_WRITE(c, i->modrm.ea, dst); 
    377  
    378372                } 
    379373        } 
     
    414408int32_t instr_group_1_83_cmp(struct emu_cpu *c, struct emu_cpu_instruction *i) 
    415409{ 
     410 
     411/* As the INSTR_CALC for big endian uses bcopy of the operands size, we have to create an operand of the size  
     412 * and use it, the replacement aligned equal size operand is called imm  
     413 */ 
     414#if BYTE_ORDER == BIG_ENDIAN 
     415         uint8_t imm8; 
     416         bcopy(i->imm8, &imm8, 1); 
     417         uint32_t imm = imm8; 
     418#endif 
     419 
    416420        if ( i->modrm.mod != 3 ) 
    417421        { 
     
    426430                         uint16_t dst; 
    427431                         MEM_WORD_READ(c, i->modrm.ea, &dst); 
    428  
    429432                         INSTR_CALC_AND_SET_FLAGS(16,  
    430433                                                                          c,  
    431434                                                                          dst, 
     435#if BYTE_ORDER == BIG_ENDIAN 
     436                                                                          imm, 
     437#else 
    432438                                                                          *i->imm8,  
     439#endif 
    433440                                                                          -) 
    434  
    435                          MEM_WORD_WRITE(c, i->modrm.ea, dst); 
    436  
    437441                } 
    438442                else 
     
    451455                                                                         c,  
    452456                                                                         dst, 
    453                                                                          *i->imm8,  
    454                                                                          -) 
    455                         MEM_DWORD_WRITE(c, i->modrm.ea, dst); 
     457#if BYTE_ORDER == BIG_ENDIAN 
     458                                                                          imm, 
     459#else 
     460                                                                          *i->imm8,  
     461#endif 
     462 
     463                                                                         -) 
    456464                } 
    457465        } 
     
    468476                                                                         c,  
    469477                                                                         *c->reg16[i->modrm.rm],  
    470                                                                          *i->imm8,  
     478#if BYTE_ORDER == BIG_ENDIAN 
     479                                                                          imm, 
     480#else 
     481                                                                          *i->imm8,  
     482#endif 
     483 
    471484                                                                         -) 
    472485                } 
     
    481494                                                                         c,  
    482495                                                                         c->reg[i->modrm.rm],  
    483                                                                          *i->imm8,  
    484                                                                          -) 
    485                 } 
    486         } 
    487         return 0; 
    488 
     496#if BYTE_ORDER == BIG_ENDIAN 
     497                                                                          imm, 
     498#else 
     499                                                                          *i->imm8,  
     500#endif 
     501 
     502                                                                         -) 
     503                } 
     504        } 
     505        return 0; 
     506