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.

I<br />

n data can be input into your code by<br />

t<br />

means of the ROM routines.<br />

h<br />

The trivial method of inputing data<br />

is to POKE values into the relevant<br />

i<br />

locations used by the code. This<br />

s method is good enough and may be<br />

amandatory<br />

if you're using a Basic<br />

rdriver<br />

program and you want to use a<br />

tcompiler.<br />

Those of you with more<br />

i<br />

refined taste will want something<br />

better.<br />

c<br />

One of the most important routines<br />

lin<br />

the Basic ROM starts at $AD9F•<br />

eThis<br />

evaluates input expressions and<br />

, checks the syntax. There are a large<br />

I number of entry points to this routine<br />

w<br />

which can be used for our benefit.<br />

a<br />

n<br />

Getting into M/C<br />

t<br />

tThere<br />

are two commands for the<br />

o accessing of machine code from Basic.<br />

cFirst<br />

we have the USR command. It's<br />

ofuill<br />

syntax is:<br />

n<br />

s<br />

Variable — USR(expression)<br />

i<br />

The expression within the brackets is<br />

devaluated<br />

and stored in FAC/1<br />

e(floating<br />

point accumulator no I). This<br />

r value is then used in your code. The<br />

hentry<br />

point of your code must fi<br />

orst<br />

stored bin ethe<br />

vector in locations $0310<br />

to $0312. On leaving the routine, the<br />

wvalue<br />

in FAC/1 is transferred to the<br />

variable in the calling instruction. Since<br />

you can only pass one parameter, this<br />

instruction is of limited value.<br />

The more frequently used<br />

command is SYS. This simply calls the<br />

machine code starting at the specified<br />

MACHINE CODE<br />

Welcome to<br />

the Machine<br />

ROM routines revealed. Read on to find out how to<br />

input data into your machine code<br />

By Allen Webb<br />

address. Since SYS doesn't support<br />

parameters, we must use some coding<br />

to add them. The most usual syntax<br />

adopted is of the form:<br />

SYS address, parameter 1, parameter<br />

2,.. „etc<br />

After your code is entered, the<br />

Basic text pointer is pointing at the<br />

character after the SYS. We can check<br />

this character using four routines:<br />

I LISTING 2<br />

40 CHKCOMMA $AEFD<br />

50 CHKLPAR = $AEFA<br />

60 CHKRPAR = $AEF7<br />

70 EVALTERM $AD8A<br />

80 FLPTOINT = $B7F7<br />

85 CHKCHAR = $AEFF<br />

90 PARAM1 = $AA<br />

95 PARAM2 = $F8<br />

100 JSR CHKCOMMA IS 1ST COMMA THERE ?<br />

110 JSR CHKLPAR OPEN BRACKET ? •<br />

120 JSR EVALTERM ; YES — GET VALUE<br />

130 JSR FLPTOINT<br />

140 LDA $14 ; AND SAVE IT IN<br />

150 STA PARAM1 RESULT 1<br />

160 LDA $15<br />

170 STA PARAM11-1<br />

180 JSR CHKRPAR CLOSING BRACKET ?<br />

190 JSR CHKCOMMA NEXT COMMA ?<br />

200 JSR EVALTERM YES — GET VALUE<br />

205 JSR FLPTOINT<br />

210 LDA $14 ; SAVE IT IN<br />

220 STA PARAM2 RESULT2<br />

230 LDA $15<br />

240 STA PARAM24-1<br />

250 RTS<br />

YOUR COMM(MORE november 1986:85<br />

$AEF7 — check that character is a right<br />

bracket<br />

SAEFA — check that character is a left<br />

bracket<br />

SAUD — check that character is a<br />

comma<br />

$AEFF check that character is that<br />

held in the accumulator<br />

These routines give a SYNTAX<br />

ERROR if the character is not that<br />

sought. If the character is correct, the<br />

1

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

Saved successfully!

Ooh no, something went wrong!