update PrintInt and change PutString to PutInt
This commit is contained in:
@@ -37,33 +37,7 @@ int SysCreate(char *filename)
|
||||
}
|
||||
|
||||
void SysPrintInt(int value) {
|
||||
static char zero[2] = "0";
|
||||
|
||||
if (value == 0) {
|
||||
kernel->synchConsoleOut->PutString(zero);
|
||||
return;
|
||||
}
|
||||
|
||||
char outputBuf[INT_BUF_LENGTH];
|
||||
bool isNeg = false;
|
||||
int curPos = INT_BUF_LENGTH;
|
||||
outputBuf[--curPos] = '\0';
|
||||
outputBuf[--curPos] = '\n';
|
||||
|
||||
if (value < 0) {
|
||||
isNeg = true;
|
||||
value = -value;
|
||||
}
|
||||
|
||||
while (value > 0) {
|
||||
outputBuf[--curPos] = '0' + (value % 10);
|
||||
value /= 10;
|
||||
}
|
||||
|
||||
if (isNeg)
|
||||
outputBuf[--curPos] = '-';
|
||||
|
||||
kernel->synchConsoleOut->PutString(&outputBuf[curPos]);
|
||||
kernel->interrupt->PrintInt(value);
|
||||
}
|
||||
|
||||
OpenFileId SysOpen(char *name) {
|
||||
|
||||
@@ -107,10 +107,10 @@ SynchConsoleOutput::PutChar(char ch)
|
||||
}
|
||||
|
||||
void
|
||||
SynchConsoleOutput::PutString(char *str)
|
||||
SynchConsoleOutput::PutInt(int value)
|
||||
{
|
||||
lock->Acquire();
|
||||
consoleOutput->PutString(str);
|
||||
consoleOutput->PutInt(value);
|
||||
waitFor->P();
|
||||
lock->Release();
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class SynchConsoleOutput : public CallBackObj {
|
||||
~SynchConsoleOutput();
|
||||
|
||||
void PutChar(char ch); // Write a character, waiting if necessary
|
||||
void PutString(char *ch);
|
||||
void PutInt(int value);
|
||||
|
||||
private:
|
||||
ConsoleOutput *consoleOutput;// the hardware display
|
||||
|
||||
Reference in New Issue
Block a user