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 ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
DE Contains a pointer <strong>to</strong> the File Control Block used <strong>to</strong> open the program file<br />
being run. This may prove useful <strong>to</strong> access the program file as data since<br />
the file is already in an open condition (the PRO-PaDS utility from MISOSYS<br />
makes use of this condition).<br />
HL Contains a pointer <strong>to</strong> the first non-blank character on the command line<br />
which terminated the parsing of the name entered in order <strong>to</strong> execute the<br />
program. This pointer should be used if you are going <strong>to</strong> parse command-line<br />
file specifications using @FSPEC or parameters via @PARAM.<br />
If the program was executed from DOS Ready or via @CMNDI, the stack pointer (SP) will<br />
point <strong>to</strong> the system stack which has approximately 150 bytes of s<strong>to</strong>rage space. If the<br />
program was executed via @RUN or @CMNDR, then the stack pointer contains whatever was<br />
established by the invoking program. In any event, the <strong>to</strong>p of the stack will contain the<br />
return address <strong>to</strong> the module which is invoking the program, be it another program or the<br />
system.<br />
If you are going <strong>to</strong> switch stacks, you should be aware that the system's task processor<br />
requires possibly 40 bytes of stack space. <strong>The</strong> exact amount will depend on what tasks are<br />
active. Release 6.0.0 of the DOS also has a restriction that limits the stack <strong>to</strong> reside<br />
below X'F400'. If you are going <strong>to</strong> use the @BANK request <strong>to</strong> <strong>to</strong>ggle memory banks, then the<br />
stack must reside below X'7FFE'.<br />
When your program terminates, it should load register pair HL with a return code. If the<br />
program terminates without error, use a return code of 0. If the termination is due <strong>to</strong> a<br />
DOS I/O error or other error being returned by an SVC as noted in the error dictionary,<br />
load that error number in<strong>to</strong> HL. For all other error conditions, the suggested procedure<br />
is <strong>to</strong> load a -1 (X'FFFF') in<strong>to</strong> register pair HL. After loading HL, you can either issue a<br />
RET instruction or issue an @EXIT SuperVisor Call. Note that the RET exit method mandates<br />
that you maintain the integrity of the stack pointer so that it is pointing <strong>to</strong> a valid<br />
return address. You may want <strong>to</strong> establish exit code that reloads the stack pointer with<br />
the SP contents that you saved when first executing the program. Thus, the SP will always<br />
be correct for an RET. An @EXIT termination will always res<strong>to</strong>re control <strong>to</strong> the operating<br />
system even if the program was invoked via an @CMNDR. <strong>The</strong>refore, if you suspect that your<br />
program will be invokable from another program, you should use the RET method for program<br />
termination.<br />
7.3 SUPERVISOR CALLS LISTED ALPHABETICALLY<br />
Name Svc # Purpose<br />
@ABORT SVC-21 Abnormal program exit<br />
@ADTSK SVC-29 Add a task process<br />
@BANK SVC-102 RAM bank switching<br />
@BKSP SVC-61 File record backspace<br />
@BREAK SVC-103 Establish vec<strong>to</strong>r<br />
@CHNIO SVC-20 Device chain character I/O<br />
@CKBRKC SVC-106 Check for a keyboard BREAK<br />
@CKDRV SVC-33 Check disk drive availability (& log)<br />
@CKEOF SVC-62 Check for file's end-of-file (EOF)<br />
@CKTSK SVC-28 Check task slot availability<br />
@CLOSE SVC-60 Close an open disk file<br />
@CLS SVC-105 Clear the Video screen<br />
@CMNDI SVC-24 Interpret and execute a command<br />
@CMNDR SVC-25 Execute a command and return<br />
@CTL SVC-05 Control a device chain<br />
@DATE SVC-18 Obtain system date<br />
@DCINIT SVC-42 Initialize a disk controller<br />
7-2