I'm trying to write sub func for nachOS but when I combines it doesn't work. Don't know the reason.
Details:
In ../userprog/syscall.h
Add :
#define SC_Sub 11
int Sub(int a, int b);
In ../test/
.globl Sub
.ent Sub
Sub:
addiu $2,$0,SC_Sub
syscall
j $31
.end Sub
After that I write a sub.c:
#include "syscall.h"
int main()
{
int result;
result = Sub(100,99);
Halt();
}
in exception.cc: I try to catch exception:
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;
To combine I go to /code/gmake all
And I have error :(
../../../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
This is the folder of nachos . It doesn't contain the "bug" Sub func I write .
http://www.mediafire.com/?g3mnjxz4wdc
enter code here