code: def parse_operand(string, location, tokens):
      
      mod = " ".join(tokens.get("modifier", ""))
  
      if "immediate" in tokens:
          imm = parse_immediate("".join(tokens["immediate"]))
          size = modifier_size.get(mod, None)
  
          oprnd = X86ImmediateOperand(imm, size)
  
      if "register" in tokens:
          name = tokens["register"]
          size = arch_info.registers_size[tokens["register"]]
  
          oprnd = X86RegisterOperand(name, size)
  
      if "memory" in tokens:
          seg_reg = tokens.get("segment", None)
          base_reg = tokens.get("base", None)
          index_reg = tokens.get("index", None)
          scale_imm = int(tokens.get("scale", "0x1"), 16)
          displ_imm = int("".join(tokens.get("displacement", "0x0")), 16)
  
          oprnd = X86MemoryOperand(seg_reg, base_reg, index_reg, scale_imm, displ_imm)
  
      oprnd.modifier = mod
  
      if not oprnd.size and oprnd.modifier:
          oprnd.size = modifier_size[oprnd.modifier]
  
      return oprnd
docs: Parse an x86 instruction operand.