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.

DW LPARM+1<br />

DB 'FEED ' ;Line feed parameter<br />

DW FPARM+1<br />

DB 'F '<br />

DW FPARM+1<br />

DB 'TITLE ' ;Title parameter<br />

DW TPARM+1<br />

DB 'T '<br />

DW TPARM+1<br />

DB 'PROMPT' ;Prompt parameter<br />

DW PPARM+1<br />

DB 'P '<br />

DW PPARM+1<br />

DB 'XLATE ' ;Translate parameter<br />

DW XPARM+1<br />

DB 'X '<br />

DW XPARM+1<br />

NOP ;This is the ending zero byte<br />

<strong>The</strong> PRMTBL$ is going <strong>to</strong> be structured similarly for all tables. <strong>The</strong> convention used of<br />

specifying the address vec<strong>to</strong>r as "LABEL+1" will become immediately obvious once you<br />

inspect the method of using the result in URPROG. As an aside, let's look at two<br />

conventions of referencing the second byte of a three-byte instruction.<br />

METHOD1 LD (LABEL+1),HL ;Load HL in<strong>to</strong> the "nn" field<br />

.<br />

.<br />

.<br />

LABEL LD BC,0 ;P/u the value loaded<br />

METHOD2 LD (LABEL),HL ;Load HL in<strong>to</strong> the "nn" field<br />

.<br />

.<br />

.<br />

LD BC,0 ;P/u the value loaded<br />

LABEL EQU $-2 ;<strong>The</strong> "nn" field is 2-bytes back<br />

<strong>The</strong> first method will be used <strong>to</strong> illustrate parameter table vec<strong>to</strong>r addresses in this<br />

appendix section. Use the method you are most comfortable with. It is suggested that you<br />

choose one technique and use it exclusively throughout a program. Otherwise you will find<br />

yourself getting in<strong>to</strong> trouble as you forget which method you were using.<br />

Now that the @PARAM system function has parsed the entered command line, how do we<br />

utilize the "values" it interpreted while still supporting our defaults and conditions?<br />

Well, bear in mind that if the user has not entered a parameter word, nothing will be<br />

entered by @PARAM in<strong>to</strong> the address vec<strong>to</strong>r specified by the parameter table. <strong>The</strong>refore, an<br />

initial condition can be supplied in the coding. Also, the initial value coded will be<br />

dependent on just what condition you want the default <strong>to</strong> be. Let's see how this would<br />

work.<br />

.<br />

. ;Some front end code<br />

.<br />

;*=*=*<br />

; Here is where we pick up the length parameter. Note<br />

; that it is initialized <strong>to</strong> 80 if there is no user entry<br />

;*=*=*<br />

LPARM LD BC,80 ;Pick up the entry<br />

INC B ;Test hi-order for zero<br />

DEC B ;It must be zero for range check<br />

JP NZ,LBAD ;Bad length if range >255<br />

LD A,C ;P/u the lo-order length<br />

8-32

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

Saved successfully!

Ooh no, something went wrong!