Tag: lc3

无法从C中的文件中读取字符串并将其作为lc3解析器进行操作

我想创建一个程序,扫描文件的内容: 1283 5105 lc3中两条指令的hex代码: 添加r1,r2,r3 和r0,r4,r5 我希望我的程序读取此文件并在屏幕上打印两个相应的说明,有人可以告诉我它有什么问题 #include #include #include int main(int argc, char *argv[]) { FILE *file; char hexString[5]; int dr, sr1, sr2, instruction; file = fopen(argv[1], “r”); while (fscanf(file, “%d”, hexString) != EOF){ unsigned short int instruction = (unsigned short)strtol(hexString, NULL, 16); if (instruction >> 12 == 0b0001){ //op code is ADD dr […]