(*InDos)++;
+ /* Save the value of SS:SP on entry in the PSP */
+ SEGMENT_TO_PSP(CurrentPsp)->LastStack =
+ MAKELONG(getSP() + (STACK_FLAGS + 1) * 2, getSS());
+
/* Check the value in the AH register */
switch (getAH())
{
Stack[STACK_FLAGS] |= EMULATOR_FLAG_CF;
}
+VOID WINAPI DosInt27h(LPWORD Stack)
+{
+ DosTerminateProcess(getCS(), 0, (getDX() + 0x0F) >> 4);
+}
+
VOID WINAPI DosFastConOut(LPWORD Stack)
{
/*
// RegisterDosInt32(0x22, DosInt22h ); // Termination
RegisterDosInt32(0x23, DosBreakInterrupt); // Ctrl-C / Ctrl-Break
// RegisterDosInt32(0x24, DosInt24h ); // Critical Error
+ RegisterDosInt32(0x27, DosInt27h ); // Terminate and Stay Resident
RegisterDosInt32(0x29, DosFastConOut ); // DOS 2+ Fast Console Output
RegisterDosInt32(0x2F, DosInt2Fh );
/* Check if this block was allocated by the process */
if (CurrentMcb->OwnerPsp == Psp)
{
- if (KeepResident == 0)
+ if (KeepResident)
{
- /* Free this entire block */
- DosFreeMemory(McbSegment + 1);
- }
- else if (KeepResident < CurrentMcb->Size)
- {
- /* Reduce the size of the block */
- DosResizeMemory(McbSegment + 1, KeepResident, NULL);
-
- /* No further paragraphs need to stay resident */
- KeepResident = 0;
+ /* Check if this is the PSP block and we should reduce its size */
+ if (McbSegment == Psp && KeepResident < CurrentMcb->Size)
+ {
+ /* Reduce the size of the block */
+ DosResizeMemory(McbSegment + 1, KeepResident, NULL);
+ break;
+ }
}
else
{
- /* Just reduce the amount of paragraphs we need to keep resident */
- KeepResident -= CurrentMcb->Size;
+ /* Free this entire block */
+ DosFreeMemory(McbSegment + 1);
}
}
/* Save the return code - Normal termination */
DosErrorLevel = MAKEWORD(ReturnCode, 0x00);
+ /* Restore the old stack */
+ setSS(HIWORD(SEGMENT_TO_PSP(CurrentPsp)->LastStack));
+ setSP(LOWORD(SEGMENT_TO_PSP(CurrentPsp)->LastStack));
+
/* Return control to the parent process */
CpuExecute(HIWORD(PspBlock->TerminateAddress),
LOWORD(PspBlock->TerminateAddress));