Line 1... |
Line 1... |
|
|
#include <stdio.h>
|
#include <stdio.h>
|
#include <stdlib.h>
|
#include <stdlib.h>
|
|
#include <string.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
|
#define RELOC_CONSTH 4
|
#define RELOC_CONSTH 4
|
|
|
|
#define EX_NONE "None"
|
|
#define EX_NA_N "N"
|
|
#define EX_NA_A "A"
|
|
#define EX_RANGE "Range Exception"
|
|
#define EX_TRAP "Trap Exception"
|
|
#define EX_TLB "TLB miss"
|
|
#define EX_PAGE "Page fault"
|
|
#define EX_BUSER "Bus error"
|
|
|
#include "opcode/or32.h"
|
#include "opcode/or32.h"
|
#include "or1k_isadesc.h"
|
#include "or1k_isadesc.h"
|
|
|
/* types of data in encoding field. */
|
/* types of data in encoding field. */
|
typedef enum { opcode, reserved, operand } encfld_types;
|
typedef enum { opcode, reserved, operand } encfld_types;
|
Line 43... |
Line 53... |
*output++ = ']';
|
*output++ = ']';
|
*output++ = '}';
|
*output++ = '}';
|
} else if (*input == '%') {
|
} else if (*input == '%') {
|
*output++ = '\\';
|
*output++ = '\\';
|
*output++ = '%';
|
*output++ = '%';
|
} else if (*input == '&') {
|
|
*output++ = '\\';
|
|
*output++ = '&';
|
|
} else if (*input == '\\') {
|
} else if (*input == '\\') {
|
*output++ = '\\';
|
*output++ = '\\';
|
*output++ = '\\';
|
*output++ = '\\';
|
} else if (*input == '_') {
|
} else if (*input == '_') {
|
*output++ = '\\';
|
*output++ = '\\';
|
Line 61... |
Line 68... |
*output++ = 'd';
|
*output++ = 'd';
|
*output++ = 'e';
|
*output++ = 'e';
|
*output++ = 'n';
|
*output++ = 'n';
|
*output++ = 't';
|
*output++ = 't';
|
*output++ = ' ';
|
*output++ = ' ';
|
|
} else if (*input == '<') {
|
|
*output++ = '$';
|
|
*output++ = '<';
|
|
*output++ = '$';
|
} else
|
} else
|
*output++ = *input;
|
*output++ = *input;
|
input++;
|
input++;
|
}
|
}
|
*output = '\0';
|
*output = '\0';
|
}
|
}
|
|
void eliminate_slash(char *input, char *output)
|
|
{
|
|
while (*input != '\0') {
|
|
if (*input == '\\') {
|
|
*output++ = '\n';
|
|
*output++ = '\n';
|
|
}
|
|
else
|
|
*output++ = *input;
|
|
input++;
|
|
}
|
|
*output = '\0';
|
|
}
|
void eliminate_crcr(char *input, char *output)
|
void eliminate_crcr(char *input, char *output)
|
{
|
{
|
while (*input != '\0') {
|
while (*input != '\0') {
|
if (*input == '\\') {
|
if (*input == '\\') {
|
/* *output++ = '{';
|
/* *output++ = '{';
|
Line 145... |
Line 168... |
/* 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 transform_except(char *input, char *output)
|
|
{
|
|
char *pTmp = NULL;
|
|
|
|
pTmp = (char*)strtok(input, "\\");
|
|
while (pTmp) {
|
|
if (strcmp(pTmp, EX_RANGE) == 0) *output++ = 'R';
|
|
if (strcmp(pTmp, EX_NA_N) == 0) *output++ = '-';
|
|
if (strcmp(pTmp, EX_NA_A) == 0) *output++ = '-';
|
|
if (strcmp(pTmp, EX_TRAP) == 0) *output++ = 'T';
|
|
if (strcmp(pTmp, EX_TLB) == 0) *output++ = 'M';
|
|
if (strcmp(pTmp, EX_PAGE) == 0) *output++ = 'P';
|
|
if (strcmp(pTmp, EX_BUSER) == 0) *output++ = 'B';
|
|
|
|
pTmp = (char*)strtok(NULL, "\\");
|
|
}
|
|
*output = '\0';
|
|
}
|
|
|
|
void print_reference(int newtable, struct or32_opcode *insn, struct or1k_isa *info)
|
|
{
|
|
char tmp[2000];
|
|
char tmp2[2000];
|
|
int i,j;
|
|
|
|
if (newtable) {
|
|
printf("\\footnotesize\n");
|
|
printf("\\begin{longtable}[t]{|p{2.3cm}|p{2cm}|p{6cm}|p{6cm}|p{0.6cm}|}\n");
|
|
printf("\\hline\n");
|
|
printf("\\normalsize ISN &\n");
|
|
printf("\\normalsize Name &\n");
|
|
printf("\\normalsize Description &\n");
|
|
/*printf("\\normalsize Usage &\n");*/
|
|
printf("\\normalsize Action &\n");
|
|
printf("\\normalsize ex. \\\\\n");
|
|
printf("\\hline\n");
|
|
printf("\\endhead\n");
|
|
printf("\\hline\n");
|
|
printf("\\endfoot\n");
|
|
}
|
|
else {
|
|
transform_tex(insn->name, tmp);
|
|
transform_tex(insn->args, tmp2);
|
|
printf("{\n\n\\raggedright %s %s} &\n", tmp, tmp2);
|
|
transform_tex(info->title, tmp);
|
|
printf("\\raggedright %s &\n", tmp);
|
|
transform_tex(info->desc, tmp);
|
|
printf("%s &\n", tmp);
|
|
/*
|
|
transform_tex(insn->args, tmp);
|
|
transform_tex(insn->name, tmp2);
|
|
printf("%s %s &\n", tmp2, tmp);
|
|
*/
|
|
eliminate_slash(info->oper32, tmp);
|
|
transform_tex(tmp, tmp2);
|
|
printf("{\n");
|
|
printf("%s} &\n", tmp2);
|
|
/*
|
|
transform_tex(info->oper64, tmp);
|
|
printf("{\n");
|
|
printf("%s} &\n", tmp);
|
|
*/
|
|
tmp[0] = 0;
|
|
strcpy(tmp2, info->except);
|
|
transform_except(tmp2, tmp);
|
|
printf("%s \\\\\n", tmp);
|
|
|
|
printf("\\hline\n");
|
|
}
|
|
}
|
|
|
void print_summary(int newtable, struct or32_opcode *insn, struct or1k_isa *info)
|
void print_summary(int newtable, struct or32_opcode *insn, struct or1k_isa *info)
|
{
|
{
|
char tmp[2000];
|
char tmp[2000];
|
char tmp2[2000];
|
char tmp2[2000];
|
Line 495... |
Line 588... |
}
|
}
|
|
|
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
{
|
{
|
int i, j;
|
int i, j;
|
int summary = 0;
|
int mode = 0;
|
long classes = -1;
|
long classes = -1;
|
|
|
if ((argc >= 2) && (strcmp(argv[1], "-s") == 0))
|
if ((argc >= 2) && (strcmp(argv[1], "-s") == 0))
|
summary = 1;
|
mode = 1;
|
|
|
|
if ((argc >= 2) && (strcmp(argv[1], "-r") == 0))
|
|
mode = 2;
|
|
|
if (argc == 3)
|
if (argc == 3)
|
classes = strtol(argv[2], NULL, 0);
|
classes = strtol(argv[2], NULL, 0);
|
|
|
cross_ref_check();
|
cross_ref_check();
|
printf("\n\\begin{document}\n\\thispagestyle{empty}\\hfil\\vfil\\newpage\\vspace{50mm}\n");
|
switch (mode) {
|
|
case 0:
|
|
case 1:
|
|
printf("\n\\begin{document}\n\\vspace{50mm}");
|
|
break;
|
|
case 2:
|
|
printf("\\documentclass[10pt,a4paper,onepage]{article}\n");
|
|
printf("\\setlength{\\topmargin}{-0.5in}\n");
|
|
printf("\\setlength{\\textheight}{9.5in}\n");
|
|
printf("\\setlength{\\evensidemargin}{-1.5cm}\n");
|
|
printf("\\setlength{\\oddsidemargin}{-1.5cm}\n");
|
|
printf("\\usepackage{longtable}\n");
|
|
printf("\\begin{document}\n");
|
|
printf("\\pagestyle{empty}\n");
|
|
printf("\\hspace{-3cm}\\noindent\n");
|
|
}
|
|
|
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 \n \n", or1k_order[i].title);
|
j= 0;
|
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)
|
if (((1 << info.desc->class) & classes) == 0)
|
continue;
|
continue;
|
|
|
if (summary) {
|
switch (mode) {
|
|
case 1:
|
decode(info.opcode);
|
decode(info.opcode);
|
if (j && ((j % 100) == 0))
|
if (j && ((j % 100) == 0))
|
printf("\\end{tabular}\\par}\n");
|
printf("\\end{tabular}\\par}\n");
|
print_summary(((j % 100) == 0), info.opcode, info.desc);
|
print_summary(((j % 100) == 0), info.opcode, info.desc);
|
} else {
|
break;
|
|
case 2:
|
|
decode(info.opcode);
|
|
print_reference((j == 0), info.opcode, info.desc);
|
|
break;
|
|
case 0:
|
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++;
|
j++;
|
}
|
}
|
if (summary && j)
|
if ( (mode == 1) && j)
|
printf("\\end{tabular}\\par}\n");
|
printf("\\end{tabular}\\par}\n");
|
|
if ( (mode == 2) && j)
|
|
printf("\\end{longtable}\n");
|
}
|
}
|
|
|
printf("\n\\newpage\\thispagestyle{empty}\\hfil\\vfil\\end{document}\n");
|
printf("\n\\end{document}\n");
|
return 0;
|
return 0;
|
}
|
}
|
|
|
No newline at end of file
|
No newline at end of file
|