Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为什么在monitor.c文件当中没有包含cpu.h的文件,cpu也没有在monitor.c文件中声明是外部变量,它也可以成功编译,这是编译器的原因吗 #120

Open
mmjwxbc opened this issue Feb 25, 2025 · 2 comments

Comments

@mmjwxbc
Copy link

mmjwxbc commented Feb 25, 2025

#include <isa.h>
#include <memory/paddr.h>

// this is not consistent with uint8_t
// but it is ok since we do not access the array directly
static const uint32_t img [] = {
  0x00000297,  // auipc t0,0
  0x00028823,  // sb  zero,16(t0)
  0x0102c503,  // lbu a0,16(t0)
  0x00100073,  // ebreak (used as nemu_trap)
  0xdeadbeef,  // some data
};

static void restart() {
  /* Set the initial program counter. */
  cpu.pc = RESET_VECTOR;

  /* The zero register is always 0. */
  cpu.gpr[0] = 0;
}

为什么在monitor.c文件当中没有包含cpu.h的文件,cpu也没有在monitor.c文件中声明是外部变量,它也可以成功编译,这是编译器的原因吗

@sashimi-yzh
Copy link
Contributor

有声明的, 建议再仔细阅读代码.

@mmjwxbc
Copy link
Author

mmjwxbc commented Feb 26, 2025

谢谢,我看错文件了,我以为是在monitor.c文件中使用了cpu这个变量

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants