本文整理汇总了C++中Disassembler::SignedImmediateTransform方法的典型用法代码示例。如果您正苦于以下问题:C++ Disassembler::SignedImmediateTransform方法的具体用法?C++ Disassembler::SignedImmediateTransform怎么用?C++ Disassembler::SignedImmediateTransform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Disassembler
的用法示例。
在下文中一共展示了Disassembler::SignedImmediateTransform方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv)
{
if (argc != 2 ) {
fprintf(stderr, "Invalid input to [MIPSsim]\n");
printf("Usage: MIPSsim [input file name]\n");
return 1;
}
// FILE *fp = fopen(INPUTFILE, "r");
FILE *fp =fopen(argv[1], "r");
if(!fp){
fprintf(stderr, "Can't open input file");
return 1;
}
FILE *out_dis = fopen(OUTPUT_DIS, "w");
char line[INSTRUCTION_LENGTH + 1];
bool is_instruction = true;
int address = INITIAL_COM_ADDR;
char out[100];
Disassembler disassembler;
map<MEMORY,int> inital_mem;
MEMORY data_addr_start = -1;
MEMORY data_addr_end;
while(fscanf(fp,"%s\n",&line) != -1){
assert(strlen(line) == INSTRUCTION_LENGTH);
if(is_instruction){
char head[3] = {line[0],line[1]};
if(strcmp(head, "01") == 0){
disassembler.disassemble(1, address, line, out);
fprintf(out_dis, "%s\n",out);
//printf("%s\n", out);
if(strcmp(line, BREAK_CODE) == 0)
is_instruction = false;
}
else if (strcmp(head, "11") == 0)
{
disassembler.disassemble(2, address, line, out);
//printf("%s\n", out);
fprintf(out_dis, "%s\n",out);
}
}
else {
//printf("%s\t%d\t%d\n",line,address,disassembler.ImmediateTransform(line,INSTRUCTION_LENGTH));
int num = disassembler.SignedImmediateTransform(line,INSTRUCTION_LENGTH);
fprintf(out_dis,"%s\t%d\t%d\n",line,address, num);
inital_mem[address] = num;
if (data_addr_start == -1) {
data_addr_start = address;
}
}
address += 4;
}
data_addr_end = address - 4;
// for (map<MEMORY, char*>::iterator it = disassembler.result.begin(); it != disassembler.result.end(); it++) {
// printf("%d:%s\n", it->first, it->second);
// }
fclose(fp);
fclose(out_dis);
//simulation
Console console(INITIAL_COM_ADDR, data_addr_start/4,data_addr_end/4, OUTPUT_SIM);
map<MEMORY, int>::iterator it;
for (it = inital_mem.begin(); it != inital_mem.end(); it++) {
console.memory_set(it->first/4, it->second);
}
while (console.PC != FLAG_COM_ADDR) {
console.execute(disassembler.result[console.PC]);
// printf("%d\n", console.PC);
}
}