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.

LD (IY+'K'-'A'),A ; PAUSE, BREAK<br />

PUSH BC ;Don't alter register BC<br />

LD B,16<br />

LD A,@PAUSE ;Pause a bit <strong>to</strong> "debounce"<br />

RST 40 ; the key entry<br />

POP BC<br />

LD A,(IY+'K'-'A') ;Check if finger is<br />

AND 7 ; still on key<br />

JR NZ,RESKFL1 ;If so, reset it again<br />

POP AF ;Res<strong>to</strong>re registers<br />

POP HL ; and exit<br />

RET<br />

<strong>The</strong> RESKFL subroutine needs <strong>to</strong> be called when you first enter your application. This is<br />

necessary <strong>to</strong> clear the flag bits that were probably in a "set" condition. This "primes"<br />

the detection. <strong>The</strong> routine also needs <strong>to</strong> be called once a BREAK, PAUSE, or ENTER<br />

condition is detected and handled.<br />

Another method that can be used <strong>to</strong> detect the BREAK condition is <strong>to</strong> use the @CKBRKC<br />

SuperVisor Call - SVC-105. This SVC essentially performs all of the code needed <strong>to</strong> test<br />

the BREAK bit of the KFLAG$ and reset it as required. Thus, instead of using your own<br />

code <strong>to</strong> test the KFLAG$'s BREAK bit, you can invoke @CKBRKC. An NZ return indicates that<br />

the BREAK key was depressed. Since the SVC also clears the BREAK bit, it should be<br />

invoked once at the beginning of your program <strong>to</strong> ensure that the bit is first reset.<br />

8.3 DISK LOAD MODULE FORMATS<br />

A load module is simply a disk file that can be loaded in<strong>to</strong> memory by the system loader.<br />

<strong>The</strong> file is made up of variable length records and is usually a program. Many different<br />

types of records are included in a load module - the DOS makes extensive use of distinct<br />

record types in load modules. One record type is a load record which contains information<br />

on where it is <strong>to</strong> load in<strong>to</strong> memory. If the file can be directly executed as a program, it<br />

then becomes known as an executable load module (ELM). <strong>The</strong> usual term that has been<br />

applied <strong>to</strong> such a file is "CMD". That's because a directly executable load module can be<br />

invoked as if it were a system CoMmanD. We further use the default file extension of /CMD<br />

for these command files.<br />

A load module can be conceptualized as a sequence of RECORDS. Note that we did not say an<br />

ordered sequence. Thus, the implication is that the records do not have <strong>to</strong> be in an<br />

ascending order (contiguous load addresses). Each record contains three fields: a TYPE<br />

field, a LENGTH field, and a DATA field. It has a one-byte indica<strong>to</strong>r as <strong>to</strong> what TYPE of<br />

record it is. This TYPE code is used <strong>to</strong> denote a record as a HEADER record, a TRANSFER<br />

record, an ISAM direc<strong>to</strong>ry entry record, a LOAD record, or other meaningful structure.<br />

Each record also has a one-byte LENGTH field which is the length of the data area field.<br />

<strong>The</strong> data field length thus ranges from in value. <strong>The</strong> remaining part of the record<br />

is its DATA AREA and is used <strong>to</strong> s<strong>to</strong>re program code, direc<strong>to</strong>ry information, messages, or<br />

other pertinent information. If you are familiar with BASIC random access files, you will<br />

see the similarity in the fielding of records - except in this case, we have variable<br />

length sequentially accessed records [with partitioned data sets provided in the PRO-PaDS<br />

utility, you also have variable length indexed sequential accessed records]. Figure 8-1<br />

lists the various TYPE codes currently used in the operating system.<br />

8-5

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

Saved successfully!

Ooh no, something went wrong!