- char description[64];
- char archtag[16];
- int archbits;
-
- if (currentLine[0] == '#')
- continue;
- memset(opcode, 0, 8);
- if (sscanf(currentLine, "%15s %15s %15s \"%[^\"]\" %15s",
- opcode, mnemonic, format, description, archtag) == 5) {
- if (strcmp(archtag, "esaonly") == 0)
- archbits = ARCHBITS_ESAONLY;
- else if (strcmp(archtag, "esa") == 0)
- archbits = ARCHBITS_ESA;
- else if (strcmp(archtag, "esame") == 0)
- archbits = ARCHBITS_ESAME;
- else
- archbits = 0;
- insertOpcode(opcode, mnemonic, format, archbits);
- } else
- fprintf(stderr, "Couldn't scan line %s\n", currentLine);
+ char description[80];
+ char cpu_string[16];
+ char modes_string[16];
+ char flags_string[80];
+ int min_cpu;
+ int mode_bits;
+ int flag_bits;
+ int num_matched;
+ char *str;
+
+ if (currentLine[0] == '#' || currentLine[0] == '\n')
+ continue;
+ memset (opcode, 0, 8);
+ num_matched =
+ sscanf (currentLine, "%15s %15s %15s \"%79[^\"]\" %15s %15s %79[^\n]",
+ opcode, mnemonic, format, description,
+ cpu_string, modes_string, flags_string);
+ if (num_matched != 6 && num_matched != 7)
+ {
+ fprintf (stderr, "Couldn't scan line %s\n", currentLine);
+ exit (1);
+ }
+
+ if (strcmp (cpu_string, "g5") == 0
+ || strcmp (cpu_string, "arch3") == 0)
+ min_cpu = S390_OPCODE_G5;
+ else if (strcmp (cpu_string, "g6") == 0)
+ min_cpu = S390_OPCODE_G6;
+ else if (strcmp (cpu_string, "z900") == 0
+ || strcmp (cpu_string, "arch5") == 0)
+ min_cpu = S390_OPCODE_Z900;
+ else if (strcmp (cpu_string, "z990") == 0
+ || strcmp (cpu_string, "arch6") == 0)
+ min_cpu = S390_OPCODE_Z990;
+ else if (strcmp (cpu_string, "z9-109") == 0)
+ min_cpu = S390_OPCODE_Z9_109;
+ else if (strcmp (cpu_string, "z9-ec") == 0
+ || strcmp (cpu_string, "arch7") == 0)
+ min_cpu = S390_OPCODE_Z9_EC;
+ else if (strcmp (cpu_string, "z10") == 0
+ || strcmp (cpu_string, "arch8") == 0)
+ min_cpu = S390_OPCODE_Z10;
+ else if (strcmp (cpu_string, "z196") == 0
+ || strcmp (cpu_string, "arch9") == 0)
+ min_cpu = S390_OPCODE_Z196;
+ else if (strcmp (cpu_string, "zEC12") == 0
+ || strcmp (cpu_string, "arch10") == 0)
+ min_cpu = S390_OPCODE_ZEC12;
+ else if (strcmp (cpu_string, "z13") == 0
+ || strcmp (cpu_string, "arch11") == 0)
+ min_cpu = S390_OPCODE_Z13;
+ else if (strcmp (cpu_string, "z14") == 0
+ || strcmp (cpu_string, "arch12") == 0)
+ min_cpu = S390_OPCODE_ARCH12;
+ else if (strcmp (cpu_string, "z15") == 0
+ || strcmp (cpu_string, "arch13") == 0)
+ min_cpu = S390_OPCODE_ARCH13;
+ else {
+ fprintf (stderr, "Couldn't parse cpu string %s\n", cpu_string);
+ exit (1);
+ }
+
+ str = modes_string;
+ mode_bits = 0;
+ do {
+ if (strncmp (str, "esa", 3) == 0
+ && (str[3] == 0 || str[3] == ',')) {
+ mode_bits |= 1 << S390_OPCODE_ESA;
+ str += 3;
+ } else if (strncmp (str, "zarch", 5) == 0
+ && (str[5] == 0 || str[5] == ',')) {
+ mode_bits |= 1 << S390_OPCODE_ZARCH;
+ str += 5;
+ } else {
+ fprintf (stderr, "Couldn't parse modes string %s\n",
+ modes_string);
+ exit (1);
+ }
+ if (*str == ',')
+ str++;
+ } while (*str != 0);
+
+ flag_bits = 0;
+
+ if (num_matched == 7)
+ {
+ str = flags_string;
+ do {
+ if (strncmp (str, "optparm", 7) == 0
+ && (str[7] == 0 || str[7] == ',')) {
+ flag_bits |= S390_INSTR_FLAG_OPTPARM;
+ str += 7;
+ } else if (strncmp (str, "optparm2", 8) == 0
+ && (str[8] == 0 || str[8] == ',')) {
+ flag_bits |= S390_INSTR_FLAG_OPTPARM2;
+ str += 8;
+ } else if (strncmp (str, "htm", 3) == 0
+ && (str[3] == 0 || str[3] == ',')) {
+ flag_bits |= S390_INSTR_FLAG_HTM;
+ str += 3;
+ } else if (strncmp (str, "vx", 2) == 0
+ && (str[2] == 0 || str[2] == ',')) {
+ flag_bits |= S390_INSTR_FLAG_VX;
+ str += 2;
+ } else {
+ fprintf (stderr, "Couldn't parse flags string %s\n",
+ flags_string);
+ exit (1);
+ }
+ if (*str == ',')
+ str++;
+ } while (*str != 0);
+ }
+ insertExpandedMnemonic (opcode, mnemonic, format, min_cpu, mode_bits, flag_bits);