Line 75... |
Line 75... |
else if (*str == '{') {olevel++;}
|
else if (*str == '{') {olevel++;}
|
else if (strncmp ("eval_operand", str, 12) == 0) {
|
else if (strncmp ("eval_operand", str, 12) == 0) {
|
replace = 1; str += 12;
|
replace = 1; str += 12;
|
} else if (strncmp ("set_operand", str, 11) == 0) {
|
} else if (strncmp ("set_operand", str, 11) == 0) {
|
replace = 2; str += 11;
|
replace = 2; str += 11;
|
|
} else if (strncmp ("get_operand", str, 11) == 0) {
|
|
replace = 10; str += 11;
|
}
|
}
|
if (replace) {
|
if (replace) {
|
int width, oper;
|
int width, oper;
|
|
if (replace < 10) {
|
sscanf (str, "%i(%i", &width, &oper);
|
sscanf (str, "%i(%i", &width, &oper);
|
while (*str && *str != '(') str++;
|
while (*str && *str != '(') str++;
|
while (*str && *str != ',') str++;
|
while (*str && *str != ',') str++;
|
str++;
|
str++;
|
|
} else {
|
|
sscanf (str, "(%i)", &oper);
|
|
while (*str && *str != ')') str++;
|
|
}
|
if (replace == 1) {
|
if (replace == 1) {
|
if (op[oper] & OPTYPE_DIS) {
|
if (op[oper] & OPTYPE_DIS) {
|
fprintf (fo, "eval_mem%i (%c", width, 'a' + oper);
|
fprintf (fo, "eval_mem%i (%c", width, 'a' + oper);
|
} else {
|
} else {
|
if (op[oper] & OPTYPE_REG) {
|
if (op[oper] & OPTYPE_REG) {
|
fprintf (fo, "(reg[%c]", 'a' + oper);
|
fprintf (fo, "(reg[%c]", 'a' + oper);
|
} else {
|
} else {
|
fprintf (fo, "(%c", 'a' + oper);
|
fprintf (fo, "(%c", 'a' + oper);
|
}
|
}
|
}
|
}
|
} else {
|
} else if (replace == 2) {
|
op[oper] |= OPTYPE_DST;
|
op[oper] |= OPTYPE_DST;
|
if (op[oper] & OPTYPE_DIS) {
|
if (op[oper] & OPTYPE_DIS) {
|
fprintf (fo, "set_mem%i(%c,", width, 'a' + oper);
|
fprintf (fo, "set_mem%i(%c,", width, 'a' + oper);
|
} else if (op[oper] & OPTYPE_REG) {
|
} else if (op[oper] & OPTYPE_REG) {
|
fprintf (fo, "reg[%c] = (", 'a' + oper);
|
fprintf (fo, "reg[%c] = (", 'a' + oper);
|
Line 104... |
Line 111... |
} else {
|
} else {
|
fprintf (stderr, "Invalid operand type.\n");
|
fprintf (stderr, "Invalid operand type.\n");
|
exit (1);
|
exit (1);
|
}
|
}
|
while (*str != ',') str = replace_operands (fo, str) + 1;
|
while (*str != ',') str = replace_operands (fo, str) + 1;
|
|
} else {
|
|
fprintf (fo, "%c", 'a' + oper);
|
}
|
}
|
|
if (replace < 10) {
|
while (*str && *str != ')') str++;
|
while (*str && *str != ')') str++;
|
if (op[oper] & OPTYPE_DIS) fprintf (fo, ", &breakpoint)");
|
if (op[oper] & OPTYPE_DIS) fprintf (fo, ", &breakpoint)");
|
else fprintf (fo, ")");
|
else fprintf (fo, ")");
|
|
}
|
} else {
|
} else {
|
fputc (*str, fo);
|
fputc (*str, fo);
|
}
|
}
|
return str;
|
return str;
|
}
|
}
|