Important: The information in this document is obsolete and should not be used for new development.
Defining a Deferred Task
You define a deferred task as a procedure taking no parameters and put the address of that procedure in the deferred task element whose address you pass to theDTInstall
function. When your task is executed, register A1 contains the optional parameter that you put in thedtParm
field of the task record.If you write your deferred task in a high-level language, such as Pascal, you might need to retrieve the value loaded into register A1. The function
GetA1
defined in Listing 6-3 returns the value of the A1 register.Listing 6-3 Finding the value of the A1 register
FUNCTION GetA1: LongInt; INLINE $2E89; {MOVE.L A1,(SP)}You can callGetA1
in your deferred task, as illustrated in Listing 6-4.Listing 6-4 Defining a deferred task
PROCEDURE DoDeferredTask (dtParm: LongInt); BEGIN {Your deferred task code goes here.} END; PROCEDURE MyDeferredTask; VAR myParm: LongInt; BEGIN myParm := GetA1; {retrieve parameter put in register A1} DoDeferredTask(myParm); {run the deferred task} END;Note thatMyDeferredTask
callsGetA1
to retrieve the parameter passed in the register A1. ThenMyDeferredTask
calls the application-defined procedureDoDeferredTask
, passing it that parameter. TheDoDeferredTask
procedure does the real work of the deferred task. (This division into two routines is necessary to prevent problems caused by some optimizing compilers.)