'Search memory for jmp/call reg instructions
Args:
- start: start address (Int)
- end: end address (Int)
- reg: register name (String)
Returns:
- list of (address(Int), instruction(String))'

def search_jmpcall(self, start, end, regname=None):

    result = []
    REG = {0: 'eax', 1: 'ecx', 2: 'edx', 3: 'ebx', 4: 'esp', 5: 'ebp', 6: 'esi', 7: 'edi'}
    P2REG = {0: '[eax]', 1: '[ecx]', 2: '[edx]', 3: '[ebx]', 6: '[esi]', 7: '[edi]'}
    OPCODE = {14: 'jmp', 13: 'call'}
    P2OPCODE = {1: 'call', 2: 'jmp'}
    JMPREG = [('\xff' + bytes_chr(i)) for i in range(224, 232)]
    JMPREG += [('\xff' + bytes_chr(i)) for i in range(32, 40)]
    CALLREG = [('\xff' + bytes_chr(i)) for i in range(208, 216)]
    CALLREG += [('\xff' + bytes_chr(i)) for i in range(16, 24)]
    JMPCALL = (JMPREG + CALLREG)
    if (regname is None):
        regname = ''
    regname = regname.lower()
    pattern = re.compile('|'.join(JMPCALL).replace('    ', '\\    '))
    mem = self.dumpmem(start, end)
    found = pattern.finditer(mem)
    (arch, bits) = self.getarch()
    for m in list(found):
        inst = ''
        addr = (start + m.start())
        opcode = codecs.encode(m.group()[1:2], 'hex')
        type = int(opcode[0:1], 16)
        reg = int(opcode[1:2], 16)
        if (type in OPCODE):
            inst = ((OPCODE[type] + '    ') + REG[reg])
        if ((type in P2OPCODE) and (reg in P2REG)):
            inst = ((P2OPCODE[type] + '    ') + P2REG[reg])
        if ((inst != '') and (regname[(-2):] in inst.split()[(-1)])):
            if (bits == 64):
                inst = inst.replace('e', 'r')
            result += [(addr, inst)]
    return result
