diff --git a/nemu/include/common.h b/nemu/include/common.h index ee3e429..fbffaa5 100644 --- a/nemu/include/common.h +++ b/nemu/include/common.h @@ -40,6 +40,7 @@ typedef MUXDEF(CONFIG_ISA64, int64_t, int32_t) sword_t; static const word_t WORD_T_MAX = MUXDEF(CONFIG_ISA64, UINT64_MAX, UINT32_MAX); static const sword_t SWORD_T_MAX = MUXDEF(CONFIG_ISA64, INT64_MAX, INT32_MAX); static const sword_t SWORD_T_MIN = MUXDEF(CONFIG_ISA64, INT64_MIN, INT32_MIN); +#define WORD_BYTES MUXDEF(CONFIG_ISA64, 8, 4) #define FMT_WORD MUXDEF(CONFIG_ISA64, "0x%016" PRIx64, "0x%08" PRIx32) typedef word_t vaddr_t; diff --git a/nemu/src/monitor/sdb/sdb.c b/nemu/src/monitor/sdb/sdb.c index 369784b..d1e00ec 100644 --- a/nemu/src/monitor/sdb/sdb.c +++ b/nemu/src/monitor/sdb/sdb.c @@ -189,10 +189,10 @@ static int cmd_x(char *args) { word_t addr = parse_expr(arg, &res); if (!res) goto wrong_usage; - printf("%d, %d\n", addr, MUXDEF(CONFIG_ISA64, 4, 8)); + printf("%d, %d\n", addr, WORD_BYTES); for (paddr_t paddr = addr; paddr < addr + n; - paddr += MUXDEF(CONFIG_ISA64, 4, 8)) { - word_t value = paddr_read(addr, MUXDEF(CONFIG_ISA64, 4, 8)); + paddr += WORD_BYTES) { + word_t value = paddr_read(addr, WORD_BYTES); printf(FMT_WORD "\n", value); } return 0;