diff --git a/src/nachos-3.4/code/test/halt b/src/nachos-3.4/code/test/halt index b6c7190..8d75a65 100644 Binary files a/src/nachos-3.4/code/test/halt and b/src/nachos-3.4/code/test/halt differ diff --git a/src/nachos-3.4/code/test/matmult b/src/nachos-3.4/code/test/matmult index 1020242..93ae4ed 100644 Binary files a/src/nachos-3.4/code/test/matmult and b/src/nachos-3.4/code/test/matmult differ diff --git a/src/nachos-3.4/code/test/shell b/src/nachos-3.4/code/test/shell index 1640db6..b9af934 100644 Binary files a/src/nachos-3.4/code/test/shell and b/src/nachos-3.4/code/test/shell differ diff --git a/src/nachos-3.4/code/test/sort b/src/nachos-3.4/code/test/sort index 4ecebb8..6c05091 100644 Binary files a/src/nachos-3.4/code/test/sort and b/src/nachos-3.4/code/test/sort differ diff --git a/src/nachos-3.4/code/test/start.s b/src/nachos-3.4/code/test/start.s index 71c883e..d2a8e23 100644 --- a/src/nachos-3.4/code/test/start.s +++ b/src/nachos-3.4/code/test/start.s @@ -130,6 +130,59 @@ Yield: j $31 .end Yield +/************** New inserted code here ****************/ + + .globl ReadInt + .ent ReadInt +ReadInt: + addiu $2,$0,SC_ReadInt + syscall + j $31 + .end ReadInt + + .glob PrintInt + .ent PrintInt +PrintInt: + addiu $2,$0,SC_PrintInt + syscall + j $31 + .end PrintInt + + .glob ReadChar + .ent ReadChar +ReadChar: + addiu $2,$0,SC_ReadChar + syscall + j $31 + .end ReadChar + + .glob PrintChar + .ent PrintChar +PrintChar: + addiu $2,$0,SC_PrintChar + syscall + j $31 + .end PrintChar + + .glob ReadString + .ent ReadString +ReadString: + addiu $2,$0,SC_ReadString + syscall + j $31 + .end ReadString + + .glob PrintString + .ent PrintString +PrintString: + addiu $2,$0,SC_PrintString + syscall + j $31 + .end PrintString + + +/************** Break of new inserted code ************/ + /* dummy function to keep gcc happy */ .globl __main .ent __main diff --git a/src/nachos-3.4/code/userprog/.syscall.h.swp b/src/nachos-3.4/code/userprog/.syscall.h.swp new file mode 100644 index 0000000..9d55a5a Binary files /dev/null and b/src/nachos-3.4/code/userprog/.syscall.h.swp differ diff --git a/src/nachos-3.4/code/userprog/exception.cc b/src/nachos-3.4/code/userprog/exception.cc index 71773a0..f270605 100644 --- a/src/nachos-3.4/code/userprog/exception.cc +++ b/src/nachos-3.4/code/userprog/exception.cc @@ -92,17 +92,27 @@ ExceptionHandler(ExceptionType which) case SC_Halt: interrupt->Halt(); break; + case SC_ReadInt: + break; + case SC_PrintInt: + break; + case SC_ReadChar: + break; + case SC_PrintChar: + break; + case SC_ReadString: + break; + case SC_PrintString: + break; default: printf("Unexpected user mode exception %d %d\n", which, type); ASSERT(FALSE); break; - } break; default: printf("Unexpected user mode exception %d %d\n", which, type); ASSERT(FALSE); break; - } } diff --git a/src/nachos-3.4/code/userprog/syscall.h b/src/nachos-3.4/code/userprog/syscall.h index f9d9979..b6fda0d 100644 --- a/src/nachos-3.4/code/userprog/syscall.h +++ b/src/nachos-3.4/code/userprog/syscall.h @@ -30,6 +30,26 @@ #define SC_Fork 9 #define SC_Yield 10 +/******************** New inserted code here *******************/ +/* Our new defined system calls, included: + * SC_ReadInt: read an integer from console + * SC_PrintInt: print an integer to console + * SC_ReadChar: read a character from console + * SC_PrintChar: print a character to console + * SC_ReadString: read a string from console + * SC_PrintString: write a string to console + */ + +#define SC_ReadInt 11 +#define SC_PrintInt 12 +#define SC_ReadChar 13 +#define SC_PrintChar 14 +#define SC_ReadString 15 +#define SC_PrintString 16 + +/******************* Break of new inserted code ***************/ + + #ifndef IN_ASM /* The system call interface. These are the operations the Nachos @@ -124,6 +144,22 @@ void Fork(void (*func)()); */ void Yield(); +/*********************** New inserted code here *****************/ + +int ReadInt(); + +void PrintInt(); + +char ReadChar(); + +void PrintChar(); + +void ReadString(char buffer[], int length); + +void PrintString(char buffer[]); + +/*********************** Break of new inserted code *************/ + #endif /* IN_ASM */ #endif /* SYSCALL_H */