修改解析部分代码:

static struct {
  const char *name;
  const char *description;
  int (*handler) (char *);
} cmd_table [] = {
  { "help", "Display informations about all supported commands", cmd_help },
  { "c", "Continue the execution of the program", cmd_c },
  { "q", "Exit NEMU", cmd_q },

  /* TODO: Add more commands */
  { "si", "excute n steps", cmd_si },
  { "info", "print infomatin", cmd_info },
  { "x", "print mem value",cmd_x },

};

修改执行函数:

static int cmd_si(char *args) {
  printf("cmd_si received, the arg is %s \\n",args);
  int n=0;
  sscanf(args, "%d", &n);
  printf("cmd_si received, the n is %d \\n",n);
  cpu_exec(n);
  printf("cmd_si received");
  return 0;
}

static int cmd_info(char *args) {
  printf("cmd_info received, the arg is %s \\n",args);
  if (strcmp(args,"r") == 0)
  {
    isa_reg_display();
    printf("cmd_info received and successd");
  }
  return 0;
}
static int cmd_x(char *args) {

  printf("cmd_info received, the arg is %s \\n",args);
  char *num = strtok(args, " ");

  int n=0;
  sscanf(num, "%d", &n);
  printf("cmd_info received, the num is %d \\n",n);

  char *addr = num + strlen(num) + 1;
  uint32_t addr_32 = 0;
  sscanf(addr, "%x", &addr_32);
  printf("cmd_info received, the addr is %x \\n", addr_32);

  word_t value = 0;

  for (int i = 0; i < n; i++)
  {
    value = paddr_read(addr_32+i,4);
    printf("%lx \\n",value);
  }
  return 0;
}

修改打印寄存器的函数

void isa_reg_display() {
    for (int i = 0; i < 32; i++)
    {
      printf("reg state %s is %ld \\n",regs[i],gpr(i));
    }
}