Rewrite GetInt syscall
This commit is contained in:
parent
5cccda4af3
commit
3609600063
4 changed files with 8 additions and 8 deletions
|
@ -70,13 +70,11 @@ void ConsoleDriver::PutInt(int n)
|
|||
delete [] buffer;
|
||||
}
|
||||
|
||||
int ConsoleDriver::GetInt()
|
||||
void ConsoleDriver::GetInt(int * n)
|
||||
{
|
||||
int n;
|
||||
char *buffer = new char[MAX_STRING_SIZE];
|
||||
GetString(buffer,MAX_STRING_SIZE);
|
||||
sscanf(buffer, "%d", &n);
|
||||
sscanf(buffer, "%d", n);
|
||||
delete [] buffer;
|
||||
return n;
|
||||
}
|
||||
#endif // CHANGED
|
||||
|
|
|
@ -19,7 +19,7 @@ class ConsoleDriver:dontcopythis {
|
|||
void PutString(const char *s); // Behaves like fputs(3S)
|
||||
void GetString(char *s, int n); // Behaves like fgets(3S)
|
||||
void PutInt(int n);
|
||||
int GetInt();
|
||||
void GetInt(int * n);
|
||||
private:
|
||||
Console *console;
|
||||
};
|
||||
|
|
|
@ -190,9 +190,11 @@ ExceptionHandler (ExceptionType which)
|
|||
case SC_GetInt:
|
||||
{
|
||||
DEBUG('s', "GetInt\n");
|
||||
int n = consoledriver->GetInt();
|
||||
int n;
|
||||
int addr = machine->ReadRegister(4);
|
||||
consoledriver->GetInt(&n);
|
||||
DEBUG('s', "Number entered: %d\n", n);
|
||||
machine->WriteRegister(2,n);
|
||||
machine->WriteMem(addr,sizeof(n),n);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -143,7 +143,7 @@ void PutString (char *s);
|
|||
char GetChar();
|
||||
void GetString(char *s, int n );
|
||||
void PutInt(int n);
|
||||
int GetInt();
|
||||
void GetInt( int * n);
|
||||
|
||||
#endif // CHANGED
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue