08.04.2013 Views

Your Commodore - Commodore Is Awesome

Your Commodore - Commodore Is Awesome

Your Commodore - Commodore Is Awesome

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.

next pointer simply moves on to the<br />

next character.<br />

Parameters<br />

Having sorted out the separators, we<br />

want to evaluate the parameters. This is<br />

readily achieved by calling SAD8A.<br />

This evaluates the expression which is<br />

being pointed at by the text pointer<br />

and stores the result in FAC/1.<br />

Consider the Listing L<br />

JSR SAEFD<br />

20 JSR MINA<br />

This will extract a single parameter<br />

after checking for a comma and leave<br />

the result in FAC/1. In other words, it<br />

checks the syntax:<br />

SYS address, parameter<br />

This sytem is in fact quite tolerant.<br />

Spaces are ignored allowing freedom<br />

of syntax. The parameter can be any<br />

valid expression or a numeric value.<br />

Listing 2 is more complex. It<br />

checks for a rather bizarre syntax ie.<br />

SYS address,(parameter 1),parameter<br />

2<br />

You will note that I've used the<br />

routine at $1371<br />

7parametes<br />

in FAC/1 to integers.<br />

7 You t o may, alternatively, wish to<br />

ctransfer o n non-numeric v e r data in strings.<br />

t<br />

Again, there are routines for this<br />

purpose. First, we call SAD9E to<br />

t<br />

evaluate<br />

h<br />

the<br />

e<br />

expression. This time. the<br />

routine will detect that we have a string<br />

and will exit with the length of the<br />

string in the accumulator and the start<br />

address of the string in S64 and $65. A<br />

call to $B6A6 erases any previous cop<br />

of the string by moving the string<br />

pointers. On leaving this routine, the<br />

start address of the string is in $22/$23.<br />

Listing 3 handles the syntax:<br />

SYS address, string<br />

I LISTING 3<br />

MACHINE CODE<br />

This routine will accept text or<br />

strings. e.g.<br />

SYS address,AS<br />

SYS address„<br />

—<br />

text" The date given by Listing 3 can be<br />

easily manipulated. Listing 4 takes this<br />

data and moves it to a buffer.<br />

I LISTING 4<br />

10 LDY #0<br />

20 LOOP LDA STRINGADD ,<br />

30 STA BUFFER,Y<br />

40 INY<br />

50 CPY STRINGLEN<br />

60 BNE LOOP OP<br />

So what happens if you want to<br />

input numeric information during the<br />

operation of the program? Well we can<br />

use some of the techniques described<br />

earlier in this series. Consider listing 5.<br />

20<br />

30<br />

GETSTR JSR $AEFD<br />

JSR $AD9E<br />

;<br />

;<br />

CHECK COMMA<br />

EVAL EXPRESSION<br />

40 JSR $B6A6 ; SAVE ADDRESS IN $22/$23<br />

50 STA STRINGLEN ; SAVE STRING LENGTH<br />

60<br />

70<br />

80<br />

90<br />

95<br />

LDA $22<br />

STA STRINGADD<br />

LDA $23<br />

STA STRINGADD+1<br />

RTS<br />

;<br />

;<br />

;<br />

;<br />

START ADDREESS OF<br />

STRING — LSB<br />

START ADDRESS OF<br />

STRING — MSB<br />

I<br />

40 L BUFFER = $0200<br />

40 I CHKSTR = $AD8A<br />

S70<br />

LDY #0<br />

T80<br />

LOOP JSR $FFCF<br />

I<br />

90 CMP #13<br />

100<br />

N BEQ QUIT<br />

110 STA<br />

G<br />

BUFFER,Y<br />

120 INY<br />

5<br />

130 JMP LOOP<br />

;<br />

;<br />

;<br />

;<br />

;<br />

;<br />

INPUT ROUTINE<br />

IF RETURN EXIT<br />

PUT INTO BASIC<br />

INPUT BUFFER<br />

140<br />

150<br />

160<br />

170<br />

180<br />

OUT<br />

STA<br />

LDA<br />

STA<br />

LDA<br />

LDA #0<br />

BUFFER,Y<br />

#

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

Saved successfully!

Ooh no, something went wrong!