我正在尝试为 nachOS 编写子函数,但是当我组合它时它不起作用。不知道原因。详细信息:在 ../userprog/syscall.h
添加:
#define SC_Sub 11
int Sub(int a, int b);
在../test/
.globl Sub
.ent Sub
Sub:
addiu $2,$0,SC_Sub
syscall
j $31
.end Sub
之后我写了一个 sub.c:
#include "syscall.h"
int main()
{
int result;
result = Sub(100,99);
Halt();
}
在 exception.cc 中:我尝试捕获异常:
case SC_Sub:
op1 = machine->ReadRegister(4);
op2 = machine->ReadRegister(5);
result = op1 - op2;
printf("op1:%d\n",op1);
printf("op2:%d\n",op2);
printf("result:%d\n",result);
machine->WriteRegister(2,result);
machine->WriteRegister(PCReg,machine->ReadRegister(PCReg)+4);
break;
结合我去/code/gmake all
我有错误:(
../../../gnu-decstation-ultrix/decstation-ultrix/2.95.3/gcc -B../../../gnu-decstation-ultrix/ -T script -N sub.o -o sub
../../../gnu-decstation-ultrix/decstation-ultrix/2.95.3/ld: cannot open crt0.o: No such file or directory
make[1]: *** [sub] Error 1
make[1]: Leaving directory `/home/nxqd/Desktop/nachos-3.4/code/test'
gmake: *** [all] Error 2
这是 nachos 的文件夹。它不包含我编写的“错误”子函数。
http://www.mediafire.com/?g3mnjxz4wdc
enter code here