[Back to MEMORY SWAG index] [Back to Main SWAG index] [Original]
{*******************************}
{* ®¤ã«ì ¯à®á⮣® *}
{* ®£®¯à®æ¥áᮣ® ®¨â®à *}
{* VSTasks v 1.01 *}
{* ¤«ï Turbo Pascal ver 7.0 *}
{* (c) Copyright VVSsoft Group *}
{*******************************}
{$F+$S-}
{ v.1.01 --- ¯® áࢥ¨î á ¢¥àᨥ© 1.0 ¨á¯à¢«¥ ¢ë室 ¨§ ¯à®æ¥áá- }
{ ¯à®æ¥¤ãàë ¯® ¤®á⨦¥¨î END. ¯à¥¤ë¤ã饩 ¢¥àᨨ 㦮 }
{ ¡ë«® ®¡ï§â¥«ì® ¯¥à¥¤ END-® á⢨âì HaltCurrentTask, }
{ ¨ç¥ á¨á⥠"¢¨á«". ¥¯¥àì ¯à¨ ¤®á⨦¥¨¨ ª®æ }
{ ¯à®æ¥áá-¯à®æ¥¤ãàë ¢â®â® ¯à®æ¥áá §ªà뢥âáï ... }
{ }
{ (c) VVSsoft Group. ®®®¢ «¤¨¨à. }
Unit VSTasks;
interface {--------------------------------------------}
Type
PTaskRec =^TTaskRec; { ---- ®¯¨áâ¥«ì ¯à®æ¥áá -----}
TTaskRec =
record
NumProc : word; { 㨪«ìë© ®¥à ¯à®æ¥áá }
Next : PTaskRec; { á«¥¤ãî騩 ®¯¨áâ¥«ì ¯à®æ¥áá }
OrignSP, { §ç¥¨¥ SP ¤«ï ¢®§¢àâ }
OrignSS : word; { §ç¥¨¥ SS ¤«ï ¢®§¢àâ }
Stack : pointer; { 㪧⥫ì á⥪ ¯à®æ¥áá }
SSize : word; { ৥à á⥪ ¯à®æ¥áá }
end;
Const
CountTask : word = 0; { ¢á¥£® §à¥£¨áâà¨à®¢® ¯à®æ¥áᮢ }
PCurTask : PTaskRec = Nil; { 㪧⥫ì ⥪ãéãî ¢ë¯®«ï¥ãî §¤çã }
HeadStack : PTaskRec = Nil; { ãª§â¥«ì £®«®¢ã á⥪ }
UniNumber : word = 1; { 㨪«ìë© ®¥à ¤«ï ᮧ¤¢¥®£® ¯à®æ¥áá }
CurTask : word = 0; { ®¥à ⥪ã饣® ¯à®æ¥áá }
{----------------- ª®¤ë ®è¨¡®ª ॣ¨áâà樨 ¯à®æ¥áá --------------}
vstMemoryLow = 1; { ¥â ¯ï⨠¤«ï ᮧ¤¨ï á⥪ ¯à®æ¥áá }
vstEmptyStackTask = 2; { ¥â §à¥£¨áâà¨à®¢ëå ¯à®æ¥áᮢ }
vstMAXLimitProc = 3; { ᫨誮 ®£® ¯à®æ¥áᮢ }
Var
TaskError : byte; { ¯®á«¥¤ïï ®è¨¡ª }
procedure StartTasks;
{--- §¯ã᪠¯à®æ¥áᮢ ¢ë¯®«¥¨¥ ---}
procedure SwithTasks; far;
{--- ¯¥à¥ª«î票¥ ¥¦¤ã §¤ç¨ ---}
function RegisterTask(TaskPoint : pointer; SizeStack: word): word;
{--- ॣ¨áâàæ¨ï §¤ç¨ ¥á«¨ - 0, â® ®è¨¡ª ¢ ¯¥à¥¥®© TaskError ---}
{--- ¢®§¢àé¥â ®¥à §à¥£¨áâà¨à®¢®£® ¯à®æ¥áá ---}
procedure HaltCurrentTask;
{--- áï⨥ ⥪ã饩 §¤ç¨ ---}
procedure HaltAllTasks;
{--- áï⨥ ¢á¥å §¤ç ---}
implementation
{----------------------------------------------------------------}
Var
OriginalSS, { ¤à¥á ®à¨£¨«ì®£® á⥪ ¯à®£àë }
OriginalSP : word; { ãª§â¥«ì ®à¨£¨«ì®£® á⥪ ¯à®£àë }
PDopPoint : PTaskRec; { ¤®¯®«¨â¥«ìë© ãª§â¥«ì }
{------- ¯¥à¥®¯à¥¤¥«¥ë¥ äãªæ¨¨ ¤«ï à¡®âë á BASM® ---------}
function mMemAvail: word;
Var M: longint;
T: record
L,H: word;
end;
begin
M:=MaxAvail;
If M>$FFFF then mMemAvail:=$FFFF
else
begin
Move(M,T,SizeOf(longint));
mMemAvail:=T.L;
end;
end;
function mGetMem(S:word): pointer;
Var P:pointer;
begin
GetMem(P,S);
mGetMem:=P;
end;
procedure mFreeMem(P: pointer;S: word);
Var D: pointer;
begin
D:=P;
FreeMem(P,S);
end;
procedure StartTasks; assembler;
{ --- §¯ã᪠¯à®æ¥áᮢ ¢ë¯®«¥¨¥ --- }
asm
{ 1) ¯®¨âì ¢ á⥪¥ ॣ¨áâàë;
2) ¯®¨âì ¢ á⥪¥ â®çªã ¢ë室 ¨§ ¥¥¤¦¥à ¯à®æ¥áᮢ;
3) ®åà¨âì ॣ¨áâàë SS ¨ SP ¤«ï ®á®¢®© ¯à®£àë;
4) ©â¨ ¯¥à¢ë© ¯à®æ¥áá ¤«ï §¯ãáª;
5) ¥à¥ãá⮢¨âì ¢á¥ â¥ªã騥 ¯¥à¥¥ë¥;
6) ¥à¥ãá⮢¨âì SS:SP ¨ ¢®áá⮢¨âì ॣ¨áâàë;
7) ந§¢¥á⨠"¤«¨ë© ¢ë室" (ç¨â© ¢å®¤) RETF ¢ ¯à®æ¥áá;
8) ®á«¥ ¢®§¢àâ ¢ â®çªã ¢ë室 ¨§ ¯à®æ¥áá, ¢®áá⮢¨âì
ॣ¨áâàë. }
{----------------------------------------------------}
PUSH BP { á®åàï¥ à¥£¨áâàë }
PUSH DI {}
PUSH SI {}
PUSH DS {}
PUSH ES {}
LEA DI, @ExitPoint { ¢ DI á¥é¥¨¥ ¢ë室 }
PUSH CS { á®åàï¥ â®çªã ¢ë室 ¨§ }
PUSH DI { ¯à®æ¥áᮢ }
MOV OriginalSS, SS { á®åàï¥ SS:SP }
MOV OriginalSP, SP {}
MOV AX, CountTask { ¥á«¨ ¥â §à¥£¨áâà¨à®¢. §¤ç }
XOR BX, BX {}
CMP AX, BX {}
JE @Exit { ®ç¥à¥¤ì ¯à®æ¥áᮢ ¯ãáâ }
MOV DI, HeadStack.word[0] { ¢ ES:DI 㪧⥫ì }
MOV ES, HeadStack.word[2] { ®¯¨áâ¥«ì ¯à®æ¥áá }
MOV AX, ES:[DI] { ®¥à ⥪ã饣® ¯à®æ¥áá }
MOV CurTask, AX {}
MOV PCurTask.word[0], DI { PCurTask ࢮ ¯¥à¢®ã }
MOV PCurTask.word[2], ES { ¯à®æ¥ááã }
CLI {}
MOV SS, ES:[DI+8] { ¯¥à¥ãá⮢ª á⥪ }
MOV SP, ES:[DI+6] {}
STI {}
POP BP { ¢®á⢫¨¢¥ ॣ¨áâàë }
POP ES { ¯à®æ¥áá }
POP DS {}
RETF { "¢ë室" ¢ ¯à®æ¥áá }
@Exit: POP AX { ¤®á⥠¨§ á⥪ ¥ã¦®¥ }
POP AX {}
MOV AL, vstEmptyStackTask {}
MOV TaskError, AL {}
@ExitPoint: POP ES { ¢®áá⢫¨¢¥ ॣ¨áâàë }
POP DS {}
POP SI {}
POP DI {}
POP BP {}
end;
procedure SwithTasks; assembler;
{ --- ¯¥à¥ª«î票¥ ¥¦¤ã §¤ç¨ --- }
asm
{ 1) C®å२¥ ¢á¥å ॣ¨áâ஢ ⥪ã饣® ¯à®æ¥áá [DS,ES,BP];
2) 宦¤¥¨¥ á«¥¤ãî饣® ¯à®æ¥áá ¤«ï ¨á¯®«¥¨ï;
3) C®å२¥ 㪧⥫¥© SS:SP á⥪ ⥪ã饣® ¯à®æ¥áá;
4) §¥¥¨¥ 㪧⥫¥© SS:SP á⥪ ¤«ï ¯®á«¥¤ãî饣® ¯à®æ¥áá;
5) §¥¥¨¥ ¢á¥å ⥪ãé¨å ¯¥à¥¥ëå;
6) ®áá⮢«¥¨¥ ॣ¨áâ஢ ¤«ï ®¢®£® ¯à®æ¥áá [BP,ES,DS]; }
{-----------------------------------------------------------------}
PUSH DS { á®å२¥ ॣ¨áâ஢ áâண® }
PUSH ES { ¯à®æ¥áá }
PUSH BP {}
MOV AX, SEG @Data { ãá⮢ª ᥣ¥â ¤ëå }
MOV DS, AX {}
MOV ES, PCurTask.word[2] { ¢ ES:DI ãª§â¥«ì ®¯¨á⥫ì}
MOV DI, PCurTask.word[0] { ⥪ã饣® ¯à®æ¥áá }
MOV ES:[DI+8], SS { á®åàï¥ SS:SP ¢ ⥪ãé¥ }
MOV ES:[DI+6], SP { ®¯¨á⥫¥ ¯à®æ¥áá }
MOV BX, ES:[DI+4] { ¢ BX:SI 㪧⥫ì á«¥¤ãî騩}
MOV SI, ES:[DI+2] { ¯à®æ¥áá }
MOV ES, BX { 㦥 ¢ ES:SI }
XOR AX, AX { ¯à®¢¥àª Nil }
CMP BX, AX {}
JNE @Next { ¥á«¨ ¥ Nil-ª ®¡à¡®âª¥ }
CMP SI, AX {}
JNE @Next {}
MOV ES, HeadStack.word[2] { ¨ç¥ á«¥¤ãî騩 - ç«ìë© }
MOV SI, HeadStack.word[0] { ®¯¨á⥫ì HeadStack }
@Next: MOV PCurTask.word[2], ES { ¥ï¥ 㪧⥫ì ⥪ã騩 }
MOV PCurTask.word[0], SI { ®¯¨á⥫ì }
MOV AX, ES:[SI] { ¥ï¥ ®¥à ⥪ã饣® ¯à®æ¥áá}
MOV CurTask, AX {}
CLI {}
MOV SS, ES:[SI+8] { ¥ï¥ 㪧⥫¨ á⥪ }
MOV SP, ES:[SI+6] { ¯®¤ ®¢ë© ¯à®æ¥áá }
STI {}
POP BP { ¢®áá⮢«¥¨¥ ॣ¨áâ஢ }
POP ES { ®¢®£® ¯à®æ¥áá }
POP DS {}
end;
function RegisterTask(TaskPoint: pointer; SizeStack: word): word; assembler;
{ --- ॣ¨áâàæ¨ï §¤ç¨ --- }
{ ¥á«¨ ¢®é§¢àé¥ 0, â® ®è¨¡ª ¢ ¯¥à¥¥®© TaskError }
asm
{ 1) ®§¤¨¥ ¢ ¯ï⨠®¯¨áâ¥«ï ¯à®æ¥áá;
2) 뤥«¥¨¥ ¯ï⨠¯®¤ á⥪ ¯à®æ¥áá;
3) 宦¤¥¨¥ 㨪«ì®£® ®¯¨áâ¥«ï ¯à®æ¥áá;
4) ¢ï§ª ®¯¨áâ¥«ï ®¢®£® ¯à®æ¥áá ¢ 楯®çªã ¯à®æ¥áᮢ;
5) ®å२¥ ¢ á⥪¥ ¯à®æ¥áá ¤à¥á ¢å®¤ ¢ ¯à®æ¥áá ¨ ॣ¨áâ஢;
6) ë室 ¢ ®á®¢ãî ¯à®£àã. }
{---------------------------------------------------------}
XOR AX, AX {}
NOT AX {}
CMP AX, UniNumber {}
JE @TooManyProc { ᫨誮 ®£® ¯à®æ¥áᮢ }
CALL mMemAvail { ¯à®¢¥àª «¨ç¨ï ¯ï⨠}
MOV BX, SizeStack {}
CMP AX, BX {}
JB @LowMem { ¥á«¨ ¯ï⨠¥â }
PUSH BX {}
CALL mGetMem { ¢ DX:AX 㪧⥫ì á⥪ }
PUSH DX {}
PUSH AX {}
CALL mMemAvail { ¯ïâì ¤«ï TTaskRec }
MOV CX, TYPE TTaskRec {}
CMP AX, CX {}
JB @LowMemAndFree { ¥á«¨ ¥ å¢â¨â }
PUSH CX { £®â®¢¨ ¯à¥âàë }
CALL mGetMem { ¢ë¤¥«ï¥ ¯ïâì }
PUSH ES {}
MOV ES, DX { ES:DI 㪧뢥⠮¯¨á⥫ì }
MOV DI, AX { ®¢®£® ¯à®æ¥áá }
MOV AX, UniNumber { ¯à¨á¢¨¢¥ 㨪«ìë© ®¥à }
MOV ES:[DI], AX {}
INC AX { ¨ªà¥¥â UniNumber }
MOV UniNumber, AX {}
MOV BX, HeadStack.word[0] { 㪧⥫ì á«¥¤ãî騩 }
MOV CX, HeadStack.word[2] { ®¯¨á⥫ì = HeadStack }
MOV ES:[DI+2], BX {}
MOV ES:[DI+4], CX {}
POP CX { ¢ CX §ç¥¨¥ ES }
POP AX { ¢ AX á¥é¥¨¥ á⥪ }
MOV ES:[DI+10], AX { á¥é¥¨¥ 㪧⥫ï Stack }
MOV BX, SizeStack { á®åàï¥ à§¥à á⥪ ¢ }
MOV ES:[DI+14], BX { SSize ⥪ã饣® ®¯¨á⥫ï }
ADD AX, BX { ¢ëç¨á«ï¥ §ç¥¨¥ SP }
JNC @NotCorrect { ¥á«¨ ª®à४æ¨ï ¥ 㦠}
XOR AX, AX {}
NOT AX { AX=$FFFF }
@NotCorrect: SUB AX, $01 {}
POP BX { ¢ BX ᥣ¥â á⥪ }
MOV ES:[DI+12], BX { ᥣ¥â 㪧⥫ï Stack }
MOV ES:[DI+8], BX { OrignSS=BX }
PUSH ES { á®åàï¥ á¥£¥â 㪧⥫ï }
MOV ES, CX { ¢®áá⮢¨«¨ ES }
MOV CX, TaskPoint.WORD[0] { á¥é¥¨¥ ç« §¤ç¨ }
MOV DX, TaskPoint.WORD[2] { ᥣ¥â ç« §¤ç¨ }
PUSH BP
CLI {}
MOV SI, SS { á®åàï¥ SS ¢ SI }
MOV BP, SP { á®åàï¥ SP ¢ BP }
MOV SS, BX { ¯¥à¥ãá⢫¨¢¥ á⥪ }
MOV SP, AX {}
MOV BX,SEG HaltCurrentTask { ¢â®â¨ç¥áª¨© ¢ë室 ¢ }
MOV AX,OFFSet HaltCurrentTask { ¯à®æ¥¤ãàã HaltCurrentTask }
PUSH BX { ¯® ¤®á⨦¥¨î ®¯¥àâ®à END }
PUSH AX { ⥪ã饩 ¯à®æ¥¤ãàë-¯à®æ¥áá }
PUSH DX { á®åàï¥ â®çªã ¢å®¤ ¢ }
PUSH CX { ¯à®æ¥áá }
PUSH DS { á®åàï¥ ¢ ¥ DS }
PUSH ES { -\\- ES }
MOV DX, SP { £®â®¢¨ ¯á¥¢¤® BP }
ADD DX, $02 { §â«ª¨¢¥ ¥£® ¢ á⥪ }
PUSH DX {}
MOV CX, SP {}
MOV SS, SI { ¢®áá⢫¨¢¥ á⥪ }
MOV SP, BP {}
STI {}
POP BP { ¢®áá⢫¨¢¥ BP }
MOV AX, ES {}
POP ES {}
MOV ES:[DI+6], CX { OrignSP=CX }
PUSH ES {}
MOV ES, AX {}
POP AX {}
MOV HeadStack.WORD[0], DI { ¯¥à¥ãá⢫¨¢¥ 㪧⥫ì }
MOV HeadStack.WORD[2], AX { HeadStack }
MOV AX, CountTask { ¨ªà¥¥â¨à㥠CountTask }
INC AX {}
MOV CountTask, AX {}
MOV AX, UniNumber { ¢®§¢àé¥ë© ®¥à ¯à®æ¥áá }
DEC AX {}
JMP @Exit { ¢ë室 ¨§ ¯à®æ¥¤ãàë }
@TooManyProc: MOV AL, vstMAXLimitProc {}
MOV TaskError, AL {}
JMP @ErrExit {}
@LowMemAndFree: MOV BX, SizeStack {}
PUSH BX {}
CALL mFreeMem {}
@LowMem: MOV AL, vstMemoryLow {}
MOV TaskError, AL {}
@ErrExit: XOR AX, AX {}
@Exit:
end;
procedure HaltCurrentTask; assembler;
{ --- áï⨥ ⥪ã饩 §¤ç¨ --- }
asm
{ 1) 宦¤¥¨¥ ¢ ®ç¥à¥¤¨ ¯à®æ¥áᮢ á«¥¤ãî饣® ¯à®æ¥áá;
2) ¥à¥ª«î票¥ ¥£® SS ¨ SP;
3) ¥à¥ãá⮢ª ¢á¥å ¯¥à¥¥ëå;
4) ¨ç⮦¥¨¥ á⥪ ¯à¥¤ë¤ã饣® ¯à®æ¥áá;
5) ¤«¥¨¥ ¨§ ®ç¥à¥¤¨ ¯à®æ¥áᮢ ®¯¨áâ¥«ï ¯à®æ¥áá;
6) ¤«¥¨¥ ¨§ ¯ï⨠®¯¨áâ¥«ï ¯à®æ¥áá;
7a) ᫨ ¡ë« ©¤¥ á«¥¤ãî騩 ¯à®æ¥áá - â® ¢®áá⮢«¥¨¥
¥£® ॣ¨áâ஢ ¨ RETF;
7b) ᫨ ¡®«ìè¥ ¯à®æ¥áᮢ ¥â, â® ãá⮢ª SS:SP ®á®¢®©
¯à®£àë ¨ RETF ¢ ¥¥. }
{--------------------------------------------------------------}
MOV AX, SEG @Data { ¯¥à¥ãá⮢ª ᥣ¥â DS }
MOV ES, PCurTask.word[2] { ¢ ES:DI 㪧⥫ì ⥪ã騩 }
MOV DI, PCurTask.word[0] { ®¯¨á⥫ì }
XOR AX, AX { ®¡ã«¥¨¥ ¤®¯®«¨â¥«ì®£® }
MOV PDopPoint.word[0], AX { 㪧⥫ï }
MOV PDopPoint.word[2], AX {}
MOV AX, ES { AX:DI }
MOV DX, HeadStack.word[2] { ¢ DX:BX §ç¥¨¥ ç« á⥪ }
MOV BX, HeadStack.word[0] { ¯à®æ¥áᮢ }
@Loop: CMP DX, AX { ¯à®¢¥àª ࢥá⢠㪧⥫¥© }
JNE @NextProc { AX:DI ¨ DX:BX }
CMP BX, DI { ¥á«¨ ¥ à¢ë, â® ¯®¨áª à¢ëå}
JNE @NextProc {}
JMP @DelProcess { ª 㤫¥¨î ¯à®æ¥áá }
@NextProc: MOV ES, DX { áâந ॣ¨áâ஢ãî ¯àã }
MOV SI, BX { ES:SI - 㪧⥫ì }
MOV PDopPoint.word[0], BX { á®åàï¥ ãª§â¥«ì }
MOV PDopPoint.word[2], DX { ¯à¥¤ë¤ã騩 í«¥¥â ®¯¨á⥫ì }
MOV DX, ES:[SI+4] { ¢ DX:BX 㪧⥫ì á«¥¤ãî騩}
MOV BX, ES:[SI+2] { í«¥¥â á⥪ ®¯¨á⥫¥© }
JMP @Loop {}
@DelProcess: MOV ES, AX { ES:DI }
MOV BX, ES:[DI+2] { ¢ BX á¥é¥¨¥ á«¥¤ãî饣® }
MOV PCurTask.word[0], BX { í«¥¥â }
MOV DX, ES:[DI+4] { ⮦¥ á ᥣ¥â® }
MOV PCurTask.word[2], DX {}
XOR CX, CX { ¯à®¢¥àï¥ PDopPoint Nil }
CMP CX, PDopPoint.word[0] {}
JNE @NotNil { ¥á«¨ ¥ Nil }
CMP CX, PDopPoint.word[2] {}
JNE @NotNil {}
MOV HeadStack.word[0], BX { ¯¥à¥áâ¢«ï¥ ãª§â¥«ì }
MOV HeadStack.word[2], DX { ç«® á⥪ }
JMP @FreeMem {}
@NotNil: PUSH ES {}
PUSH DI {}
MOV ES, PDopPoint.word[2] { ¢ ES:DI 㪧⥫ì }
MOV DI, PDopPoint.word[0] { ¯à¥¤ë¤ã騩 í«¥¥â }
MOV ES:[DI+2], BX { ¯¥à¥áâ¢«ï¥ ãª§â¥«ì Next ã }
MOV ES:[DI+4], DX { ¯à¥¤ë¤ã饣® í«¥¥â }
POP DI { ¢ ES:DI 㪧⥫ì 㤫ï¥ë©}
POP ES { í«¥¥â }
@FreeMem: CLI {}
MOV SS, OriginalSS { ¢®áá⢫¨¢¥ á⥪ }
MOV SP, OriginalSP { ®á®¢®© ¯à®£àë }
STI {}
MOV DX, ES:[DI+12] { ¢ DX:BX 㪧⥫ì á⥪ }
MOV BX, ES:[DI+10] { 㤫葉£® ¯à®æ¥áá }
MOV CX, ES:[DI+14] { ¢ CX ৥à á⥪ }
PUSH ES {}
PUSH DI
PUSH DX { £®â®¢¨ á⥪ ¨ ®á¢®¡®¦¤¥ }
PUSH BX { ¯ïâì á⥪ 㤫葉£® }
PUSH CX { ¯à®æ¥áá }
CALL mFreeMem {}
POP DI {}
POP ES {}
MOV CX, TYPE TTaskRec { à§¥à §¯¨á¨ TTaskRec -> CX }
PUSH ES { ã¤«ï¥ ®¯¨áâ¥«ì ¯à®æ¥áá ¨§ }
PUSH DI { ¯ï⨠}
PUSH CX {}
CALL mFreeMem {}
XOR AX, AX { ®¡ã«¨âì ®¥à â¥ã饣® ¯à®æ¥áá}
MOV CurTask, AX {}
MOV AX, CountTask { ¤¥ªà¥¥â CountTask }
DEC AX {}
MOV CountTask, AX {}
JZ @Exit { ¯à®æ¥áᮢ ¡®«ìè¥ ¥â }
MOV ES, PCurTask.word[2] { PCurTask -> ES:DI }
MOV DI, PCurTask.word[0] {}
MOV BX, ES {}
XOR AX, AX {}
CMP AX, BX { ¥á«¨ PCurTask ¥ ࢥ }
JNE @SetProcess { Nil, â® ¯¥à¥ãá⮢¨âì }
CMP AX, DI { ⥪ã騩 ¯à®æ¥áá }
JNE @SetProcess {}
MOV ES, HeadStack.word[2] { HeadStack -> ES:DI }
MOV DI, HeadStack.word[0] {}
MOV PCurTask.word[2], ES { ES:DI -> PCurTask }
MOV PCurTask.word[0], DI {}
@SetProcess: MOV AX, ES:[DI] { NumProc -> AX }
MOV CurTask, AX {}
CLI {}
MOV SS, ES:[DI+8] { ¯¥à¥ãá⮢ª á⥪ }
MOV SP, ES:[DI+6] {}
STI {}
POP BP { ¢®áá⮢«¥¨¥ ॣ¨áâ஢ }
POP ES { ¯à®æ¥áá }
POP DS {}
@Exit:
end;
procedure HaltAllTasks; assembler;
{ --- áï⨥ ¢á¥å §¤ç --- }
asm
{ 1) ¡ã«¥¨¥ ¢á¥å ¯¥à¥¥ëå;
2) ¤«¥¨¥ ®ç¥à¥¤¨ ¯à®æ¥áᮢ á® á⥪¨;
3) á⮢ª SS:SP ®á®¢®© ¯à®£àë ¨ RETF ¢ ¥¥. }
MOV AX, SEG @Data { ¢®áá⢫¨¢¥ ᥣ¥â DS }
MOV DS, AX {}
XOR AX, AX { PCurTask=Nil }
MOV PCurTask.word[0], AX {}
MOV PCurTask.word[2], AX {}
CLI {}
MOV SS, OriginalSS { ¢®áá⢫¨¢¥ á⥪ ¯à®£àë}
MOV SP, OriginalSP {}
STI {}
@Loop: XOR AX, AX {}
CMP AX, CountTask { á®âਠ¥áâì «¨ ¯à®æ¥ááë }
JE @StackEmpty { ¥á«¨ ¥â ¢ë室 }
MOV ES, HeadStack.word[2] { ¢ ES:DI ãª§â¥«ì ¯¥à¢ë© }
MOV DI, HeadStack.word[0] { í«¥¥â ®ç¥à¥¤¨ ¯à®æ¥áᮢ }
MOV DX, ES:[DI+4] { DX:BX 㪧⥫ì á«¥¤ãî騩 }
MOV BX, ES:[DI+2] { í«¥¥â á⥪ ¨«¨ Nil }
MOV HeadStack.word[2], DX { HeadStack = DX:BX }
MOV HeadStack.word[0], BX {}
MOV AX, ES:[DI+12] { ¢ AX:CX 㪧⥫ì á⥪ }
MOV CX, ES:[DI+10] { ¯à®æ¥áá }
PUSH ES { £®â®¢¨ á⥪ ¤«ï ¢ë§®¢ ¯à®æ¥-}
PUSH DI { ¤ãàë ®ç¨á⪨ ¯ï⨠}
PUSH AX { AX:CX - 㪧⥫ì á⥪ }
PUSH CX { ¯à®æ¥áá }
MOV AX, ES:[DI+14] { ¢ AX ৥à á⥪ }
PUSH AX {}
CALL mFreeMem { ã¨ç⮦¥ á⥪ ¯à®æ¥áá }
MOV AX, TYPE TTaskRec { ¢ AX à§¥à ®¯¨áâ¥«ï ¯à®æ¥áá}
PUSH AX {}
CALL mFreeMem { ã¨ç⮦¥ ®¯¨áâ¥«ì ¯à®æ¥áá }
MOV AX, CountTask { ¤¥ªà¥¥â¨à㥠CountTask }
DEC AX {}
MOV CountTask, AX {}
JMP @Loop { ã¨ç⮦âì á«¥¤ãî騩 ¯à®æ¥áá }
@StackEmpty: MOV CurTask, AX { CurTask=0 }
end;
{----------------------------------------------------------------}
end.
[Back to MEMORY SWAG index] [Back to Main SWAG index] [Original]