int paramIndex = line.indexOf(' '); // The space character after operators
if (paramIndex == -1) { // If no parameters, return
return -1;
}
boolean string = false;
for (int count = 0; count < line.length(); count++) { // For each character in line
if (line.charAt(count) == ' ' && !string) { // If space and not string
line = line.substring(0, count) + line.substring(count + 1, line.length()); // DESTROY
}
if (line.charAt(count) == '"') { // If quote now
string = !string; // Set string toggle
line = line.substring(0, count) + line.substring(count + 1, line.length()); // DESTROY
}
}
if (line.charAt(line.length() - 1) == ':') { // If label
for (int count = count2; count < lines.length; count++) { // For each line after label
if (lines[count] != null) { // If it isn't null
if (lines[count].equals("END")) { // If there's an END, go to that
return proc.checkshort(count);
} // If not, continue
}
}
return -1;
}
if (line.charAt(0) == ';') { // If comment only, return
return -1;
}
if (line.equals("END")) { // If comment only, return
return -1;
}
for (int count = 0; count < line.length(); count++) { // Remove comment part
if (line.charAt(count) == ';') {
line = line.substring(0, count);
}
}
for (int count = 0; count < line.length(); count++) { // Place register values
if (line.charAt(count) == '$') {
line = line.replace("$" + line.charAt(count + 1), "" + proc.getregister(line.charAt(count + 1)));
}
}
String operator = line.substring(0, paramIndex); // Comments and labels are removed, find operator
ArrayList<Integer> commas = new ArrayList<Integer>(); // Commas
ArrayList<String> params = new ArrayList<String>(); // Parameters
int paramAmount = 0; // Amount of parameters
commas.add(paramIndex); // Add paramIndex as comma
for (int count = 0; count < line.length(); count++) { // For each character in line
if (line.charAt(count) == ',') { // If comma
commas.add(count); // Add comma index
}
}
commas.add(line.length()); // Add line size as commas
// IMPORTANT: Commas must be in order in the ArrayList, that's why the line length is added after finding the parameter commas
for (int count = 0; count < commas.size() - 1; count++) { // For each comma
params.add(line.substring(commas.get(count), commas.get(count + 1)).replaceAll(",", "")); // Get parameter between commas, remove commas
paramAmount++;
}