| 1 | /* Copyright 2006-2009, BeatriX | 
 
 
 
 
 | 2 | * File coded by BeatriX | 
 
 
 
 
 | 3 | * | 
 
 
 
 
 | 4 | * This file is part of BeaEngine. | 
 
 
 
 
 | 5 | * | 
 
 
 
 
 | 6 | *    BeaEngine is free software: you can redistribute it and/or modify | 
 
 
 
 
 | 7 | *    it under the terms of the GNU Lesser General Public License as published by | 
 
 
 
 
 | 8 | *    the Free Software Foundation, either version 3 of the License, or | 
 
 
 
 
 | 9 | *    (at your option) any later version. | 
 
 
 
 
 | 10 | * | 
 
 
 
 
 | 11 | *    BeaEngine is distributed in the hope that it will be useful, | 
 
 
 
 
 | 12 | *    but WITHOUT ANY WARRANTY; without even the implied warranty of | 
 
 
 
 
 | 13 | *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
 
 
 
 
 | 14 | *    GNU Lesser General Public License for more details. | 
 
 
 
 
 | 15 | * | 
 
 
 
 
 | 16 | *    You should have received a copy of the GNU Lesser General Public License | 
 
 
 
 
 | 17 | *    along with BeaEngine.  If not, see <http://www.gnu.org/licenses/>. */ | 
 
 
 
 
 | 18 |  | 
 
 
 
 
 | 19 | /* ==================================================================== | 
 
 
 
 
 | 20 | * | 
 
 
 
 
 | 21 | * ==================================================================== */ | 
 
 
 
 
 | 22 | int __bea_callspec__ Disasm (PDISASM pMyDisasm) { | 
 
 
 
 
 | 23 |  | 
 
 
 
 
 | 24 | if (InitVariables(pMyDisasm)) { | 
 
 
 
 
 | 25 | (void) AnalyzeOpcode(pMyDisasm); | 
 
 
 
 
 | 26 | if (!GV.OutOfBlock) { | 
 
 
 
 
 | 27 | FixArgSizeForMemoryOperand(pMyDisasm); | 
 
 
 
 
 | 28 | FixREXPrefixes(pMyDisasm); | 
 
 
 
 
 | 29 | FillSegmentsRegisters(pMyDisasm); | 
 
 
 
 
 | 30 | CompleteInstructionFields(pMyDisasm); | 
 
 
 
 
 | 31 | #ifndef BEA_LIGHT_DISASSEMBLY | 
 
 
 
 
 | 32 | if (GV.SYNTAX_ == ATSyntax) { | 
 
 
 
 
 | 33 | BuildCompleteInstructionATSyntax(pMyDisasm); | 
 
 
 
 
 | 34 | } | 
 
 
 
 
 | 35 | else { | 
 
 
 
 
 | 36 | BuildCompleteInstruction(pMyDisasm); | 
 
 
 
 
 | 37 | } | 
 
 
 
 
 | 38 | #endif | 
 
 
 
 
 | 39 | if (GV.ERROR_OPCODE) { | 
 
 
 
 
 | 40 | return -1; | 
 
 
 
 
 | 41 | } | 
 
 
 
 
 | 42 | else { | 
 
 
 
 
 | 43 | return (int) (GV.EIP_-(*pMyDisasm).EIP); | 
 
 
 
 
 | 44 | } | 
 
 
 
 
 | 45 | } | 
 
 
 
 
 | 46 | else { | 
 
 
 
 
 | 47 | return 0; | 
 
 
 
 
 | 48 | } | 
 
 
 
 
 | 49 | } | 
 
 
 
 
 | 50 | else { | 
 
 
 
 
 | 51 | return -1; | 
 
 
 
 
 | 52 | } | 
 
 
 
 
 | 53 | } | 
 
 
 
 
 | 54 |  | 
 
 
 
 
 | 55 | /* ==================================================================== | 
 
 
 
 
 | 56 | * | 
 
 
 
 
 | 57 | * ==================================================================== */ | 
 
 
 
 
 | 58 | void __bea_callspec__ CompleteInstructionFields (PDISASM pMyDisasm) { | 
 
 
 
 
 | 59 |  | 
 
 
 
 
 | 60 | if (((*pMyDisasm).Instruction.BranchType == JmpType) || ((*pMyDisasm).Instruction.BranchType == CallType)) { | 
 
 
 
 
 | 61 | (*pMyDisasm).Argument1.AccessMode = READ; | 
 
 
 
 
 | 62 | } | 
 
 
 
 
 | 63 | } | 
 
 
 
 
 | 64 |  | 
 
 
 
 
 | 65 | /* ==================================================================== | 
 
 
 
 
 | 66 | * | 
 
 
 
 
 | 67 | * ==================================================================== */ | 
 
 
 
 
 | 68 | int __bea_callspec__ InitVariables (PDISASM pMyDisasm) { | 
 
 
 
 
 | 69 |  | 
 
 
 
 
 | 70 | (void) memset (&GV, 0, sizeof (InternalDatas)); | 
 
 
 
 
 | 71 | GV.EIP_ = (*pMyDisasm).EIP; | 
 
 
 
 
 | 72 | GV.EIP_REAL = GV.EIP_; | 
 
 
 
 
 | 73 | GV.EIP_VA = (*pMyDisasm).VirtualAddr; | 
 
 
 
 
 | 74 | if ((*pMyDisasm).SecurityBlock != 0) GV.EndOfBlock = GV.EIP_+(*pMyDisasm).SecurityBlock; | 
 
 
 
 
 | 75 | GV.OperandSize = 32; | 
 
 
 
 
 | 76 | GV.OriginalOperandSize = 32; | 
 
 
 
 
 | 77 | GV.AddressSize = 32; | 
 
 
 
 
 | 78 | GV.Architecture = (*pMyDisasm).Archi; | 
 
 
 
 
 | 79 | (*pMyDisasm).Prefix.Number = 0; | 
 
 
 
 
 | 80 | if (GV.Architecture == 64) { | 
 
 
 
 
 | 81 | GV.AddressSize = 64; | 
 
 
 
 
 | 82 | } | 
 
 
 
 
 | 83 | if (GV.Architecture == 16) { | 
 
 
 
 
 | 84 | GV.OperandSize = 16; | 
 
 
 
 
 | 85 | GV.OriginalOperandSize = 16; | 
 
 
 
 
 | 86 | GV.AddressSize = 16; | 
 
 
 
 
 | 87 | } | 
 
 
 
 
 | 88 | (void) memset (&(*pMyDisasm).Argument1, 0, sizeof (ARGTYPE)); | 
 
 
 
 
 | 89 | (void) memset (&(*pMyDisasm).Argument2, 0, sizeof (ARGTYPE)); | 
 
 
 
 
 | 90 | (void) memset (&(*pMyDisasm).Argument3, 0, sizeof (ARGTYPE)); | 
 
 
 
 
 | 91 | (void) memset (&(*pMyDisasm).Prefix, 0, sizeof (PREFIXINFO)); | 
 
 
 
 
 | 92 | (*pMyDisasm).Argument1.AccessMode = WRITE; | 
 
 
 
 
 | 93 | (*pMyDisasm).Argument1.ArgPosition = LowPosition; | 
 
 
 
 
 | 94 | (*pMyDisasm).Argument2.ArgPosition = LowPosition; | 
 
 
 
 
 | 95 | (*pMyDisasm).Argument3.ArgPosition = LowPosition; | 
 
 
 
 
 | 96 | (*pMyDisasm).Argument1.ArgType = NO_ARGUMENT; | 
 
 
 
 
 | 97 | (*pMyDisasm).Argument2.ArgType = NO_ARGUMENT; | 
 
 
 
 
 | 98 | (*pMyDisasm).Argument3.ArgType = NO_ARGUMENT; | 
 
 
 
 
 | 99 | (*pMyDisasm).Argument2.AccessMode = READ; | 
 
 
 
 
 | 100 | (*pMyDisasm).Argument3.AccessMode = READ; | 
 
 
 
 
 | 101 | (void) memset (&(*pMyDisasm).Instruction, 0, sizeof (INSTRTYPE)); | 
 
 
 
 
 | 102 | GV.TAB_ = (UInt32)(*pMyDisasm).Options & 0xff; | 
 
 
 
 
 | 103 | GV.SYNTAX_ = (UInt32)(*pMyDisasm).Options & 0xff00; | 
 
 
 
 
 | 104 | GV.FORMATNUMBER = (UInt32)(*pMyDisasm).Options & 0xff0000; | 
 
 
 
 
 | 105 | GV.SEGMENTREGS = (UInt32)(*pMyDisasm).Options & 0xff000000; | 
 
 
 
 
 | 106 | GV.OutOfBlock = 0; | 
 
 
 
 
 | 107 | return 1; | 
 
 
 
 
 | 108 | } | 
 
 
 
 
 | 109 | /* ==================================================================== | 
 
 
 
 
 | 110 | * | 
 
 
 
 
 | 111 | * ==================================================================== */ | 
 
 
 
 
 | 112 | void __bea_callspec__ FixArgSizeForMemoryOperand (PDISASM pMyDisasm) { | 
 
 
 
 
 | 113 |  | 
 
 
 
 
 | 114 | if (GV.MemDecoration == Arg2byte) { | 
 
 
 
 
 | 115 | (*pMyDisasm).Argument2.ArgSize = 8; | 
 
 
 
 
 | 116 | } | 
 
 
 
 
 | 117 | else if (GV.MemDecoration == Arg2word) { | 
 
 
 
 
 | 118 | (*pMyDisasm).Argument2.ArgSize = 16; | 
 
 
 
 
 | 119 | } | 
 
 
 
 
 | 120 | else if (GV.MemDecoration == Arg2dword) { | 
 
 
 
 
 | 121 | (*pMyDisasm).Argument2.ArgSize = 32; | 
 
 
 
 
 | 122 | } | 
 
 
 
 
 | 123 | else if (GV.MemDecoration == Arg2qword) { | 
 
 
 
 
 | 124 | (*pMyDisasm).Argument2.ArgSize = 64; | 
 
 
 
 
 | 125 | } | 
 
 
 
 
 | 126 | else if (GV.MemDecoration == Arg2multibytes) { | 
 
 
 
 
 | 127 | (*pMyDisasm).Argument2.ArgSize = 0; | 
 
 
 
 
 | 128 | } | 
 
 
 
 
 | 129 | else if (GV.MemDecoration == Arg2tbyte) { | 
 
 
 
 
 | 130 | (*pMyDisasm).Argument2.ArgSize = 80; | 
 
 
 
 
 | 131 | } | 
 
 
 
 
 | 132 | else if (GV.MemDecoration == Arg2fword) { | 
 
 
 
 
 | 133 | (*pMyDisasm).Argument2.ArgSize = 48; | 
 
 
 
 
 | 134 | } | 
 
 
 
 
 | 135 | else if (GV.MemDecoration == Arg2dqword) { | 
 
 
 
 
 | 136 | (*pMyDisasm).Argument2.ArgSize = 128; | 
 
 
 
 
 | 137 | } | 
 
 
 
 
 | 138 |  | 
 
 
 
 
 | 139 |  | 
 
 
 
 
 | 140 | if (GV.MemDecoration == Arg1byte) { | 
 
 
 
 
 | 141 | (*pMyDisasm).Argument1.ArgSize = 8; | 
 
 
 
 
 | 142 | } | 
 
 
 
 
 | 143 | else if (GV.MemDecoration == Arg1word) { | 
 
 
 
 
 | 144 | (*pMyDisasm).Argument1.ArgSize = 16; | 
 
 
 
 
 | 145 | } | 
 
 
 
 
 | 146 | else if (GV.MemDecoration == Arg1dword) { | 
 
 
 
 
 | 147 | (*pMyDisasm).Argument1.ArgSize = 32; | 
 
 
 
 
 | 148 | } | 
 
 
 
 
 | 149 | else if (GV.MemDecoration == Arg1qword) { | 
 
 
 
 
 | 150 | (*pMyDisasm).Argument1.ArgSize = 64; | 
 
 
 
 
 | 151 | } | 
 
 
 
 
 | 152 | else if (GV.MemDecoration == Arg1multibytes) { | 
 
 
 
 
 | 153 | (*pMyDisasm).Argument1.ArgSize = 0; | 
 
 
 
 
 | 154 | } | 
 
 
 
 
 | 155 | else if (GV.MemDecoration == Arg1tbyte) { | 
 
 
 
 
 | 156 | (*pMyDisasm).Argument1.ArgSize = 80; | 
 
 
 
 
 | 157 | } | 
 
 
 
 
 | 158 | else if (GV.MemDecoration == Arg1fword) { | 
 
 
 
 
 | 159 | (*pMyDisasm).Argument1.ArgSize = 48; | 
 
 
 
 
 | 160 | } | 
 
 
 
 
 | 161 | else if (GV.MemDecoration == Arg1dqword) { | 
 
 
 
 
 | 162 | (*pMyDisasm).Argument1.ArgSize = 128; | 
 
 
 
 
 | 163 | } | 
 
 
 
 
 | 164 |  | 
 
 
 
 
 | 165 | } | 
 
 
 
 
 | 166 |  | 
 
 
 
 
 | 167 | /* ==================================================================== | 
 
 
 
 
 | 168 | * | 
 
 
 
 
 | 169 | * ==================================================================== */ | 
 
 
 
 
 | 170 | void __bea_callspec__ FixREXPrefixes (PDISASM pMyDisasm) { | 
 
 
 
 
 | 171 |  | 
 
 
 
 
 | 172 | (*pMyDisasm).Prefix.REX.W_ = GV.REX.W_; | 
 
 
 
 
 | 173 | (*pMyDisasm).Prefix.REX.R_ = GV.REX.R_; | 
 
 
 
 
 | 174 | (*pMyDisasm).Prefix.REX.X_ = GV.REX.X_; | 
 
 
 
 
 | 175 | (*pMyDisasm).Prefix.REX.B_ = GV.REX.B_; | 
 
 
 
 
 | 176 | (*pMyDisasm).Prefix.REX.state = GV.REX.state; | 
 
 
 
 
 | 177 |  | 
 
 
 
 
 | 178 | } | 
 
 
 
 
 | 179 |  | 
 
 
 
 
 | 180 | /* ==================================================================== | 
 
 
 
 
 | 181 | * | 
 
 
 
 
 | 182 | * ==================================================================== */ | 
 
 
 
 
 | 183 | int __bea_callspec__ AnalyzeOpcode (PDISASM pMyDisasm) { | 
 
 
 
 
 | 184 |  | 
 
 
 
 
 | 185 | (*pMyDisasm).Instruction.Opcode = *((UInt8*) (UIntPtr)(GV.EIP_)); | 
 
 
 
 
 | 186 | (void) opcode_map1[*((UInt8*) (UIntPtr)GV.EIP_)](pMyDisasm); | 
 
 
 
 
 | 187 | return 1; | 
 
 
 
 
 | 188 | } | 
 
 
 
 
 | 189 | /* ==================================================================== | 
 
 
 
 
 | 190 | * | 
 
 
 
 
 | 191 | * ==================================================================== */ | 
 
 
 
 
 | 192 | void __bea_callspec__ EbGb(PDISASM pMyDisasm) | 
 
 
 
 
 | 193 | { | 
 
 
 
 
 | 194 | GV.MemDecoration = Arg1byte; | 
 
 
 
 
 | 195 | GV.OperandSize = 8; | 
 
 
 
 
 | 196 | MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); | 
 
 
 
 
 | 197 | Reg_Opcode(&(*pMyDisasm).Argument2, pMyDisasm); | 
 
 
 
 
 | 198 | GV.OperandSize = 32; | 
 
 
 
 
 | 199 | GV.EIP_ += GV.DECALAGE_EIP+2; | 
 
 
 
 
 | 200 | } | 
 
 
 
 
 | 201 |  | 
 
 
 
 
 | 202 | /* ==================================================================== | 
 
 
 
 
 | 203 | * | 
 
 
 
 
 | 204 | * ==================================================================== */ | 
 
 
 
 
 | 205 | void __bea_callspec__ GbEb(PDISASM pMyDisasm) | 
 
 
 
 
 | 206 | { | 
 
 
 
 
 | 207 | GV.MemDecoration = Arg2byte; | 
 
 
 
 
 | 208 | GV.OperandSize = 8; | 
 
 
 
 
 | 209 | MOD_RM(&(*pMyDisasm).Argument2, pMyDisasm); | 
 
 
 
 
 | 210 | Reg_Opcode(&(*pMyDisasm).Argument1, pMyDisasm); | 
 
 
 
 
 | 211 | GV.OperandSize = 32; | 
 
 
 
 
 | 212 | GV.EIP_ += GV.DECALAGE_EIP+2; | 
 
 
 
 
 | 213 | } | 
 
 
 
 
 | 214 | /* ==================================================================== | 
 
 
 
 
 | 215 | * | 
 
 
 
 
 | 216 | * ==================================================================== */ | 
 
 
 
 
 | 217 | void __bea_callspec__ EvGv(PDISASM pMyDisasm) | 
 
 
 
 
 | 218 | { | 
 
 
 
 
 | 219 | if (GV.OperandSize == 64) { | 
 
 
 
 
 | 220 | GV.MemDecoration = Arg1qword; | 
 
 
 
 
 | 221 | } | 
 
 
 
 
 | 222 | else if (GV.OperandSize == 32) { | 
 
 
 
 
 | 223 | GV.MemDecoration = Arg1dword; | 
 
 
 
 
 | 224 | } | 
 
 
 
 
 | 225 | else { | 
 
 
 
 
 | 226 | GV.MemDecoration = Arg1word; | 
 
 
 
 
 | 227 | } | 
 
 
 
 
 | 228 | MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); | 
 
 
 
 
 | 229 | Reg_Opcode(&(*pMyDisasm).Argument2, pMyDisasm); | 
 
 
 
 
 | 230 | GV.EIP_ += GV.DECALAGE_EIP+2; | 
 
 
 
 
 | 231 | } | 
 
 
 
 
 | 232 |  | 
 
 
 
 
 | 233 | /* ==================================================================== | 
 
 
 
 
 | 234 | * | 
 
 
 
 
 | 235 | * ==================================================================== */ | 
 
 
 
 
 | 236 | void __bea_callspec__ ExGx(PDISASM pMyDisasm) | 
 
 
 
 
 | 237 | { | 
 
 
 
 
 | 238 | MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); | 
 
 
 
 
 | 239 | Reg_Opcode(&(*pMyDisasm).Argument2, pMyDisasm); | 
 
 
 
 
 | 240 | GV.EIP_ += GV.DECALAGE_EIP+2; | 
 
 
 
 
 | 241 | } | 
 
 
 
 
 | 242 |  | 
 
 
 
 
 | 243 | /* ==================================================================== | 
 
 
 
 
 | 244 | * | 
 
 
 
 
 | 245 | * ==================================================================== */ | 
 
 
 
 
 | 246 | void __bea_callspec__ EvIv(PDISASM pMyDisasm) | 
 
 
 
 
 | 247 | { | 
 
 
 
 
 | 248 | if (GV.OperandSize >= 32) { | 
 
 
 
 
 | 249 | if (GV.OperandSize == 64) { | 
 
 
 
 
 | 250 | GV.MemDecoration = Arg1qword; | 
 
 
 
 
 | 251 | } | 
 
 
 
 
 | 252 | else { | 
 
 
 
 
 | 253 | GV.MemDecoration = Arg1dword; | 
 
 
 
 
 | 254 | } | 
 
 
 
 
 | 255 | GV.ImmediatSize = 32;                       /* place this instruction before MOD_RM routine to inform it there is an immediat value */ | 
 
 
 
 
 | 256 | MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); | 
 
 
 
 
 | 257 | GV.EIP_ += GV.DECALAGE_EIP+6; | 
 
 
 
 
 | 258 | if (!Security(0, pMyDisasm)) return; | 
 
 
 
 
 | 259 | #ifndef BEA_LIGHT_DISASSEMBLY | 
 
 
 
 
 | 260 | if (GV.OperandSize == 64) { | 
 
 
 
 
 | 261 | (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument2.ArgMnemonic,"%.16llX",(Int64) *((Int32*)(UIntPtr) (GV.EIP_-4))); | 
 
 
 
 
 | 262 | } | 
 
 
 
 
 | 263 | else { | 
 
 
 
 
 | 264 | (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument2.ArgMnemonic,"%.8X",(Int64) *((UInt32*)(UIntPtr) (GV.EIP_-4))); | 
 
 
 
 
 | 265 | } | 
 
 
 
 
 | 266 | #endif | 
 
 
 
 
 | 267 |  | 
 
 
 
 
 | 268 | (*pMyDisasm).Argument2.ArgType = CONSTANT_TYPE+ABSOLUTE_; | 
 
 
 
 
 | 269 | (*pMyDisasm).Argument2.ArgSize = 32; | 
 
 
 
 
 | 270 | (*pMyDisasm).Instruction.Immediat = *((UInt32*)(UIntPtr) (GV.EIP_-4)); | 
 
 
 
 
 | 271 | } | 
 
 
 
 
 | 272 | else { | 
 
 
 
 
 | 273 | GV.MemDecoration = Arg1word; | 
 
 
 
 
 | 274 | GV.ImmediatSize = 16; | 
 
 
 
 
 | 275 | MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); | 
 
 
 
 
 | 276 | GV.EIP_ += GV.DECALAGE_EIP+4; | 
 
 
 
 
 | 277 | if (!Security(0, pMyDisasm)) return; | 
 
 
 
 
 | 278 | #ifndef BEA_LIGHT_DISASSEMBLY | 
 
 
 
 
 | 279 | (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument2.ArgMnemonic,"%.4X",(Int64)*((UInt16*)(UIntPtr) (GV.EIP_-2))); | 
 
 
 
 
 | 280 | #endif | 
 
 
 
 
 | 281 | (*pMyDisasm).Argument2.ArgType = CONSTANT_TYPE+ABSOLUTE_; | 
 
 
 
 
 | 282 | (*pMyDisasm).Argument2.ArgSize = 16; | 
 
 
 
 
 | 283 | (*pMyDisasm).Instruction.Immediat = *((UInt16*)(UIntPtr) (GV.EIP_-2)); | 
 
 
 
 
 | 284 | } | 
 
 
 
 
 | 285 | } | 
 
 
 
 
 | 286 |  | 
 
 
 
 
 | 287 | /* ==================================================================== | 
 
 
 
 
 | 288 | * | 
 
 
 
 
 | 289 | * ==================================================================== */ | 
 
 
 
 
 | 290 | void __bea_callspec__ EvIb(PDISASM pMyDisasm) | 
 
 
 
 
 | 291 | { | 
 
 
 
 
 | 292 | Int8 MyNumber; | 
 
 
 
 
 | 293 | (*pMyDisasm).Argument2.ArgType = CONSTANT_TYPE+ABSOLUTE_; | 
 
 
 
 
 | 294 | (*pMyDisasm).Argument2.ArgSize = 8; | 
 
 
 
 
 | 295 | GV.ImmediatSize = 8; | 
 
 
 
 
 | 296 | if (GV.OperandSize >= 32) { | 
 
 
 
 
 | 297 | if (GV.OperandSize == 64) { | 
 
 
 
 
 | 298 | GV.MemDecoration = Arg1qword; | 
 
 
 
 
 | 299 | } | 
 
 
 
 
 | 300 | else { | 
 
 
 
 
 | 301 | GV.MemDecoration = Arg1dword; | 
 
 
 
 
 | 302 | } | 
 
 
 
 
 | 303 | MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); | 
 
 
 
 
 | 304 | GV.EIP_ += GV.DECALAGE_EIP+3; | 
 
 
 
 
 | 305 | if (!Security(0, pMyDisasm)) return; | 
 
 
 
 
 | 306 | if (GV.OperandSize == 32) { | 
 
 
 
 
 | 307 | #ifndef BEA_LIGHT_DISASSEMBLY | 
 
 
 
 
 | 308 | MyNumber = *((Int8*)(UIntPtr) (GV.EIP_-1)); | 
 
 
 
 
 | 309 | if (MyNumber > 0) { | 
 
 
 
 
 | 310 | (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument2.ArgMnemonic,"%.2X",(Int64)*((Int8*)(UIntPtr) (GV.EIP_-1))); | 
 
 
 
 
 | 311 | } | 
 
 
 
 
 | 312 | else { | 
 
 
 
 
 | 313 | (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument2.ArgMnemonic,"%.8X",(Int64)*((Int8*)(IntPtr) (GV.EIP_-1))); | 
 
 
 
 
 | 314 | } | 
 
 
 
 
 | 315 | #endif | 
 
 
 
 
 | 316 | } | 
 
 
 
 
 | 317 | else { | 
 
 
 
 
 | 318 | #ifndef BEA_LIGHT_DISASSEMBLY | 
 
 
 
 
 | 319 | MyNumber = *((Int8*)(UIntPtr) (GV.EIP_-1)); | 
 
 
 
 
 | 320 | if (MyNumber > 0) { | 
 
 
 
 
 | 321 | (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument2.ArgMnemonic,"%.2X",(Int64)*((Int8*)(UIntPtr) (GV.EIP_-1))); | 
 
 
 
 
 | 322 | } | 
 
 
 
 
 | 323 | else { | 
 
 
 
 
 | 324 | (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument2.ArgMnemonic,"%.16llX",(Int64)*((Int8*)(IntPtr) (GV.EIP_-1))); | 
 
 
 
 
 | 325 | } | 
 
 
 
 
 | 326 | #endif | 
 
 
 
 
 | 327 | } | 
 
 
 
 
 | 328 |  | 
 
 
 
 
 | 329 | (*pMyDisasm).Instruction.Immediat = *((UInt8*)(UIntPtr) (GV.EIP_-1)); | 
 
 
 
 
 | 330 | } | 
 
 
 
 
 | 331 | else { | 
 
 
 
 
 | 332 | GV.MemDecoration = Arg1word; | 
 
 
 
 
 | 333 | MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); | 
 
 
 
 
 | 334 | GV.EIP_ += GV.DECALAGE_EIP+3; | 
 
 
 
 
 | 335 | if (!Security(0, pMyDisasm)) return; | 
 
 
 
 
 | 336 | #ifndef BEA_LIGHT_DISASSEMBLY | 
 
 
 
 
 | 337 | (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument2.ArgMnemonic,"%.4X",(Int64)*((Int8*)(UIntPtr) (GV.EIP_-1))); | 
 
 
 
 
 | 338 | #endif | 
 
 
 
 
 | 339 |  | 
 
 
 
 
 | 340 | (*pMyDisasm).Instruction.Immediat = *((UInt8*)(UIntPtr) (GV.EIP_-1)); | 
 
 
 
 
 | 341 | } | 
 
 
 
 
 | 342 | } | 
 
 
 
 
 | 343 | /* ==================================================================== | 
 
 
 
 
 | 344 | * | 
 
 
 
 
 | 345 | * ==================================================================== */ | 
 
 
 
 
 | 346 | void __bea_callspec__ EbIb(PDISASM pMyDisasm) | 
 
 
 
 
 | 347 | { | 
 
 
 
 
 | 348 | (*pMyDisasm).Argument2.ArgType = CONSTANT_TYPE+ABSOLUTE_; | 
 
 
 
 
 | 349 | (*pMyDisasm).Argument2.ArgSize = 8; | 
 
 
 
 
 | 350 | GV.ImmediatSize = 8; | 
 
 
 
 
 | 351 | GV.MemDecoration = Arg1byte; | 
 
 
 
 
 | 352 | GV.OperandSize = 8; | 
 
 
 
 
 | 353 | MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); | 
 
 
 
 
 | 354 | GV.OperandSize = 32; | 
 
 
 
 
 | 355 | GV.EIP_ += GV.DECALAGE_EIP+3; | 
 
 
 
 
 | 356 | if (!Security(0, pMyDisasm)) return; | 
 
 
 
 
 | 357 | #ifndef BEA_LIGHT_DISASSEMBLY | 
 
 
 
 
 | 358 | (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument2.ArgMnemonic,"%.2X",(Int64)*((Int8*)(UIntPtr) (GV.EIP_-1))); | 
 
 
 
 
 | 359 | #endif | 
 
 
 
 
 | 360 | (*pMyDisasm).Instruction.Immediat = *((UInt8*)(UIntPtr) (GV.EIP_-1)); | 
 
 
 
 
 | 361 | } | 
 
 
 
 
 | 362 |  | 
 
 
 
 
 | 363 | /* ==================================================================== | 
 
 
 
 
 | 364 | * | 
 
 
 
 
 | 365 | * ==================================================================== */ | 
 
 
 
 
 | 366 | void __bea_callspec__ Eb(PDISASM pMyDisasm) | 
 
 
 
 
 | 367 | { | 
 
 
 
 
 | 368 | GV.MemDecoration = Arg1byte; | 
 
 
 
 
 | 369 | GV.OperandSize = 8; | 
 
 
 
 
 | 370 | MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); | 
 
 
 
 
 | 371 | GV.OperandSize = 32; | 
 
 
 
 
 | 372 | GV.EIP_ += GV.DECALAGE_EIP+2; | 
 
 
 
 
 | 373 | } | 
 
 
 
 
 | 374 |  | 
 
 
 
 
 | 375 | /* ==================================================================== | 
 
 
 
 
 | 376 | * | 
 
 
 
 
 | 377 | * ==================================================================== */ | 
 
 
 
 
 | 378 | void __bea_callspec__ Ev(PDISASM pMyDisasm) | 
 
 
 
 
 | 379 | { | 
 
 
 
 
 | 380 | if (GV.OperandSize == 64) { | 
 
 
 
 
 | 381 | GV.MemDecoration = Arg1qword; | 
 
 
 
 
 | 382 | } | 
 
 
 
 
 | 383 | else if (GV.OperandSize == 32) { | 
 
 
 
 
 | 384 | GV.MemDecoration = Arg1dword; | 
 
 
 
 
 | 385 | } | 
 
 
 
 
 | 386 | else { | 
 
 
 
 
 | 387 | GV.MemDecoration = Arg1word; | 
 
 
 
 
 | 388 | } | 
 
 
 
 
 | 389 | MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); | 
 
 
 
 
 | 390 | GV.EIP_ += GV.DECALAGE_EIP+2; | 
 
 
 
 
 | 391 | } | 
 
 
 
 
 | 392 |  | 
 
 
 
 
 | 393 | /* ==================================================================== | 
 
 
 
 
 | 394 | * | 
 
 
 
 
 | 395 | * ==================================================================== */ | 
 
 
 
 
 | 396 | void __bea_callspec__ GvEv(PDISASM pMyDisasm) | 
 
 
 
 
 | 397 | { | 
 
 
 
 
 | 398 | if (GV.OperandSize == 64) { | 
 
 
 
 
 | 399 | GV.MemDecoration = Arg2qword; | 
 
 
 
 
 | 400 | } | 
 
 
 
 
 | 401 | else if (GV.OperandSize == 32) { | 
 
 
 
 
 | 402 | GV.MemDecoration = Arg2dword; | 
 
 
 
 
 | 403 | } | 
 
 
 
 
 | 404 | else { | 
 
 
 
 
 | 405 | GV.MemDecoration = Arg2word; | 
 
 
 
 
 | 406 | } | 
 
 
 
 
 | 407 | MOD_RM(&(*pMyDisasm).Argument2, pMyDisasm); | 
 
 
 
 
 | 408 | Reg_Opcode(&(*pMyDisasm).Argument1, pMyDisasm); | 
 
 
 
 
 | 409 | GV.EIP_ += GV.DECALAGE_EIP+2; | 
 
 
 
 
 | 410 | } | 
 
 
 
 
 | 411 |  | 
 
 
 
 
 | 412 | /* ==================================================================== | 
 
 
 
 
 | 413 | * | 
 
 
 
 
 | 414 | * ==================================================================== */ | 
 
 
 
 
 | 415 | void __bea_callspec__ GvEb(PDISASM pMyDisasm) | 
 
 
 
 
 | 416 | { | 
 
 
 
 
 | 417 | if (GV.OperandSize == 64) { | 
 
 
 
 
 | 418 | GV.MemDecoration = Arg2byte; | 
 
 
 
 
 | 419 | GV.OperandSize = 8; | 
 
 
 
 
 | 420 | MOD_RM(&(*pMyDisasm).Argument2, pMyDisasm); | 
 
 
 
 
 | 421 | GV.OperandSize = 64; | 
 
 
 
 
 | 422 | } | 
 
 
 
 
 | 423 | else if (GV.OperandSize == 32) { | 
 
 
 
 
 | 424 | GV.MemDecoration = Arg2byte; | 
 
 
 
 
 | 425 | GV.OperandSize = 8; | 
 
 
 
 
 | 426 | MOD_RM(&(*pMyDisasm).Argument2, pMyDisasm); | 
 
 
 
 
 | 427 | GV.OperandSize = 32; | 
 
 
 
 
 | 428 | } | 
 
 
 
 
 | 429 | else { | 
 
 
 
 
 | 430 | GV.MemDecoration = Arg2byte; | 
 
 
 
 
 | 431 | GV.OperandSize = 8; | 
 
 
 
 
 | 432 | MOD_RM(&(*pMyDisasm).Argument2, pMyDisasm); | 
 
 
 
 
 | 433 | GV.OperandSize = 16; | 
 
 
 
 
 | 434 | } | 
 
 
 
 
 | 435 | Reg_Opcode(&(*pMyDisasm).Argument1, pMyDisasm); | 
 
 
 
 
 | 436 | GV.EIP_ += GV.DECALAGE_EIP+2; | 
 
 
 
 
 | 437 | } | 
 
 
 
 
 | 438 |  | 
 
 
 
 
 | 439 | /* ==================================================================== | 
 
 
 
 
 | 440 | * | 
 
 
 
 
 | 441 | * ==================================================================== */ | 
 
 
 
 
 | 442 | void __bea_callspec__ GxEx(PDISASM pMyDisasm) | 
 
 
 
 
 | 443 | { | 
 
 
 
 
 | 444 | MOD_RM(&(*pMyDisasm).Argument2, pMyDisasm); | 
 
 
 
 
 | 445 | Reg_Opcode(&(*pMyDisasm).Argument1, pMyDisasm); | 
 
 
 
 
 | 446 | GV.EIP_ += GV.DECALAGE_EIP+2; | 
 
 
 
 
 | 447 | } | 
 
 
 
 
 | 448 |  | 
 
 
 
 
 | 449 | /* ==================================================================== | 
 
 
 
 
 | 450 | * | 
 
 
 
 
 | 451 | * ==================================================================== */ | 
 
 
 
 
 | 452 | void __bea_callspec__ GvEw(PDISASM pMyDisasm) | 
 
 
 
 
 | 453 | { | 
 
 
 
 
 | 454 | GV.MemDecoration = Arg2word; | 
 
 
 
 
 | 455 | GV.OriginalOperandSize = GV.OperandSize; | 
 
 
 
 
 | 456 | GV.OperandSize = 16; | 
 
 
 
 
 | 457 | MOD_RM(&(*pMyDisasm).Argument2, pMyDisasm); | 
 
 
 
 
 | 458 | GV.OperandSize = GV.OriginalOperandSize; | 
 
 
 
 
 | 459 | Reg_Opcode(&(*pMyDisasm).Argument1, pMyDisasm); | 
 
 
 
 
 | 460 | GV.EIP_ += GV.DECALAGE_EIP+2; | 
 
 
 
 
 | 461 | } | 
 
 
 
 
 | 462 |  | 
 
 
 
 
 | 463 | /* ==================================================================== | 
 
 
 
 
 | 464 | * | 
 
 
 
 
 | 465 | * ==================================================================== */ | 
 
 
 
 
 | 466 | void __bea_callspec__ ALIb(PDISASM pMyDisasm) | 
 
 
 
 
 | 467 | { | 
 
 
 
 
 | 468 | long MyNumber; | 
 
 
 
 
 | 469 | if (!Security(2, pMyDisasm)) return; | 
 
 
 
 
 | 470 | GV.ImmediatSize = 8; | 
 
 
 
 
 | 471 | MyNumber = *((Int8*)(IntPtr) (GV.EIP_+1)); | 
 
 
 
 
 | 472 | #ifndef BEA_LIGHT_DISASSEMBLY | 
 
 
 
 
 | 473 | (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument2.ArgMnemonic,"%.2X",(Int64) MyNumber); | 
 
 
 
 
 | 474 | #endif | 
 
 
 
 
 | 475 | (*pMyDisasm).Instruction.Immediat = MyNumber; | 
 
 
 
 
 | 476 | #ifndef BEA_LIGHT_DISASSEMBLY | 
 
 
 
 
 | 477 | (void) strcpy((char*) &(*pMyDisasm).Argument1.ArgMnemonic, Registers8Bits[0]); | 
 
 
 
 
 | 478 | #endif | 
 
 
 
 
 | 479 | (*pMyDisasm).Argument1.ArgType = REGISTER_TYPE+GENERAL_REG+REG0; | 
 
 
 
 
 | 480 | (*pMyDisasm).Argument1.ArgSize = 8; | 
 
 
 
 
 | 481 | (*pMyDisasm).Argument2.ArgType = CONSTANT_TYPE+ABSOLUTE_; | 
 
 
 
 
 | 482 | (*pMyDisasm).Argument2.ArgSize = 8; | 
 
 
 
 
 | 483 | GV.EIP_ += 2; | 
 
 
 
 
 | 484 | } | 
 
 
 
 
 | 485 |  | 
 
 
 
 
 | 486 | /* ==================================================================== | 
 
 
 
 
 | 487 | * | 
 
 
 
 
 | 488 | * ==================================================================== */ | 
 
 
 
 
 | 489 | void __bea_callspec__ eAX_Iv(PDISASM pMyDisasm) | 
 
 
 
 
 | 490 | { | 
 
 
 
 
 | 491 | UInt32 MyNumber; | 
 
 
 
 
 | 492 | (*pMyDisasm).Argument1.ArgType = REGISTER_TYPE+GENERAL_REG+REG0; | 
 
 
 
 
 | 493 | (*pMyDisasm).Argument2.ArgType = CONSTANT_TYPE+ABSOLUTE_; | 
 
 
 
 
 | 494 | if (GV.OperandSize == 64) { | 
 
 
 
 
 | 495 | if (!Security(5, pMyDisasm)) return; | 
 
 
 
 
 | 496 | GV.ImmediatSize = 32; | 
 
 
 
 
 | 497 | (*pMyDisasm).Argument1.ArgSize = 64; | 
 
 
 
 
 | 498 | (*pMyDisasm).Argument2.ArgSize = 32; | 
 
 
 
 
 | 499 | MyNumber = *((UInt32*)(UIntPtr) (GV.EIP_+1)); | 
 
 
 
 
 | 500 | #ifndef BEA_LIGHT_DISASSEMBLY | 
 
 
 
 
 | 501 | (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument2.ArgMnemonic,"%.16llX",(Int64) MyNumber); | 
 
 
 
 
 | 502 | #endif | 
 
 
 
 
 | 503 | (*pMyDisasm).Instruction.Immediat = MyNumber; | 
 
 
 
 
 | 504 | if (GV.REX.B_ == 1) { | 
 
 
 
 
 | 505 | #ifndef BEA_LIGHT_DISASSEMBLY | 
 
 
 
 
 | 506 | (void) strcpy ((char*) (*pMyDisasm).Argument1.ArgMnemonic, Registers64Bits[0+8]); | 
 
 
 
 
 | 507 | #endif | 
 
 
 
 
 | 508 | } | 
 
 
 
 
 | 509 | else { | 
 
 
 
 
 | 510 | #ifndef BEA_LIGHT_DISASSEMBLY | 
 
 
 
 
 | 511 | (void) strcpy ((char*) (*pMyDisasm).Argument1.ArgMnemonic, Registers64Bits[0]); | 
 
 
 
 
 | 512 | #endif | 
 
 
 
 
 | 513 | } | 
 
 
 
 
 | 514 | GV.EIP_+= 5; | 
 
 
 
 
 | 515 | } | 
 
 
 
 
 | 516 | else if (GV.OperandSize == 32) { | 
 
 
 
 
 | 517 | if (!Security(5, pMyDisasm)) return; | 
 
 
 
 
 | 518 | GV.ImmediatSize = 32; | 
 
 
 
 
 | 519 | (*pMyDisasm).Argument1.ArgSize = 32; | 
 
 
 
 
 | 520 | (*pMyDisasm).Argument2.ArgSize = 32; | 
 
 
 
 
 | 521 | MyNumber = *((UInt32*)(UIntPtr) (GV.EIP_+1)); | 
 
 
 
 
 | 522 | #ifndef BEA_LIGHT_DISASSEMBLY | 
 
 
 
 
 | 523 | (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument2.ArgMnemonic,"%.8X",(Int64) MyNumber); | 
 
 
 
 
 | 524 | #endif | 
 
 
 
 
 | 525 | (*pMyDisasm).Instruction.Immediat = MyNumber; | 
 
 
 
 
 | 526 | if (GV.REX.B_ == 1) { | 
 
 
 
 
 | 527 | #ifndef BEA_LIGHT_DISASSEMBLY | 
 
 
 
 
 | 528 | (void) strcpy ((char*) (*pMyDisasm).Argument1.ArgMnemonic, Registers32Bits[0+8]); | 
 
 
 
 
 | 529 | #endif | 
 
 
 
 
 | 530 | } | 
 
 
 
 
 | 531 | else { | 
 
 
 
 
 | 532 | #ifndef BEA_LIGHT_DISASSEMBLY | 
 
 
 
 
 | 533 | (void) strcpy ((char*) (*pMyDisasm).Argument1.ArgMnemonic, Registers32Bits[0]); | 
 
 
 
 
 | 534 | #endif | 
 
 
 
 
 | 535 | } | 
 
 
 
 
 | 536 | GV.EIP_+= 5; | 
 
 
 
 
 | 537 | } | 
 
 
 
 
 | 538 | else { | 
 
 
 
 
 | 539 | if (!Security(3, pMyDisasm)) return; | 
 
 
 
 
 | 540 | GV.ImmediatSize = 16; | 
 
 
 
 
 | 541 | (*pMyDisasm).Argument1.ArgSize = 16; | 
 
 
 
 
 | 542 | (*pMyDisasm).Argument2.ArgSize = 16; | 
 
 
 
 
 | 543 | MyNumber = *((UInt16*)(UIntPtr) (GV.EIP_+1)); | 
 
 
 
 
 | 544 | #ifndef BEA_LIGHT_DISASSEMBLY | 
 
 
 
 
 | 545 | (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument2.ArgMnemonic,"%.8X", (Int64) MyNumber); | 
 
 
 
 
 | 546 | #endif | 
 
 
 
 
 | 547 | (*pMyDisasm).Instruction.Immediat = MyNumber; | 
 
 
 
 
 | 548 | if (GV.REX.B_ == 1) { | 
 
 
 
 
 | 549 | #ifndef BEA_LIGHT_DISASSEMBLY | 
 
 
 
 
 | 550 | (void) strcpy ((char*) (*pMyDisasm).Argument1.ArgMnemonic, Registers16Bits[0+8]); | 
 
 
 
 
 | 551 | #endif | 
 
 
 
 
 | 552 | } | 
 
 
 
 
 | 553 | else { | 
 
 
 
 
 | 554 | #ifndef BEA_LIGHT_DISASSEMBLY | 
 
 
 
 
 | 555 | (void) strcpy ((char*) (*pMyDisasm).Argument1.ArgMnemonic, Registers16Bits[0]); | 
 
 
 
 
 | 556 | #endif | 
 
 
 
 
 | 557 | } | 
 
 
 
 
 | 558 | GV.EIP_+= 3; | 
 
 
 
 
 | 559 | } | 
 
 
 
 
 | 560 |  | 
 
 
 
 
 | 561 | } | 
 
 
 
 
 | 562 |  | 
 
 
 
 
 | 563 | /* ==================================================================== | 
 
 
 
 
 | 564 | * | 
 
 
 
 
 | 565 | * ==================================================================== */ | 
 
 
 
 
 | 566 | int __bea_callspec__ Security(int len, PDISASM pMyDisasm) | 
 
 
 
 
 | 567 | { | 
 
 
 
 
 | 568 | if ((GV.EndOfBlock != 0) && (GV.EIP_+(UInt64)len >= GV.EndOfBlock)) { | 
 
 
 
 
 | 569 | GV.OutOfBlock = 1; | 
 
 
 
 
 | 570 | return 0; | 
 
 
 
 
 | 571 | } | 
 
 
 
 
 | 572 | return 1; | 
 
 
 
 
 | 573 | } | 
 
 
 
 
 | 574 |  | 
 
 
 
 
 | 575 | /* ==================================================================== | 
 
 
 
 
 | 576 | * | 
 
 
 
 
 | 577 | * ==================================================================== */ | 
 
 
 
 
 | 578 | void __bea_callspec__ FillFlags(PDISASM pMyDisasm, int index) | 
 
 
 
 
 | 579 | { | 
 
 
 
 
 | 580 | (*pMyDisasm).Instruction.Flags = EFLAGS_TABLE[index]; | 
 
 
 
 
 | 581 | } | 
 
 
 
 
 | 582 | /* ==================================================================== | 
 
 
 
 
 | 583 | * | 
 
 
 
 
 | 584 | * ==================================================================== */ | 
 
 
 
 
 | 585 | void __bea_callspec__ CalculateRelativeAddress(UInt64 * pMyAddress, Int64 MyNumber, PDISASM pMyDisasm) | 
 
 
 
 
 | 586 | { | 
 
 
 
 
 | 587 | GV.RelativeAddress = 1; | 
 
 
 
 
 | 588 | if (GV.EIP_VA != 0) { | 
 
 
 
 
 | 589 | *pMyAddress = (UInt64) (GV.EIP_VA+(UInt64) MyNumber); | 
 
 
 
 
 | 590 | } | 
 
 
 
 
 | 591 | else { | 
 
 
 
 
 | 592 | *pMyAddress = (UInt64) (GV.EIP_REAL+(UInt64) MyNumber); | 
 
 
 
 
 | 593 | } | 
 
 
 
 
 | 594 | } | 
 
 
 
 
 | 595 |  | 
 
 
 
 
 | 596 | /* ==================================================================== | 
 
 
 
 
 | 597 | * | 
 
 
 
 
 | 598 | * ==================================================================== */ | 
 
 
 
 
 | 599 | #ifndef BEA_LIGHT_DISASSEMBLY | 
 
 
 
 
 | 600 | size_t __bea_callspec__ CopyFormattedNumber(PDISASM pMyDisasm, char* pBuffer, const char* pFormat, Int64 MyNumber) | 
 
 
 
 
 | 601 | { | 
 
 
 
 
 | 602 | size_t i = 0; | 
 
 
 
 
 | 603 | if (!strcmp(pFormat,"%.2X")) MyNumber = MyNumber & 0xFF; | 
 
 
 
 
 | 604 | if (!strcmp(pFormat,"%.4X")) MyNumber = MyNumber & 0xFFFF; | 
 
 
 
 
 | 605 | if (!strcmp(pFormat,"%.8X")) MyNumber = MyNumber & 0xFFFFFFFF; | 
 
 
 
 
 | 606 | if (GV.FORMATNUMBER == PrefixedNumeral) { | 
 
 
 
 
 | 607 | (void) strcpy(pBuffer, "0x"); | 
 
 
 
 
 | 608 | (void) sprintf (pBuffer+2, pFormat, MyNumber); | 
 
 
 
 
 | 609 | i += strlen(pBuffer); | 
 
 
 
 
 | 610 | } | 
 
 
 
 
 | 611 | else { | 
 
 
 
 
 | 612 | (void) sprintf (pBuffer+i, pFormat, MyNumber); | 
 
 
 
 
 | 613 | i += strlen(pBuffer); | 
 
 
 
 
 | 614 | (void) strcpy(pBuffer+i, "h"); | 
 
 
 
 
 | 615 | i++; | 
 
 
 
 
 | 616 | } | 
 
 
 
 
 | 617 | return i; | 
 
 
 
 
 | 618 | } | 
 
 
 
 
 | 619 | #endif | 
 
 
 
 
 | 620 |  | 
 
 
 
 
 | 621 | /* ==================================================================== | 
 
 
 
 
 | 622 | * | 
 
 
 
 
 | 623 | * ==================================================================== */ | 
 
 
 
 
 | 624 | void __bea_callspec__ FillSegmentsRegisters(PDISASM pMyDisasm) | 
 
 
 
 
 | 625 | { | 
 
 
 
 
 | 626 | if (((*pMyDisasm).Prefix.LockPrefix == InUsePrefix) && !((*pMyDisasm).Argument1.ArgType & MEMORY_TYPE)) { | 
 
 
 
 
 | 627 | (*pMyDisasm).Prefix.LockPrefix = InvalidPrefix; | 
 
 
 
 
 | 628 | } | 
 
 
 
 
 | 629 | if ((*pMyDisasm).Instruction.Category == GENERAL_PURPOSE_INSTRUCTION+STRING_INSTRUCTION) { | 
 
 
 
 
 | 630 | (*pMyDisasm).Argument1.SegmentReg = ESReg; | 
 
 
 
 
 | 631 | (*pMyDisasm).Argument2.SegmentReg = DSReg; | 
 
 
 
 
 | 632 | /* =============== override affects Arg2 */ | 
 
 
 
 
 | 633 | if ((*pMyDisasm).Argument2.ArgType & MEMORY_TYPE) { | 
 
 
 
 
 | 634 | if ((*pMyDisasm).Prefix.FSPrefix == InUsePrefix) { | 
 
 
 
 
 | 635 | (*pMyDisasm).Argument2.SegmentReg = FSReg; | 
 
 
 
 
 | 636 | } | 
 
 
 
 
 | 637 | else if ((*pMyDisasm).Prefix.GSPrefix == InUsePrefix) { | 
 
 
 
 
 | 638 | (*pMyDisasm).Argument2.SegmentReg = GSReg; | 
 
 
 
 
 | 639 | } | 
 
 
 
 
 | 640 | else if ((*pMyDisasm).Prefix.CSPrefix == InUsePrefix) { | 
 
 
 
 
 | 641 | (*pMyDisasm).Argument2.SegmentReg = CSReg; | 
 
 
 
 
 | 642 | } | 
 
 
 
 
 | 643 | else if ((*pMyDisasm).Prefix.ESPrefix == InUsePrefix) { | 
 
 
 
 
 | 644 | (*pMyDisasm).Argument2.SegmentReg = ESReg; | 
 
 
 
 
 | 645 | } | 
 
 
 
 
 | 646 | else if ((*pMyDisasm).Prefix.SSPrefix == InUsePrefix) { | 
 
 
 
 
 | 647 | (*pMyDisasm).Argument2.SegmentReg = SSReg; | 
 
 
 
 
 | 648 | } | 
 
 
 
 
 | 649 | else { | 
 
 
 
 
 | 650 | (*pMyDisasm).Argument2.SegmentReg = DSReg; | 
 
 
 
 
 | 651 | } | 
 
 
 
 
 | 652 | } | 
 
 
 
 
 | 653 | } | 
 
 
 
 
 | 654 | else { | 
 
 
 
 
 | 655 | if ((*pMyDisasm).Argument1.ArgType & MEMORY_TYPE) { | 
 
 
 
 
 | 656 | if (((*pMyDisasm).Argument1.Memory.BaseRegister == REG4) || ((*pMyDisasm).Argument1.Memory.BaseRegister == REG5)) { | 
 
 
 
 
 | 657 | (*pMyDisasm).Argument1.SegmentReg = SSReg; | 
 
 
 
 
 | 658 | /* ========== override is invalid here */ | 
 
 
 
 
 | 659 | if ((*pMyDisasm).Argument2.ArgType != MEMORY_TYPE) { | 
 
 
 
 
 | 660 | if ((*pMyDisasm).Prefix.FSPrefix == InUsePrefix) { | 
 
 
 
 
 | 661 | (*pMyDisasm).Argument1.SegmentReg = FSReg; | 
 
 
 
 
 | 662 | (*pMyDisasm).Prefix.FSPrefix = InvalidPrefix; | 
 
 
 
 
 | 663 | } | 
 
 
 
 
 | 664 | else if ((*pMyDisasm).Prefix.GSPrefix == InUsePrefix) { | 
 
 
 
 
 | 665 | (*pMyDisasm).Argument1.SegmentReg = GSReg; | 
 
 
 
 
 | 666 | (*pMyDisasm).Prefix.GSPrefix = InvalidPrefix; | 
 
 
 
 
 | 667 | } | 
 
 
 
 
 | 668 | else if ((*pMyDisasm).Prefix.CSPrefix == InUsePrefix) { | 
 
 
 
 
 | 669 | (*pMyDisasm).Argument1.SegmentReg = CSReg; | 
 
 
 
 
 | 670 | (*pMyDisasm).Prefix.CSPrefix = InvalidPrefix; | 
 
 
 
 
 | 671 | } | 
 
 
 
 
 | 672 | else if ((*pMyDisasm).Prefix.DSPrefix == InUsePrefix) { | 
 
 
 
 
 | 673 | (*pMyDisasm).Argument1.SegmentReg = DSReg; | 
 
 
 
 
 | 674 | (*pMyDisasm).Prefix.DSPrefix = InvalidPrefix; | 
 
 
 
 
 | 675 | } | 
 
 
 
 
 | 676 | else if ((*pMyDisasm).Prefix.ESPrefix == InUsePrefix) { | 
 
 
 
 
 | 677 | (*pMyDisasm).Argument1.SegmentReg = ESReg; | 
 
 
 
 
 | 678 | (*pMyDisasm).Prefix.ESPrefix = InvalidPrefix; | 
 
 
 
 
 | 679 | } | 
 
 
 
 
 | 680 | else if ((*pMyDisasm).Prefix.SSPrefix == InUsePrefix) { | 
 
 
 
 
 | 681 | (*pMyDisasm).Argument1.SegmentReg = SSReg; | 
 
 
 
 
 | 682 | (*pMyDisasm).Prefix.SSPrefix = InvalidPrefix; | 
 
 
 
 
 | 683 | } | 
 
 
 
 
 | 684 | } | 
 
 
 
 
 | 685 | } | 
 
 
 
 
 | 686 | else { | 
 
 
 
 
 | 687 | (*pMyDisasm).Argument1.SegmentReg = DSReg; | 
 
 
 
 
 | 688 | /* ============= test if there is override */ | 
 
 
 
 
 | 689 | if ((*pMyDisasm).Prefix.FSPrefix == InUsePrefix) { | 
 
 
 
 
 | 690 | (*pMyDisasm).Argument1.SegmentReg = FSReg; | 
 
 
 
 
 | 691 | } | 
 
 
 
 
 | 692 | else if ((*pMyDisasm).Prefix.GSPrefix == InUsePrefix) { | 
 
 
 
 
 | 693 | (*pMyDisasm).Argument1.SegmentReg = GSReg; | 
 
 
 
 
 | 694 | } | 
 
 
 
 
 | 695 | else if ((*pMyDisasm).Prefix.CSPrefix == InUsePrefix) { | 
 
 
 
 
 | 696 | (*pMyDisasm).Argument1.SegmentReg = CSReg; | 
 
 
 
 
 | 697 | } | 
 
 
 
 
 | 698 | else if ((*pMyDisasm).Prefix.ESPrefix == InUsePrefix) { | 
 
 
 
 
 | 699 | (*pMyDisasm).Argument1.SegmentReg = ESReg; | 
 
 
 
 
 | 700 | } | 
 
 
 
 
 | 701 | else if ((*pMyDisasm).Prefix.SSPrefix == InUsePrefix) { | 
 
 
 
 
 | 702 | (*pMyDisasm).Argument1.SegmentReg = SSReg; | 
 
 
 
 
 | 703 | } | 
 
 
 
 
 | 704 | } | 
 
 
 
 
 | 705 | } | 
 
 
 
 
 | 706 |  | 
 
 
 
 
 | 707 | if ((*pMyDisasm).Argument2.ArgType & MEMORY_TYPE) { | 
 
 
 
 
 | 708 | if (((*pMyDisasm).Argument2.Memory.BaseRegister == REG4) || ((*pMyDisasm).Argument2.Memory.BaseRegister == REG5)) { | 
 
 
 
 
 | 709 | (*pMyDisasm).Argument2.SegmentReg = SSReg; | 
 
 
 
 
 | 710 | /* ========== override is invalid here */ | 
 
 
 
 
 | 711 | if ((*pMyDisasm).Prefix.FSPrefix == InUsePrefix) { | 
 
 
 
 
 | 712 | (*pMyDisasm).Argument2.SegmentReg = FSReg; | 
 
 
 
 
 | 713 | (*pMyDisasm).Prefix.FSPrefix = InvalidPrefix; | 
 
 
 
 
 | 714 | } | 
 
 
 
 
 | 715 | else if ((*pMyDisasm).Prefix.GSPrefix == InUsePrefix) { | 
 
 
 
 
 | 716 | (*pMyDisasm).Argument2.SegmentReg = GSReg; | 
 
 
 
 
 | 717 | (*pMyDisasm).Prefix.GSPrefix = InvalidPrefix; | 
 
 
 
 
 | 718 | } | 
 
 
 
 
 | 719 | else if ((*pMyDisasm).Prefix.CSPrefix == InUsePrefix) { | 
 
 
 
 
 | 720 | (*pMyDisasm).Argument2.SegmentReg = CSReg; | 
 
 
 
 
 | 721 | (*pMyDisasm).Prefix.CSPrefix = InvalidPrefix; | 
 
 
 
 
 | 722 | } | 
 
 
 
 
 | 723 | else if ((*pMyDisasm).Prefix.DSPrefix == InUsePrefix) { | 
 
 
 
 
 | 724 | (*pMyDisasm).Argument2.SegmentReg = DSReg; | 
 
 
 
 
 | 725 | (*pMyDisasm).Prefix.DSPrefix = InvalidPrefix; | 
 
 
 
 
 | 726 | } | 
 
 
 
 
 | 727 | else if ((*pMyDisasm).Prefix.ESPrefix == InUsePrefix) { | 
 
 
 
 
 | 728 | (*pMyDisasm).Argument2.SegmentReg = ESReg; | 
 
 
 
 
 | 729 | (*pMyDisasm).Prefix.ESPrefix = InvalidPrefix; | 
 
 
 
 
 | 730 | } | 
 
 
 
 
 | 731 | else if ((*pMyDisasm).Prefix.SSPrefix == InUsePrefix) { | 
 
 
 
 
 | 732 | (*pMyDisasm).Argument2.SegmentReg = SSReg; | 
 
 
 
 
 | 733 | (*pMyDisasm).Prefix.SSPrefix = InvalidPrefix; | 
 
 
 
 
 | 734 | } | 
 
 
 
 
 | 735 | } | 
 
 
 
 
 | 736 | else { | 
 
 
 
 
 | 737 | (*pMyDisasm).Argument2.SegmentReg = DSReg; | 
 
 
 
 
 | 738 | /* ============= test if there is override */ | 
 
 
 
 
 | 739 | if ((*pMyDisasm).Prefix.FSPrefix == InUsePrefix) { | 
 
 
 
 
 | 740 | (*pMyDisasm).Argument2.SegmentReg = FSReg; | 
 
 
 
 
 | 741 | } | 
 
 
 
 
 | 742 | else if ((*pMyDisasm).Prefix.GSPrefix == InUsePrefix) { | 
 
 
 
 
 | 743 | (*pMyDisasm).Argument2.SegmentReg = GSReg; | 
 
 
 
 
 | 744 | } | 
 
 
 
 
 | 745 | else if ((*pMyDisasm).Prefix.CSPrefix == InUsePrefix) { | 
 
 
 
 
 | 746 | (*pMyDisasm).Argument2.SegmentReg = CSReg; | 
 
 
 
 
 | 747 | } | 
 
 
 
 
 | 748 | else if ((*pMyDisasm).Prefix.ESPrefix == InUsePrefix) { | 
 
 
 
 
 | 749 | (*pMyDisasm).Argument2.SegmentReg = ESReg; | 
 
 
 
 
 | 750 | } | 
 
 
 
 
 | 751 | else if ((*pMyDisasm).Prefix.SSPrefix == InUsePrefix) { | 
 
 
 
 
 | 752 | (*pMyDisasm).Argument2.SegmentReg = SSReg; | 
 
 
 
 
 | 753 | } | 
 
 
 
 
 | 754 | } | 
 
 
 
 
 | 755 | } | 
 
 
 
 
 | 756 | } | 
 
 
 
 
 | 757 | } | 
 
 
 
 
 | 758 |  | 
 
 
 
 
 | 759 | #ifndef BEA_LIGHT_DISASSEMBLY | 
 
 
 
 
 | 760 | /* ==================================================================== | 
 
 
 
 
 | 761 | * | 
 
 
 
 
 | 762 | * ==================================================================== */ | 
 
 
 
 
 | 763 | void __bea_callspec__ BuildCompleteInstruction(PDISASM pMyDisasm) | 
 
 
 
 
 | 764 | { | 
 
 
 
 
 | 765 | size_t i = 0; | 
 
 
 
 
 | 766 | /* =============== Copy Instruction Mnemonic */ | 
 
 
 
 
 | 767 |  | 
 
 
 
 
 | 768 | if ((*pMyDisasm).Prefix.RepnePrefix == InUsePrefix) { | 
 
 
 
 
 | 769 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, "repne "); | 
 
 
 
 
 | 770 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 771 | } | 
 
 
 
 
 | 772 | if ((*pMyDisasm).Prefix.RepPrefix == InUsePrefix) { | 
 
 
 
 
 | 773 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, "rep "); | 
 
 
 
 
 | 774 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 775 | } | 
 
 
 
 
 | 776 | if ((*pMyDisasm).Prefix.LockPrefix == InUsePrefix) { | 
 
 
 
 
 | 777 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, "lock "); | 
 
 
 
 
 | 778 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 779 | } | 
 
 
 
 
 | 780 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, (char*) &(*pMyDisasm).Instruction.Mnemonic); | 
 
 
 
 
 | 781 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 782 |  | 
 
 
 
 
 | 783 | /* =============== if TAB = 1, add tabulation */ | 
 
 
 
 
 | 784 | if (GV.TAB_ == 1) { | 
 
 
 
 
 | 785 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, space_tab[i>10 ? 0 : 10-i]); | 
 
 
 
 
 | 786 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 787 | } | 
 
 
 
 
 | 788 | /* =============== if Arg1.IsMemoryType, add decoration-example == "dword ptr ds:[" */ | 
 
 
 
 
 | 789 | if ((GV.MemDecoration >0) && (GV.MemDecoration < 99)) { | 
 
 
 
 
 | 790 | if (GV.SYNTAX_ == NasmSyntax) { | 
 
 
 
 
 | 791 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, NasmPrefixes[GV.MemDecoration-1]); | 
 
 
 
 
 | 792 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 793 | if ((GV.SEGMENTREGS != 0) || (GV.SEGMENTFS != 0)){ | 
 
 
 
 
 | 794 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, "["); | 
 
 
 
 
 | 795 | i++; | 
 
 
 
 
 | 796 | if (GV.SEGMENTREGS != 0) { | 
 
 
 
 
 | 797 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, SegmentRegs[(*pMyDisasm).Argument1.SegmentReg]); | 
 
 
 
 
 | 798 | } | 
 
 
 
 
 | 799 | else { | 
 
 
 
 
 | 800 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, SegmentRegs[3]); | 
 
 
 
 
 | 801 | } | 
 
 
 
 
 | 802 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 803 | } | 
 
 
 
 
 | 804 | else { | 
 
 
 
 
 | 805 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, "["); | 
 
 
 
 
 | 806 | i++; | 
 
 
 
 
 | 807 | } | 
 
 
 
 
 | 808 | } | 
 
 
 
 
 | 809 | else { | 
 
 
 
 
 | 810 | if (GV.SYNTAX_ == MasmSyntax) { | 
 
 
 
 
 | 811 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, MasmPrefixes[GV.MemDecoration-1]); | 
 
 
 
 
 | 812 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 813 | } | 
 
 
 
 
 | 814 | else { | 
 
 
 
 
 | 815 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, GoAsmPrefixes[GV.MemDecoration-1]); | 
 
 
 
 
 | 816 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 817 | } | 
 
 
 
 
 | 818 | if ((GV.SEGMENTREGS != 0) || (GV.SEGMENTFS != 0)){ | 
 
 
 
 
 | 819 | if (GV.SEGMENTREGS != 0) { | 
 
 
 
 
 | 820 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, SegmentRegs[(*pMyDisasm).Argument1.SegmentReg]); | 
 
 
 
 
 | 821 | } | 
 
 
 
 
 | 822 | else { | 
 
 
 
 
 | 823 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, SegmentRegs[3]); | 
 
 
 
 
 | 824 | } | 
 
 
 
 
 | 825 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 826 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, "["); | 
 
 
 
 
 | 827 | i++; | 
 
 
 
 
 | 828 | } | 
 
 
 
 
 | 829 | else { | 
 
 
 
 
 | 830 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, "["); | 
 
 
 
 
 | 831 | i++; | 
 
 
 
 
 | 832 | } | 
 
 
 
 
 | 833 | } | 
 
 
 
 
 | 834 | /* =============== add Arg1.Mnemonic */ | 
 
 
 
 
 | 835 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, (char*) &(*pMyDisasm).Argument1.ArgMnemonic); | 
 
 
 
 
 | 836 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 837 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, "]"); | 
 
 
 
 
 | 838 | i++; | 
 
 
 
 
 | 839 | } | 
 
 
 
 
 | 840 | /* =============== add Arg1.Mnemonic */ | 
 
 
 
 
 | 841 | else { | 
 
 
 
 
 | 842 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, (char*) &(*pMyDisasm).Argument1.ArgMnemonic); | 
 
 
 
 
 | 843 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 844 | } | 
 
 
 
 
 | 845 |  | 
 
 
 
 
 | 846 | /* =============== if Arg2.Exists and Arg1.Exists , add"," */ | 
 
 
 
 
 | 847 | if (((UInt8)*((UInt8*) &(*pMyDisasm).Argument1.ArgMnemonic) != 0) && ((UInt8)*((UInt8*) &(*pMyDisasm).Argument2.ArgMnemonic) != 0)) { | 
 
 
 
 
 | 848 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, ", "); | 
 
 
 
 
 | 849 | i += 2; | 
 
 
 
 
 | 850 | } | 
 
 
 
 
 | 851 |  | 
 
 
 
 
 | 852 | /* =============== if Arg2.IsMemoryType, add decoration-example == "dword ptr ds:[" */ | 
 
 
 
 
 | 853 | if ((GV.MemDecoration >100) && (GV.MemDecoration < 199)) { | 
 
 
 
 
 | 854 | GV.MemDecoration -= 100; | 
 
 
 
 
 | 855 | if (GV.SYNTAX_ == NasmSyntax) { | 
 
 
 
 
 | 856 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, NasmPrefixes[GV.MemDecoration-1]); | 
 
 
 
 
 | 857 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 858 | if ((GV.SEGMENTREGS != 0) || (GV.SEGMENTFS != 0)){ | 
 
 
 
 
 | 859 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, "["); | 
 
 
 
 
 | 860 | i++; | 
 
 
 
 
 | 861 | if (GV.SEGMENTREGS != 0) { | 
 
 
 
 
 | 862 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, SegmentRegs[(*pMyDisasm).Argument2.SegmentReg]); | 
 
 
 
 
 | 863 | } | 
 
 
 
 
 | 864 | else { | 
 
 
 
 
 | 865 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, SegmentRegs[3]); | 
 
 
 
 
 | 866 | } | 
 
 
 
 
 | 867 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 868 | } | 
 
 
 
 
 | 869 | else { | 
 
 
 
 
 | 870 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, "["); | 
 
 
 
 
 | 871 | i++; | 
 
 
 
 
 | 872 | } | 
 
 
 
 
 | 873 | } | 
 
 
 
 
 | 874 | else { | 
 
 
 
 
 | 875 | if (GV.SYNTAX_ == MasmSyntax) { | 
 
 
 
 
 | 876 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, MasmPrefixes[GV.MemDecoration-1]); | 
 
 
 
 
 | 877 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 878 | } | 
 
 
 
 
 | 879 | else { | 
 
 
 
 
 | 880 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, GoAsmPrefixes[GV.MemDecoration-1]); | 
 
 
 
 
 | 881 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 882 | } | 
 
 
 
 
 | 883 | if ((GV.SEGMENTREGS != 0) || (GV.SEGMENTFS != 0)){ | 
 
 
 
 
 | 884 | if (GV.SEGMENTREGS != 0) { | 
 
 
 
 
 | 885 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, SegmentRegs[(*pMyDisasm).Argument2.SegmentReg]); | 
 
 
 
 
 | 886 | } | 
 
 
 
 
 | 887 | else { | 
 
 
 
 
 | 888 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, SegmentRegs[3]); | 
 
 
 
 
 | 889 | } | 
 
 
 
 
 | 890 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 891 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, "["); | 
 
 
 
 
 | 892 | i++; | 
 
 
 
 
 | 893 | } | 
 
 
 
 
 | 894 | else { | 
 
 
 
 
 | 895 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, "["); | 
 
 
 
 
 | 896 | i++; | 
 
 
 
 
 | 897 | } | 
 
 
 
 
 | 898 | } | 
 
 
 
 
 | 899 | /* =============== add Arg2.ArgMnemonic */ | 
 
 
 
 
 | 900 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, (char*) &(*pMyDisasm).Argument2.ArgMnemonic); | 
 
 
 
 
 | 901 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 902 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, "]"); | 
 
 
 
 
 | 903 | i++; | 
 
 
 
 
 | 904 | } | 
 
 
 
 
 | 905 | /* =============== add Arg2.ArgMnemonic */ | 
 
 
 
 
 | 906 | else { | 
 
 
 
 
 | 907 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, (char*) &(*pMyDisasm).Argument2.ArgMnemonic); | 
 
 
 
 
 | 908 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 909 | } | 
 
 
 
 
 | 910 |  | 
 
 
 
 
 | 911 |  | 
 
 
 
 
 | 912 | /* =============== if Arg3.Exists */ | 
 
 
 
 
 | 913 | if (GV.third_arg != 0) { | 
 
 
 
 
 | 914 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, ", "); | 
 
 
 
 
 | 915 | i += 2; | 
 
 
 
 
 | 916 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, (char*) &(*pMyDisasm).Argument3.ArgMnemonic); | 
 
 
 
 
 | 917 | } | 
 
 
 
 
 | 918 |  | 
 
 
 
 
 | 919 |  | 
 
 
 
 
 | 920 |  | 
 
 
 
 
 | 921 | } | 
 
 
 
 
 | 922 |  | 
 
 
 
 
 | 923 | /* ==================================================================== | 
 
 
 
 
 | 924 | * | 
 
 
 
 
 | 925 | * ==================================================================== */ | 
 
 
 
 
 | 926 | void __bea_callspec__ BuildCompleteInstructionATSyntax(PDISASM pMyDisasm) | 
 
 
 
 
 | 927 | { | 
 
 
 
 
 | 928 | size_t i = 0; | 
 
 
 
 
 | 929 | /* =============== Copy Instruction Mnemonic */ | 
 
 
 
 
 | 930 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr, (char*) &(*pMyDisasm).Instruction.Mnemonic); | 
 
 
 
 
 | 931 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 932 |  | 
 
 
 
 
 | 933 | /* =============== suffix the mnemonic */ | 
 
 
 
 
 | 934 | if (GV.MemDecoration != 0) { | 
 
 
 
 
 | 935 | if (GV.MemDecoration > 99) GV.MemDecoration -= 100; | 
 
 
 
 
 | 936 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i-1, ATSuffixes[GV.MemDecoration-1]); | 
 
 
 
 
 | 937 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 938 | } | 
 
 
 
 
 | 939 | else { | 
 
 
 
 
 | 940 | if ((*pMyDisasm).Argument1.ArgType != NO_ARGUMENT) { | 
 
 
 
 
 | 941 | if ((*pMyDisasm).Argument1.ArgSize == 8) { | 
 
 
 
 
 | 942 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i-1, ATSuffixes[0]); | 
 
 
 
 
 | 943 | } | 
 
 
 
 
 | 944 | else if ((*pMyDisasm).Argument1.ArgSize == 16) { | 
 
 
 
 
 | 945 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i-1, ATSuffixes[1]); | 
 
 
 
 
 | 946 | } | 
 
 
 
 
 | 947 | else if ((*pMyDisasm).Argument1.ArgSize == 32) { | 
 
 
 
 
 | 948 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i-1, ATSuffixes[2]); | 
 
 
 
 
 | 949 | } | 
 
 
 
 
 | 950 | else if ((*pMyDisasm).Argument1.ArgSize == 64) { | 
 
 
 
 
 | 951 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i-1, ATSuffixes[3]); | 
 
 
 
 
 | 952 | } | 
 
 
 
 
 | 953 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 954 | } | 
 
 
 
 
 | 955 | else if ((*pMyDisasm).Argument1.ArgType != NO_ARGUMENT) { | 
 
 
 
 
 | 956 | if ((*pMyDisasm).Argument1.ArgSize == 8) { | 
 
 
 
 
 | 957 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i-1, ATSuffixes[0]); | 
 
 
 
 
 | 958 | } | 
 
 
 
 
 | 959 | else if ((*pMyDisasm).Argument1.ArgSize == 16) { | 
 
 
 
 
 | 960 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i-1, ATSuffixes[1]); | 
 
 
 
 
 | 961 | } | 
 
 
 
 
 | 962 | else if ((*pMyDisasm).Argument1.ArgSize == 32) { | 
 
 
 
 
 | 963 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i-1, ATSuffixes[2]); | 
 
 
 
 
 | 964 | } | 
 
 
 
 
 | 965 | else if ((*pMyDisasm).Argument1.ArgSize == 64) { | 
 
 
 
 
 | 966 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i-1, ATSuffixes[3]); | 
 
 
 
 
 | 967 | } | 
 
 
 
 
 | 968 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 969 | } | 
 
 
 
 
 | 970 | } | 
 
 
 
 
 | 971 | /* =============== if TAB = 1, add tabulation */ | 
 
 
 
 
 | 972 | if (GV.TAB_ == 1) { | 
 
 
 
 
 | 973 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, space_tab[i>10 ? 0 : 10-i]); | 
 
 
 
 
 | 974 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 975 | } | 
 
 
 
 
 | 976 |  | 
 
 
 
 
 | 977 | /* =============== if Arg3.Exists, display it */ | 
 
 
 
 
 | 978 | if (GV.third_arg != 0) { | 
 
 
 
 
 | 979 | if ((*pMyDisasm).Argument3.ArgType & REGISTER_TYPE) { | 
 
 
 
 
 | 980 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, "%"); | 
 
 
 
 
 | 981 | i++; | 
 
 
 
 
 | 982 | } | 
 
 
 
 
 | 983 | else if ((*pMyDisasm).Argument3.ArgType & CONSTANT_TYPE) { | 
 
 
 
 
 | 984 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, "\x24"); | 
 
 
 
 
 | 985 | i++; | 
 
 
 
 
 | 986 | } | 
 
 
 
 
 | 987 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, (char*) &(*pMyDisasm).Argument3.ArgMnemonic); | 
 
 
 
 
 | 988 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 989 | } | 
 
 
 
 
 | 990 |  | 
 
 
 
 
 | 991 | /* =============== if Arg3.Exists and Arg2.Exists , display " , " */ | 
 
 
 
 
 | 992 | if ((GV.third_arg != 0) && (*((UInt8*) &(*pMyDisasm).Argument2.ArgMnemonic) != 0)) { | 
 
 
 
 
 | 993 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, ", "); | 
 
 
 
 
 | 994 | i += 2; | 
 
 
 
 
 | 995 | } | 
 
 
 
 
 | 996 |  | 
 
 
 
 
 | 997 | /* =============== if Arg2 exists, display it */ | 
 
 
 
 
 | 998 | if (*((UInt8*) &(*pMyDisasm).Argument2.ArgMnemonic) != 0) { | 
 
 
 
 
 | 999 | if ((*pMyDisasm).Argument2.ArgType & CONSTANT_TYPE) { | 
 
 
 
 
 | 1000 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, "\x24"); | 
 
 
 
 
 | 1001 | i++; | 
 
 
 
 
 | 1002 | } | 
 
 
 
 
 | 1003 | else { | 
 
 
 
 
 | 1004 | if ((*pMyDisasm).Instruction.BranchType != 0) { | 
 
 
 
 
 | 1005 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, "*"); | 
 
 
 
 
 | 1006 | i++; | 
 
 
 
 
 | 1007 | } | 
 
 
 
 
 | 1008 | if ((*pMyDisasm).Argument2.ArgType & REGISTER_TYPE) { | 
 
 
 
 
 | 1009 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, "%"); | 
 
 
 
 
 | 1010 | i++; | 
 
 
 
 
 | 1011 | } | 
 
 
 
 
 | 1012 | else if ((*pMyDisasm).Argument2.ArgType & CONSTANT_TYPE) { | 
 
 
 
 
 | 1013 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, "\x24"); | 
 
 
 
 
 | 1014 | i++; | 
 
 
 
 
 | 1015 | } | 
 
 
 
 
 | 1016 | else { | 
 
 
 
 
 | 1017 | if ((GV.SEGMENTREGS != 0) || (GV.SEGMENTFS != 0)){ | 
 
 
 
 
 | 1018 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, "%"); | 
 
 
 
 
 | 1019 | i++; | 
 
 
 
 
 | 1020 | if (GV.SEGMENTREGS != 0) { | 
 
 
 
 
 | 1021 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, SegmentRegs[(*pMyDisasm).Argument2.SegmentReg]); | 
 
 
 
 
 | 1022 | } | 
 
 
 
 
 | 1023 | else { | 
 
 
 
 
 | 1024 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, SegmentRegs[3]); | 
 
 
 
 
 | 1025 | } | 
 
 
 
 
 | 1026 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 1027 | } | 
 
 
 
 
 | 1028 | } | 
 
 
 
 
 | 1029 | } | 
 
 
 
 
 | 1030 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, (char*) &(*pMyDisasm).Argument2.ArgMnemonic); | 
 
 
 
 
 | 1031 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 1032 | } | 
 
 
 
 
 | 1033 |  | 
 
 
 
 
 | 1034 | /* =============== if Arg2.Exists and Arg1.Exists , display " , " */ | 
 
 
 
 
 | 1035 | if (((UInt8)*((UInt8*) &(*pMyDisasm).Argument1.ArgMnemonic) != 0) && ((UInt8)*((UInt8*) &(*pMyDisasm).Argument2.ArgMnemonic) != 0)) { | 
 
 
 
 
 | 1036 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, ", "); | 
 
 
 
 
 | 1037 | i += 2; | 
 
 
 
 
 | 1038 | } | 
 
 
 
 
 | 1039 |  | 
 
 
 
 
 | 1040 | /* =============== if Arg1 exists, display it */ | 
 
 
 
 
 | 1041 | if (*((UInt8*) &(*pMyDisasm).Argument1.ArgMnemonic) != 0) { | 
 
 
 
 
 | 1042 | if ((*pMyDisasm).Argument1.ArgType & CONSTANT_TYPE) { | 
 
 
 
 
 | 1043 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, "\x24"); | 
 
 
 
 
 | 1044 | i++; | 
 
 
 
 
 | 1045 | } | 
 
 
 
 
 | 1046 | else { | 
 
 
 
 
 | 1047 | if ((*pMyDisasm).Instruction.BranchType != 0) { | 
 
 
 
 
 | 1048 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, "*"); | 
 
 
 
 
 | 1049 | i++; | 
 
 
 
 
 | 1050 | } | 
 
 
 
 
 | 1051 | if ((*pMyDisasm).Argument1.ArgType & REGISTER_TYPE) { | 
 
 
 
 
 | 1052 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, "%"); | 
 
 
 
 
 | 1053 | i++; | 
 
 
 
 
 | 1054 | } | 
 
 
 
 
 | 1055 | else if ((*pMyDisasm).Argument1.ArgType & CONSTANT_TYPE) { | 
 
 
 
 
 | 1056 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, "\x24"); | 
 
 
 
 
 | 1057 | i++; | 
 
 
 
 
 | 1058 | } | 
 
 
 
 
 | 1059 | else { | 
 
 
 
 
 | 1060 | if ((GV.SEGMENTREGS != 0) || (GV.SEGMENTFS != 0)){ | 
 
 
 
 
 | 1061 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, "%"); | 
 
 
 
 
 | 1062 | i++; | 
 
 
 
 
 | 1063 | if (GV.SEGMENTREGS != 0) { | 
 
 
 
 
 | 1064 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, SegmentRegs[(*pMyDisasm).Argument1.SegmentReg]); | 
 
 
 
 
 | 1065 | } | 
 
 
 
 
 | 1066 | else { | 
 
 
 
 
 | 1067 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, SegmentRegs[3]); | 
 
 
 
 
 | 1068 | } | 
 
 
 
 
 | 1069 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 1070 | } | 
 
 
 
 
 | 1071 | } | 
 
 
 
 
 | 1072 | } | 
 
 
 
 
 | 1073 | (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, (char*) &(*pMyDisasm).Argument1.ArgMnemonic); | 
 
 
 
 
 | 1074 | i = strlen((char*) &(*pMyDisasm).CompleteInstr); | 
 
 
 
 
 | 1075 | } | 
 
 
 
 
 | 1076 | } | 
 
 
 
 
 | 1077 | #endif |