29.12.2012 Views

The Programmer's Guide to TRSDOS Version 6 - Tim Mann's Home ...

The Programmer's Guide to TRSDOS Version 6 - Tim Mann's Home ...

The Programmer's Guide to TRSDOS Version 6 - Tim Mann's Home ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

What could be more simple? We identify what task slot <strong>to</strong> remove by the value placed in<strong>to</strong><br />

register C, then issue the supervisor call. Another method can be used if we want <strong>to</strong><br />

remove the task WHILE WE ARE EXECUTING IT. Consider the routine modified as follows:<br />

MYTCB DW MYTASK<br />

COUNTER DB 10<br />

TEMPY DB 0<br />

MYTASK DEC (IX+2)<br />

RET NZ<br />

LD A,@KLTSK ;Identify the SVC<br />

RST 40 ;Invoke the service call<br />

<strong>The</strong> @KLTSK service routine will remove the currently executing task. Since this task is<br />

currently executing, it is the one that gets removed from the TCBVT table. <strong>The</strong> system<br />

will not return <strong>to</strong> your routine but will continue as if you had executed an "RET"<br />

instruction. <strong>The</strong>refore, the "@KLTSK" SuperVisor Call should be the last instruction you<br />

want executed. In this example, MYTASK will decrement the counter by one on each entry <strong>to</strong><br />

the task. When the counter reaches zero, the task will be removed from slot 2 (remember<br />

it was placed in slot 2).<br />

One additional TP SuperVisor Call is @RPTSK. <strong>The</strong> function is easy <strong>to</strong> say in words;<br />

however, its function is best illustrated. <strong>The</strong> @RPTSK function will update the TCB<br />

s<strong>to</strong>rage vec<strong>to</strong>r (the vec<strong>to</strong>r address in your task control block) <strong>to</strong> be the address<br />

immediately following the @RPTSK SVC instruction. This is also another case where the<br />

system will NOT return <strong>to</strong> your task routine after the SVC is made but rather continues on<br />

with the TP. To illustrate how this TP function is used in a program, the final example<br />

should be examined:<br />

First, let's point out that this task routine contains no method of relocating it <strong>to</strong><br />

protected RAM. <strong>The</strong> statements starting at label, BEGIN, add the task <strong>to</strong> TCBVT slot zero<br />

(without checking for its availability) and return <strong>to</strong> DOS Ready. <strong>The</strong> task contains a four<br />

second down counter and a routine <strong>to</strong> put a character in video RAM (80th character of row<br />

0). At four second intervals, the character <strong>to</strong>ggles between '|' and '-'. <strong>The</strong> <strong>to</strong>ggling is<br />

achieved by <strong>to</strong>ggling the execution of two separate routines which perform the character<br />

display. Use is made of the @RPTSK TP call <strong>to</strong> implement the routine <strong>to</strong>ggling. Examine<br />

this task closely <strong>to</strong> ascertain the functioning of @RPTSK.<br />

BEGIN LD DE,TCB ;Point <strong>to</strong> TCB & add the<br />

LD C,0 ; task <strong>to</strong> slot 0<br />

LD A,@ADTSK<br />

RST 40<br />

LD A,@EXIT ;Exit <strong>to</strong> DOS<br />

RST 40<br />

TCB DW TASK<br />

COUNTER DB 15<br />

TASKA LD A,@RPTSK ;Replace current<br />

RST 40 ; task with TASKA<br />

TASK LD BC,2

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!