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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

set. Thus, the Z-flag will be indicative of a problem in effecting the transfer. If, by<br />

chance, PROGRAM-B needs <strong>to</strong> provide a return code, it must be done by using register pair<br />

DE, IX, or IY, as registers AF, BC, and HL are used <strong>to</strong> perform the transfer (or some<br />

other technique such as altering the return transfer address <strong>to</strong> a known error trapping<br />

routine).<br />

PROGRAM-B should contain code that is very similar <strong>to</strong> that shown earlier. For example,<br />

PROGRAM-B could be:<br />

PROGB PUSH BC ;Save old bank data<br />

PUSH HL ;Save the RET address<br />

.<br />

your PROGRAM-B routines<br />

.<br />

POP HL ;Recover transfer address<br />

POP BC ;Get bank transfer data<br />

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

RST 40<br />

JR NZ,ERROR ;Whatever error trap<br />

PROGRAM-B saves the bank data (register BC). Don't forget that a transfer was effected<br />

and register C has bit-7 already set when PROGRAM-B is entered.<br />

PROGRAM-B also saves the address it needs <strong>to</strong> transfer back (which is in HL). It then<br />

performs whatever routines it has been coded for, recovers the transfer data, and issues<br />

the bank transfer request. As explained earlier, an NZ return condition from the @BANK<br />

SVC indicates that the bank transfer was not performed. A recommendation is <strong>to</strong> verify<br />

that your application has not violated the integrity of the stack where the transfer data<br />

was s<strong>to</strong>red.<br />

Never place disk drivers, device drivers, device filters, or interrupt task service<br />

routines in banks other than bank-0. It is possible <strong>to</strong> segment one of the above modules<br />

and place segments in banks 1 through 7 provided the segment containing the primary entry<br />

is placed in bank 0. All three types of divisions are incorporated in<strong>to</strong> the system's<br />

spooler with transfer between segments being accomplished by the bank transfer techniques<br />

discussed above.<br />

It sometimes is necessary <strong>to</strong> transfer a page of memory from one bank <strong>to</strong> another. This can<br />

only be done in one of two ways. Either a character(s) at a time is passed in a<br />

register(s) or a page buffer below X'8000' is used. <strong>The</strong> system uses the last page of the<br />

system overlay region (X'2300'-X'23FF') as an overlay buffer (except for SYS5/SYS which<br />

loads in<strong>to</strong> the region). This buffer is generally available for use as a page transfer<br />

buffer. Do not use this location if your memory transfer routine is a background task or<br />

is using the RAM bank as a disk cache buffer.<br />

8.9 INTERFACING TO @KITSK<br />

Consider for a moment that disk I/O can not take place during an interrupt task. How then<br />

can we write "background" routines that perform disk I/O? <strong>The</strong> system printer spooler does<br />

its despooling function as a background task. If we cannot perform disk I/O during<br />

interrupt tasks, how can we despool? We achieve this by being able <strong>to</strong> invoke a background<br />

task in a way that does not depend on the interrupt task processor. A function frequently<br />

requested in almost every application is that of obtaining characters from the keyboard.<br />

If we can "hook in<strong>to</strong>" this keyboard request, we can execute a task every time the<br />

keyboard is scanned. For those tasks that require disk I/O, we can make use of this<br />

keyboard task process.<br />

At the beginning of the system keyboard driver code is a call <strong>to</strong> @KITSK. This means that<br />

any time that @KBD is called, the @KITSK vec<strong>to</strong>r is likewise called (actually, the type-<br />

8-24

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

Saved successfully!

Ooh no, something went wrong!