'Compare content of a memory region with a file
Usage:
MYNAME start end file'

def cmpmem(self, *arg):

    (start, end, filename) = normalize_argv(arg, 3)
    if (filename is None):
        self._missing_argument()
    try:
        buf = open(filename, 'rb').read()
    except:
        error_msg(('cannot    read    data    from    filename    %s' % filename))
        return
    result = peda.cmpmem(start, end, buf)
    if (result is None):
        warning_msg('failed    to    perform    comparison')
    elif (result == {}):
        msg('mem    and    filename    are    identical')
    else:
        msg(('---    mem:    %s    ->    %s' % (arg[0], arg[1])), 'green', 'bold')
        msg(('+++    filename:    %s' % arg[2]), 'blue', 'bold')
        for (addr, bytes_) in result.items():
            msg(('@@    0x%x    @@' % addr), 'red')
            line_1 = '-    '
            line_2 = '+    '
            for (mem_val, file_val) in bytes_:
                m_byte = ('%02X    ' % ord(mem_val))
                f_byte = ('%02X    ' % ord(file_val))
                if (mem_val == file_val):
                    line_1 += m_byte
                    line_2 += f_byte
                else:
                    line_1 += green(m_byte)
                    line_2 += blue(f_byte)
            msg(line_1)
            msg(line_2)
    return
