小编xSl*_*ing的帖子

ASM:“ mov”的内存引用过多

还是我,我的idt.S文件(使用gcc编译的Intel语法)出现了新问题。当我尝试编译以下代码时:

load_idt:
        mov edx, (esp + 4) ; On this line
        lidt (edx)
        sti
        ret
Run Code Online (Sandbox Code Playgroud)

我收到一个我真的不知道如何解决的错误:

Error: too many memory references for `mov'
Run Code Online (Sandbox Code Playgroud)

x86 assembly gcc osdev intel-syntax

4
推荐指数
1
解决办法
492
查看次数

为什么我的代码出现分段错误?

当我用GCC编译我的代码然后运行它时,当我在代码中调用函数时,它会打印出:“分段错误(内核已转储)”。

我尝试在Google上搜索解决方案。

这是我当前的代码:

char ** saveLevelPositions() {
  int x, y;
  char ** positions;
  positions = malloc(sizeof(char *) * 25);

  for (y = 0; y < 25; y++) {
    positions[y] = malloc(sizeof(char) * 100);

    for (x = 0; x < 100; x++) {
      positions[x][y] = mvinch(y, x);
    }
  }

  return positions;
}
Run Code Online (Sandbox Code Playgroud)

我希望该功能能够正常运行,并且只会给出细分错误。

编辑:有关上下文的一些信息,这是GitHub项目的链接:https : //github.com/xslendix/rogue

c malloc segmentation-fault

0
推荐指数
1
解决办法
64
查看次数

标签 统计

assembly ×1

c ×1

gcc ×1

intel-syntax ×1

malloc ×1

osdev ×1

segmentation-fault ×1

x86 ×1