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.

esident routine in<strong>to</strong> its execution location in memory. <strong>The</strong> first thing that must be done<br />

is <strong>to</strong> move the contents of the @ICNFG vec<strong>to</strong>r in<strong>to</strong> your initialization routine. <strong>The</strong> code:<br />

LD A,@FLAGS$ ;Get flags pointer<br />

RST 40 ; in<strong>to</strong> register IY<br />

LD A,(IY+28) ;Get @ICNFG byte 1<br />

LD (LINK),A ; & save in LINK+0<br />

LD L,(IY+29) ;Get address LOW and HIGH<br />

LD H,(IY+30) ; then save in the<br />

LD (LINK+1),HL ; LINK address vec<strong>to</strong>r<br />

does this by transferring the three byte vec<strong>to</strong>r <strong>to</strong> your routine. You then need <strong>to</strong><br />

relocate your routine <strong>to</strong> its execution memory address. Once this is done, transfer the<br />

relocated initialization entry point <strong>to</strong> the @ICNFG vec<strong>to</strong>r as a jump instruction with this<br />

code:<br />

LD HL,INIT ;Get (relocated)<br />

LD (IY+29),L ; init address<br />

LD (IY+30),H<br />

LD A,0C3H ;Set JP instruction<br />

LD (IY+28),A<br />

It is sometimes necessary <strong>to</strong> have your initialization program execute the initialization<br />

routine so that the function of the module is immediately available. You probably do not<br />

want <strong>to</strong> execute any other routines that may be chained in<strong>to</strong> @ICNFG so you should not CALL<br />

the chain! Your initialization routine can be executed by calling its relocated address<br />

as in:<br />

CALL ROUTINE ;Initialize only mine<br />

Don't forget <strong>to</strong> SYSGEN after linking in your routine. <strong>The</strong> SYSGEN process includes saving<br />

the revisions <strong>to</strong> @ICNFG so that any changes will be part of the system configuration the<br />

next time the disk is booted. By following these procedures, you can effect the<br />

invocation of your routine every time you boot the operating system disk which contains<br />

this configuration.<br />

8.2 THE KFLAG$ SCANNER<br />

Many applications have the need <strong>to</strong> detect a PAUSE or BREAK condition while they are in<br />

execution. BASIC does this after every logical statement is executed (i.e. after each end<br />

of line or ":" statement separa<strong>to</strong>r). That's how, in BASIC, you can s<strong>to</strong>p a program with<br />

the key or pause a listing. <strong>The</strong> classical method that programmers have used <strong>to</strong><br />

detect the condition was <strong>to</strong> scan the keyboard via the @KBD SuperVisor Call. If a<br />

character was input, and it was a or a , the appropriate action would be<br />

taken. Any other entry that was available would be ignored which would discard all other<br />

keyboard entries. Unfortunately, if the user was trying <strong>to</strong> make use of keyboard typeahead,<br />

each @KBD request looking for or would extract one character from<br />

the type-ahead buffer; thus the user's typed-ahead entries would be lost.<br />

Another method could be used on a matrix keyboard that is accessible <strong>to</strong> the application.<br />

This method does not request entries via the @KBD call but scans the keyboard physically<br />

examining the keyboard matrix. A problem with this method is that accessible matrix<br />

keyboards are not always available. A second problem is that if such a keyboard was<br />

available, the application would not be portable across <strong>Version</strong> 6 installations.<br />

If an application uses the KFLAG$ keyboard function latch <strong>to</strong> observe the BREAK or PAUSE<br />

condition, it overcomes these deficiencies [a third condition - that of the ASCII CR is<br />

also supported]. KFLAG$ contains three bits associated with the "keyboard" functions of<br />

BREAK, PAUSE (sometimes interpreted as ), and CR (sometimes interpreted as<br />

8-2

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

Saved successfully!

Ooh no, something went wrong!