Skip to content

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

@mmjwxbc

Description

@mmjwxbc
#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文件中声明是外部变量,它也可以成功编译,这是编译器的原因吗

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions