GNIDA.mediana.get_seg C# (CSharp) Method

get_seg() static private method

static private get_seg ( INSTRUCTION &instr, int op_index, byte prefixes, DISMODE mode ) : void
instr INSTRUCTION
op_index int
prefixes byte
mode DISMODE
return void
        static void get_seg(ref INSTRUCTION instr, int op_index, byte[] prefixes, DISMODE mode)
        {
            if (prefixes[PREF_SEG_INDEX] == 0xFF)
            {
            if (mode == DISMODE.DISASSEMBLE_MODE_64)
            {
            instr.ops[op_index].value.addr.seg = SREG_CODE_CS;
            }
            else
            {
            if ( (instr.ops[op_index].value.addr.mod & ADDR_MOD_BASE)==0 )
            {
                instr.ops[op_index].value.addr.seg = SREG_CODE_DS;
            }
            else
            {
                if ((instr.ops[op_index].value.addr.bas != REG_CODE_BP) && (instr.ops[op_index].value.addr.bas != REG_CODE_SP))
                {
                    instr.ops[op_index].value.addr.seg = SREG_CODE_DS;
                }
                else
                {
                    instr .ops[op_index].value.addr.seg = SREG_CODE_SS;
                }
            }
            }
            }
            else
            {
            if (mode != DISMODE.DISASSEMBLE_MODE_64)
            {
            instr.ops[op_index].value.addr.seg = sregs[prefixes[PREF_SEG_INDEX]];
            }
            else
            {
            if (prefixes[PREF_SEG_INDEX] == PREF_FS_ID || prefixes[PREF_SEG_INDEX] == PREF_GS_ID)
            {
                instr.ops[op_index].value.addr.seg = sregs[prefixes[PREF_SEG_INDEX]];
            }
            else
            {
                instr.ops[op_index].value.addr.seg = SREG_CODE_CS;
            }
            }
            }
        }