--- np2/i386c/ia32/resolve.c 2004/01/23 14:33:26 1.4 +++ np2/i386c/ia32/resolve.c 2011/01/15 17:17:23 1.10 @@ -1,5 +1,3 @@ -/* $Id: resolve.c,v 1.4 2004/01/23 14:33:26 monaka Exp $ */ - /* * Copyright (c) 2002-2003 NONAKA Kimihiro * All rights reserved. @@ -12,8 +10,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES @@ -32,26 +28,14 @@ #include "ia32.mcr" -static DWORD (*calc_ea_dst_tbl[0x100])(void); -static DWORD (*calc_ea32_dst_tbl[0x100])(void); - - -DWORD -calc_ea_dst(DWORD op) -{ - - __ASSERT(op < 0x100); - - if (!CPU_INST_AS32) - return ((*calc_ea_dst_tbl[op])() & 0xffff); - return (*calc_ea32_dst_tbl[op])(); -} +UINT32 (*calc_ea_dst_tbl[0x100])(void); +UINT32 (*calc_ea32_dst_tbl[0x100])(void); /* * common */ -DWORD +static UINT32 ea_nop(void) { @@ -67,7 +51,7 @@ ea_nop(void) /* * ea_dest */ -static DWORD +static UINT32 ea_bx_si(void) { @@ -75,27 +59,27 @@ ea_bx_si(void) return (CPU_BX + CPU_SI); } -static DWORD +static UINT32 ea_bx_si_disp8(void) { - SDWORD adrs; + UINT32 adrs; - GET_PCBYTESD(adrs); + GET_PCBYTES(adrs); CPU_INST_SEGREG_INDEX = DS_FIX; return (adrs + CPU_BX + CPU_SI); } -static DWORD +static UINT32 ea_bx_si_disp16(void) { - DWORD adrs; + UINT32 adrs; GET_PCWORD(adrs); CPU_INST_SEGREG_INDEX = DS_FIX; return (adrs + CPU_BX + CPU_SI); } -static DWORD +static UINT32 ea_bx_di(void) { @@ -103,27 +87,27 @@ ea_bx_di(void) return (CPU_BX + CPU_DI); } -static DWORD +static UINT32 ea_bx_di_disp8(void) { - SDWORD adrs; + UINT32 adrs; - GET_PCBYTESD(adrs); + GET_PCBYTES(adrs); CPU_INST_SEGREG_INDEX = DS_FIX; return (adrs + CPU_BX + CPU_DI); } -static DWORD +static UINT32 ea_bx_di_disp16(void) { - DWORD adrs; + UINT32 adrs; GET_PCWORD(adrs); CPU_INST_SEGREG_INDEX = DS_FIX; return (adrs + CPU_BX + CPU_DI); } -static DWORD +static UINT32 ea_bp_si(void) { @@ -131,27 +115,27 @@ ea_bp_si(void) return (CPU_BP + CPU_SI); } -static DWORD +static UINT32 ea_bp_si_disp8(void) { - SDWORD adrs; + UINT32 adrs; - GET_PCBYTESD(adrs); + GET_PCBYTES(adrs); CPU_INST_SEGREG_INDEX = SS_FIX; return (adrs + CPU_BP + CPU_SI); } -static DWORD +static UINT32 ea_bp_si_disp16(void) { - DWORD adrs; + UINT32 adrs; GET_PCWORD(adrs); CPU_INST_SEGREG_INDEX = SS_FIX; return (adrs + CPU_BP + CPU_SI); } -static DWORD +static UINT32 ea_bp_di(void) { @@ -159,27 +143,27 @@ ea_bp_di(void) return (CPU_BP + CPU_DI); } -static DWORD +static UINT32 ea_bp_di_disp8(void) { - SDWORD adrs; + UINT32 adrs; - GET_PCBYTESD(adrs); + GET_PCBYTES(adrs); CPU_INST_SEGREG_INDEX = SS_FIX; return (adrs + CPU_BP + CPU_DI); } -static DWORD +static UINT32 ea_bp_di_disp16(void) { - DWORD adrs; + UINT32 adrs; GET_PCWORD(adrs); CPU_INST_SEGREG_INDEX = SS_FIX; return (adrs + CPU_BP + CPU_DI); } -static DWORD +static UINT32 ea_si(void) { @@ -187,27 +171,27 @@ ea_si(void) return CPU_SI; } -static DWORD +static UINT32 ea_si_disp8(void) { - SDWORD adrs; + UINT32 adrs; - GET_PCBYTESD(adrs); + GET_PCBYTES(adrs); CPU_INST_SEGREG_INDEX = DS_FIX; return (adrs + CPU_SI); } -static DWORD +static UINT32 ea_si_disp16(void) { - DWORD adrs; + UINT32 adrs; GET_PCWORD(adrs); CPU_INST_SEGREG_INDEX = DS_FIX; return (adrs + CPU_SI); } -static DWORD +static UINT32 ea_di(void) { @@ -215,57 +199,57 @@ ea_di(void) return CPU_DI; } -static DWORD +static UINT32 ea_di_disp8(void) { - SDWORD adrs; + UINT32 adrs; - GET_PCBYTESD(adrs); + GET_PCBYTES(adrs); CPU_INST_SEGREG_INDEX = DS_FIX; return (adrs + CPU_DI); } -static DWORD +static UINT32 ea_di_disp16(void) { - DWORD adrs; + UINT32 adrs; GET_PCWORD(adrs); CPU_INST_SEGREG_INDEX = DS_FIX; return (adrs + CPU_DI); } -static DWORD +static UINT32 ea_disp16(void) { - DWORD adrs; + UINT32 adrs; GET_PCWORD(adrs); CPU_INST_SEGREG_INDEX = DS_FIX; return adrs; } -static DWORD +static UINT32 ea_bp_disp8(void) { - SDWORD adrs; + UINT32 adrs; - GET_PCBYTESD(adrs); + GET_PCBYTES(adrs); CPU_INST_SEGREG_INDEX = SS_FIX; return (adrs + CPU_BP); } -static DWORD +static UINT32 ea_bp_disp16(void) { - DWORD adrs; + UINT32 adrs; GET_PCWORD(adrs); CPU_INST_SEGREG_INDEX = SS_FIX; return (adrs + CPU_BP); } -static DWORD +static UINT32 ea_bx(void) { @@ -273,27 +257,27 @@ ea_bx(void) return CPU_BX; } -static DWORD +static UINT32 ea_bx_disp8(void) { - SDWORD adrs; + UINT32 adrs; - GET_PCBYTESD(adrs); + GET_PCBYTES(adrs); CPU_INST_SEGREG_INDEX = DS_FIX; return (adrs + CPU_BX); } -static DWORD +static UINT32 ea_bx_disp16(void) { - DWORD adrs; + UINT32 adrs; GET_PCWORD(adrs); CPU_INST_SEGREG_INDEX = DS_FIX; return (adrs + CPU_BX); } -static DWORD (*c_ea_dst_tbl[])(void) = { +static UINT32 (*c_ea_dst_tbl[])(void) = { ea_bx_si, ea_bx_di, ea_bp_si, ea_bp_di, ea_si, ea_di, @@ -315,7 +299,7 @@ static DWORD (*c_ea_dst_tbl[])(void) = { /* * ea_dest 32 */ -static DWORD +static UINT32 ea32_eax(void) { @@ -323,7 +307,7 @@ ea32_eax(void) return CPU_EAX; } -static DWORD +static UINT32 ea32_ecx(void) { @@ -331,7 +315,7 @@ ea32_ecx(void) return CPU_ECX; } -static DWORD +static UINT32 ea32_edx(void) { @@ -339,7 +323,7 @@ ea32_edx(void) return CPU_EDX; } -static DWORD +static UINT32 ea32_ebx(void) { @@ -347,11 +331,12 @@ ea32_ebx(void) return CPU_EBX; } -static DWORD +static UINT32 ea32_sib(void) { - DWORD op, dst; - DWORD base, idx, scale; + UINT32 dst; + UINT32 op; + UINT32 base, idx, scale; GET_PCBYTE(op); base = op & 7; @@ -384,17 +369,17 @@ ea32_sib(void) return dst; } -static DWORD +static UINT32 ea32_disp32(void) { - DWORD adrs; + UINT32 adrs; GET_PCDWORD(adrs); CPU_INST_SEGREG_INDEX = DS_FIX; return adrs; } -static DWORD +static UINT32 ea32_esi(void) { @@ -402,7 +387,7 @@ ea32_esi(void) return CPU_ESI; } -static DWORD +static UINT32 ea32_edi(void) { @@ -410,52 +395,52 @@ ea32_edi(void) return CPU_EDI; } -static DWORD +static UINT32 ea32_eax_disp8(void) { - SDWORD adrs; + SINT32 adrs; GET_PCBYTESD(adrs); CPU_INST_SEGREG_INDEX = DS_FIX; return adrs + CPU_EAX; } -static DWORD +static UINT32 ea32_ecx_disp8(void) { - SDWORD adrs; + SINT32 adrs; GET_PCBYTESD(adrs); CPU_INST_SEGREG_INDEX = DS_FIX; return adrs + CPU_ECX; } -static DWORD +static UINT32 ea32_edx_disp8(void) { - SDWORD adrs; + SINT32 adrs; GET_PCBYTESD(adrs); CPU_INST_SEGREG_INDEX = DS_FIX; return adrs + CPU_EDX; } -static DWORD +static UINT32 ea32_ebx_disp8(void) { - SDWORD adrs; + SINT32 adrs; GET_PCBYTESD(adrs); CPU_INST_SEGREG_INDEX = DS_FIX; return adrs + CPU_EBX; } -static DWORD +static UINT32 ea32_sib_disp8(void) { - SDWORD adrs; - DWORD op; - DWORD base, idx, scale; + SINT32 adrs; + UINT32 op; + UINT32 base, idx, scale; GET_PCBYTE(op); base = op & 7; @@ -478,82 +463,82 @@ ea32_sib_disp8(void) return CPU_REGS_DWORD(base) + adrs; } -static DWORD +static UINT32 ea32_ebp_disp8(void) { - SDWORD adrs; + SINT32 adrs; GET_PCBYTESD(adrs); CPU_INST_SEGREG_INDEX = SS_FIX; return adrs + CPU_EBP; } -static DWORD +static UINT32 ea32_esi_disp8(void) { - SDWORD adrs; + SINT32 adrs; GET_PCBYTESD(adrs); CPU_INST_SEGREG_INDEX = DS_FIX; return adrs + CPU_ESI; } -static DWORD +static UINT32 ea32_edi_disp8(void) { - SDWORD adrs; + SINT32 adrs; GET_PCBYTESD(adrs); CPU_INST_SEGREG_INDEX = DS_FIX; return adrs + CPU_EDI; } -static DWORD +static UINT32 ea32_eax_disp32(void) { - DWORD adrs; + UINT32 adrs; GET_PCDWORD(adrs); CPU_INST_SEGREG_INDEX = DS_FIX; return adrs + CPU_EAX; } -static DWORD +static UINT32 ea32_ecx_disp32(void) { - DWORD adrs; + UINT32 adrs; GET_PCDWORD(adrs); CPU_INST_SEGREG_INDEX = DS_FIX; return adrs + CPU_ECX; } -static DWORD +static UINT32 ea32_edx_disp32(void) { - DWORD adrs; + UINT32 adrs; GET_PCDWORD(adrs); CPU_INST_SEGREG_INDEX = DS_FIX; return adrs + CPU_EDX; } -static DWORD +static UINT32 ea32_ebx_disp32(void) { - DWORD adrs; + UINT32 adrs; GET_PCDWORD(adrs); CPU_INST_SEGREG_INDEX = DS_FIX; return adrs + CPU_EBX; } -static DWORD +static UINT32 ea32_sib_disp32(void) { - DWORD adrs; - DWORD op; - DWORD base, idx, scale; + UINT32 adrs; + UINT32 op; + UINT32 base, idx, scale; GET_PCBYTE(op); base = op & 7; @@ -576,37 +561,37 @@ ea32_sib_disp32(void) return CPU_REGS_DWORD(base) + adrs; } -static DWORD +static UINT32 ea32_ebp_disp32(void) { - DWORD adrs; + UINT32 adrs; GET_PCDWORD(adrs); CPU_INST_SEGREG_INDEX = SS_FIX; return adrs + CPU_EBP; } -static DWORD +static UINT32 ea32_esi_disp32(void) { - DWORD adrs; + UINT32 adrs; GET_PCDWORD(adrs); CPU_INST_SEGREG_INDEX = DS_FIX; return adrs + CPU_ESI; } -static DWORD +static UINT32 ea32_edi_disp32(void) { - DWORD adrs; + UINT32 adrs; GET_PCDWORD(adrs); CPU_INST_SEGREG_INDEX = DS_FIX; return adrs + CPU_EDI; } -static DWORD (*c_ea32_dst_tbl[])(void) = { +static UINT32 (*c_ea32_dst_tbl[])(void) = { ea32_eax, ea32_ecx, ea32_edx, ea32_ebx, ea32_sib, ea32_disp32,