Line 1... |
Line 1... |
|
|
#include <stdio.h>
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
#define NO_RELOC 20
|
#define NO_RELOC 20
|
#define RELOC_32 1
|
#define RELOC_32 1
|
#define RELOC_8 2
|
#define RELOC_8 2
|
#define RELOC_CONST 3
|
#define RELOC_CONST 3
|
Line 64... |
Line 65... |
input++;
|
input++;
|
}
|
}
|
*output = '\0';
|
*output = '\0';
|
}
|
}
|
|
|
|
void eliminate_crcr(char *input, char *output)
|
|
{
|
|
while (*input != '\0') {
|
|
if (*input == '\\') {
|
|
/* *output++ = '{';
|
|
*output++ = '[';*/
|
|
} else
|
|
*output++ = *input;
|
|
input++;
|
|
}
|
|
*output = '\0';
|
|
}
|
|
|
void print_encoding()
|
void print_encoding()
|
{
|
{
|
int i, j;
|
int i, j;
|
|
|
printf("\\vspace{10mm}\n");
|
printf("\\vspace{10mm}\n");
|
Line 128... |
Line 142... |
/* printf("{|c|}{\\textcolor{white}{XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX ");
|
/* printf("{|c|}{\\textcolor{white}{XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX ");
|
printf("XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX}}\\\\\n");*/
|
printf("XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX}}\\\\\n");*/
|
printf("\\end{tabular}\\par}\n");
|
printf("\\end{tabular}\\par}\n");
|
}
|
}
|
|
|
|
|
|
void print_summary(int newtable, struct or32_opcode *insn, struct or1k_isa *info)
|
|
{
|
|
char tmp[2000];
|
|
char tmp2[2000];
|
|
int i, j, k;
|
|
|
|
|
|
if (newtable) {
|
|
|
|
printf("{\\centering \\begin{tabular}{|l");
|
|
|
|
/* organization of the table */
|
|
for(i = 1; i <= decoded.fldcnt; i++) {
|
|
printf("|");
|
|
for(j = 0; j < decoded.field[i].bitsize; j++)
|
|
if (j == 0)
|
|
printf("l");
|
|
else if (j+1 == decoded.field[i].bitsize)
|
|
printf("r");
|
|
else
|
|
printf("c");
|
|
}
|
|
printf("|}\n");
|
|
printf("Insn&\n");
|
|
|
|
/* print first row of the table */
|
|
for(i = decoded.insn_size - 1; i > 0; i--)
|
|
if (decoded.bitpos[i])
|
|
printf("%d&\n", i);
|
|
else
|
|
printf("%d&\n");
|
|
printf("0\\\\\n");
|
|
}
|
|
else {
|
|
printf("\\multicolumn{1}{|c}{}&\n");
|
|
k = 31;
|
|
for(i = 1; i <= decoded.fldcnt; i++) {
|
|
for(j = 0; j < decoded.field[i].bitsize; j++) {
|
|
if (j == 0)
|
|
printf("\\multicolumn{1}{|l");
|
|
else if (j+1 == decoded.field[i].bitsize)
|
|
printf("\\multicolumn{1}{|r");
|
|
else
|
|
printf("\\multicolumn{1}{|c");
|
|
if (k)
|
|
printf("}{%d}&\n", k);
|
|
else
|
|
printf("}{%d}\\\\\n", k);
|
|
k--;
|
|
}
|
|
}
|
|
}
|
|
|
|
printf("\\multicolumn{1}{|l|}{");
|
|
transform_tex(info->name, tmp);
|
|
printf("%s}&\n", tmp);
|
|
|
|
/* print second row of the table */
|
|
for(i = 1; i <= decoded.fldcnt; i++) {
|
|
if (decoded.field[i].type == opcode) {
|
|
printf("\\multicolumn{%d}{", decoded.field[i].bitsize);
|
|
printf("%s", (i == 1 ? "|":""));
|
|
printf("c|}{opcode 0x%x}", decoded.field[i].value);
|
|
} else if (decoded.field[i].type == operand) {
|
|
printf("\\multicolumn{%d}{", decoded.field[i].bitsize);
|
|
printf("%s", (i == 1 ? "|":""));
|
|
printf("c|}{%c}", decoded.field[i].value);
|
|
} else if (decoded.field[i].type == reserved) {
|
|
printf("\\multicolumn{%d}{", decoded.field[i].bitsize);
|
|
printf("%s", (i == 1 ? "|":""));
|
|
printf("c|}{reserved}", decoded.field[i].value);
|
|
}
|
|
if (i == decoded.fldcnt)
|
|
printf("\\\\\n");
|
|
else
|
|
printf("&\n");
|
|
}
|
|
printf("\n");
|
|
|
|
/* print third row of the table */
|
|
/* printf("\\multicolumn{10}{|c|}{");
|
|
transform_tex(info->name, tmp);
|
|
printf("%s ", tmp);
|
|
transform_tex(insn->args, tmp);
|
|
printf("%s}&\n", tmp);
|
|
printf("\\multicolumn{22}{c|}{");
|
|
eliminate_crcr(info->desc, tmp2);
|
|
transform_tex(tmp2, tmp);
|
|
printf("%s}\\\\\n", tmp); */
|
|
|
|
|
|
}
|
|
|
void decode(struct or32_opcode *insn)
|
void decode(struct or32_opcode *insn)
|
{
|
{
|
int opc_pos = 0;
|
int opc_pos = 0;
|
char *enc;
|
char *enc;
|
encfld_types last;
|
encfld_types last;
|
Line 381... |
Line 489... |
printf("\\end{tabular}\\par}\n");
|
printf("\\end{tabular}\\par}\n");
|
|
|
printf("\n");
|
printf("\n");
|
}
|
}
|
|
|
int main()
|
int main(int argc, char *argv[])
|
{
|
{
|
int i;
|
int i, j;
|
|
int summary = 0;
|
|
long classes = -1;
|
|
|
|
if ((argc >= 2) && (strcmp(argv[1], "-s") == 0))
|
|
summary = 1;
|
|
|
|
if (argc == 3)
|
|
classes = strtol(argv[2], NULL, 0);
|
|
|
cross_ref_check();
|
cross_ref_check();
|
printf("\n\\begin{document}\n\\vspace{50mm}");
|
printf("\n\\begin{document}\n\\vspace{50mm}");
|
|
|
for(i = 0; strlen(or1k_order[i].title); i++) {
|
for(i = 0; strlen(or1k_order[i].title); i++) {
|
printf("\\section{%s}\n", or1k_order[i].title);
|
printf("\\section{%s}\n", or1k_order[i].title);
|
|
j= 0;
|
|
|
while (get_or1k_isa(or1k_order[i].classes, &info)) {
|
while (get_or1k_isa(or1k_order[i].classes, &info)) {
|
|
if (((1 << info.desc->class) & classes) == 0)
|
|
continue;
|
|
|
|
if (summary) {
|
|
decode(info.opcode);
|
|
if (j && ((j % 100) == 0))
|
|
printf("\\end{tabular}\\par}\n");
|
|
print_summary(((j % 100) == 0), info.opcode, info.desc);
|
|
} else {
|
print_header(info.opcode, info.desc);
|
print_header(info.opcode, info.desc);
|
decode(info.opcode);
|
decode(info.opcode);
|
print_encoding();
|
print_encoding();
|
print_body(info.opcode, info.desc);
|
print_body(info.opcode, info.desc);
|
}
|
}
|
|
j++;
|
|
}
|
|
if (summary && j)
|
|
printf("\\end{tabular}\\par}\n");
|
}
|
}
|
|
|
printf("\n\\end{document}\n");
|
printf("\n\\end{document}\n");
|
return 0;
|
return 0;
|
}
|
}
|