code: def dump(self, tofile=None, width=16, withpadding=False):
          if not isinstance(width,int) or width < 1:
              raise ValueError('width must be a positive integer.')
          width = int(width)
          if tofile is None:
              tofile = sys.stdout
          if self.start_addr is not None:
              cs = self.start_addr.get('CS')
              ip = self.start_addr.get('IP')
              eip = self.start_addr.get('EIP')
              if eip is not None and cs is None and ip is None:
                  tofile.write('EIP = 0x%08X\n' % eip)
              elif eip is None and cs is not None and ip is not None:
                  tofile.write('CS = 0x%04X, IP = 0x%04X\n' % (cs, ip))
              else:
                  tofile.write('start_addr = %r\n' % start_addr)
          addresses = dict_keys(self._buf)
          if addresses:
              addresses.sort()
              minaddr = addresses[0]
              maxaddr = addresses[-1]
              startaddr = (minaddr // width) * width
              endaddr = ((maxaddr // width) + 1) * width
              maxdigits = max(len(hex(endaddr)) - 2, 4)
              templa = '%%0%dX' % maxdigits
              rangewidth = range_l(width)
              if withpadding:
                  pad = self.padding
              else:
                  pad = None
              for i in range_g(startaddr, endaddr, width):
                  tofile.write(templa % i)
                  tofile.write(' ')
                  s = []
                  for j in rangewidth:
                      x = self._buf.get(i+j, pad)
                      if x is not None:
                          tofile.write(' %02X' % x)
                          if 32 <= x < 127:
                              s.append(chr(x))
                          else:
                              s.append('.')
                      else:
                          tofile.write(' --')
                          s.append(' ')
                  tofile.write('  |' + ''.join(s) + '|\n')