ATARIAssembler Editor User Manual
ATARIAssembler Editor User Manual
ERROR ERROR
CODE ERROR CODE MESSAGE CODE ERROR CODE MDSSAGE
2 Memory insufficient 142 Serial bus data frame overrLur
3 Value error 143 Serialbus data frame checksumerror
4 Too many variables 144 Device done error
s Stdng length error 145 Read after write compare error
6 out of data error 146 Function not implemented
? Number greater tltan 32767 147 Insufficient RAM
I Input statement error 160 Drive number error
I Array or string DIM error 161 Too many OPEN files
10 Argument stack overflolv 162 Disk iull
11 Floating point overflod 163 Unrecoverable system data I/O e|ro.
underflow etror 164 File number mismatch
72 Line not found 165 File name error
13 No matching FOR statement 166 POINT data length error
74 line too long error 167 File locked
15 GOSUBor FOR line deleted 164 Command invalid
16 RETURNerror 169 Directory full
az Garbageerror 1?o File not found
1a Invalid string character 171 POINT invalid
/t\
ATARI'
OAwame' communicar
onscompany
lveD' etfort has b€en hade to eNure thal thid manu.l .m.ately documenls rhis prcdud ofthe ATARr compurer Division. Hove@rj
beoue ot rhe ongong imlroLement.and updatin8 ofthe omputer sftwe an:dhardware, ATART, rNC. cannot gudaDtee lhe ae
cuacy or printeJ mlenal after the datc ofpublication and onnor acepi responsibnityfor eriors or omissrons.
PREFACE
This manual assum€s the user has read an introductory book on assembly
languag€. It is not intended to teach assembly language. Suggested rcferencis
for assembly languag€beginners are 6'502Assembll ranguage programmingby
Ladce L€v€nthal and Progamming the 65U by Rodney Zaks (6eeAppendix 8).
The wer should also know how to use the scleen editinq and control features of
rhe ATARIo 400rM and ATARI 8OOtu personal CoriDuter Svsrems. Thes€
(eatures are the same as used in ATARI 8AS|C. Rer.i;w rhe"ATARr BASIC
Reference Manual ifyou are Lrnsure of ho.w to do screen editing.
The Assembler Editor cartridge allows you to talk in the mmputer's natural
language - machine language.Assembly languag€programming offers you
f:lster running programs and the ability io iailor programs to your exact needs.
CONTENTS
PREFACE
1 INTRODUCTION
About This Book 1
ATARI PeisonalComputer Systems 1
How anAssembler Editor Is Used
2 GETTING STARTED
Allocating Memory 5
Program Format*How to Write a Statement a
StatementNumber a
Label a
Operation CodeMnemonic a
Operand a
Comment a
How to Write Operands a2
Hex Operands 12
Immediate Operands t2
PageZero Operands t2
Absolute Operands 7.2
Absolute Indexed Operands 12
Non-indexedIndirect Operands 13
Indexed Indirect Operands 13
Indirect Indexed Operands 13
Indexed PageZero Operands 13
String Operands 13
Debug Commands
DR Display Registers 36
CRChangeRegisters 36
D or Dlnmmm Display Memory 36
C or Cmmmm ChangeMemory 3Z
Mmmmm Move Memory 3B
Vmmmm Verify Memory 3B
L or Lmmmm List Memory With Disassembly 38
A AssembleOne Instruction Into Memory 40
Gmmmm Go (ExecuteProgram) 40
Tmmmm Trace Operation 40
Sor Smmlnm StepOperation 4a
X Exit 4l
APPENDICES
1 Errors 43
2 Assembler Mnemonics(Alphabetic List) 45
3 Special Symbols 47
4 Table of Hex Digits with Corresponding
Op CodeMnemonicsand Operalds 49
5 Expressions 51
6 Directives 53
7 ATASCII Codeand Decimal/
Hexadecimal Equivalents
I References 61
9 Using the ATARI AssemblerDdiror
Cartridge to BestAdvantage 63
10 Quick Reference for Command6
Recognized by the AssemblerEdiror
11 Modifying DOS I to Make Binary Headers
Compariblewith AssemblyCarr;idge
ILLUSTRATIONS
Relationship ofvarious partsof Assembler
tditor carrridgero you and your sollware 3
Figure 2 Memory map withour useof LOMEM
Figure 3 Memory map with u6eof LOMEM
Figure 4 Example ofhow to write Line No., Label.
Op Code.Operand.and Commentin rhe
ATARI programming form
Figure 5 Statemenrs a6 rhey would appearon the
screenwhen enteredon the keyboard
with the recommendedspacine. - !O
-r-xntolr I Samplereproducible A'I'ARI
programming form j,B
Figure 6 S_ample program as you write it on
lhe ATARI programming form lB
-rlqure / Appearance of the screen as your
program is entered on the keyboard 1a
Figure B Appearance of the screen as your
sampleprogram is assembled 25
Figure 9 Normal (defaulrt format of assembly
listing asit appearson the screen 26
l
7
)
INTRODUCTION
To use the ATARI@ Assembler Editor cariridge effectively, there are ftur
kinds ofinformation that you must have. Firsi, y;u need someguidarc€ about
ho$ ro Lr"elhe rdrrri,lge irselr.Second,vou ne.a r,, know abo-urrhe ArARI
rcrsonalCompurcrsysremyou ar( uring wir h rhp carrridge. I hird. you needro
knou .om.'hing dbourb502 An"cmbtvLangurgpnrogramm,ng.And. tourrh,
lhe AssemblcrEdilor Carrrideewas de\Uned lo bc u"ed wirh lhc At ARJdi"k
drives and DOSII
ABOUT THIS This manual explainsihe operation ofttre ATARr AssemblerEdiior cartridge. rt
MANUAL do.s nor e\pl,in 6502 AssemblvLdnH,raep pr.^qrammin]-.lt vou are ahe.dv
Idmilirr wirh 6so2AJ.embll rangu"ge.vou u i)i rind rhis'maIualrmply .uire-d
io J our nced': orhcrwi:". vou Jroutd I pter ro one,,f rh. many Look"ihar ex.
plain 4502 AssFmbly Ld Buage pro8rdmming:.uir:bJe books dce ti",ed r,l
Ifyou are familiar with ATARr BASICand have written someprograms on your
ATARI 400rr1or ATARI 800N personat Compute. System,^yoi will fini1 no
better way to learn assemblylanguageihan the combination oithis manuat.the
ATARI A.semblertdrror carrridge.rnd a 6502programmingbook.
ATARI The 4TARI Assembler Editor cartridge is installed in ihe cart dge slot ofihe
PERSONAL ATARI 400 computer consoleand in the tcft cart.idee slot of the "1TARr 800
(ompurFrconsole.You musr he tamitiarw h rhe ke1;board and all rhe scree _
COMPUTER editing lunctions. That matedal is coveredin the app;opriaie operator,s Manual
SYSTEMS supplied rvith yolll. A'rARI perconal computer *st;m. Th; special sc.een_
editing keys are described in Section6 of fue Opeiator's uanual. you shoutd
readSection6 and follo.lvthe instmctions untit yoir are compietelyfamiliar with
I th. keyhoard"nd rhe.creen-edr.ig lun(1ion,.
If you arc usingthe ATARI 810Dirk Dri! e.you shodd refer to the in6(ructions
rhit comewirh ir. You shouldalto readrhF appropriateDisk operalingsysrem
ReferenceManual. Ifyou are curently usirg the 9/2419 ver8ion ofDos (Dos I),
you must userhe prdgram in AppeniJ;xI I for rhe d,"k drive ro be comparible
with the Assembler Editor cariridse.
lfyou are using the ATARI 815 Du3l Disk Driwe,you should refer to the ATARI
8r-5 operator's:uanual and the Disk operating sistem 1I Reference Manual that
You can alsoadd the ATARI820r!, the ATARI S25TM or the ATARI 822rNiPrinter
to give you "hard copy"-ihat is, a perma-
io your PersonalCompute! System
nent rccord ofyour program written on paper.
"soxrce
HOW AN All assembly language programs are divided into two parts: a "object
prosram, which is a human readableversion ofrhe program. and rhe
ASSEMBLER vet"ion of the program.Thesctwo
;roiram. s hich is lhe compurer-readable
EDITOR IS USED i,er."ion. of th. progr am are'disrinct and mLrstoc' upy diftire;r area" of RAM
As the programmer, you have three p mary iasks:
To enter your source program into the computer, €dit it (make insertioru,
deletions," and corrections] and save it to oi retrieve it from diskette or
YOU
SourceProgram ObjectProgram
GETTING
STARTED
ALLOCATING The very lirst.decisionyou must make when you sii down to write your source
MEMORY program involves the allocationofmcDlory spac€.
rhe araRr conputer syU." *"" a* -"--" tbr its own internat Deeds.The
an,ounr rr urFs,lepcndsun $hprlrcr o. nor DOr is loJIed ir,ro RA]\1.ln anv
F v e , , r' .h c A r " c n r b F rf , d i r o . , d r r r i d g F $ ra u r o m a r i , J t y p l a , e v o u
s ,r u r c cp r J _
g ' " m i n r o' h e c h u n ko f m c r n o , v, r J i n g w i r h r h e f i r . j i r . . ; " m o r " t , . . r | i o n .
As.you typ€ in more sourcecode,the memorlr allocatedio storing your source
.odc '.a ed r h- . LdirTF\r Bufrerj, gro$ ". tfyou dcl"retinFsor .o;r ( F , .,de,rh.
c d i r r p \ r b u f T ( r . l r r i n k . .y o u , r n v i s u a t i z rFt , p m F m o r ) r o , , r r o n\ v i r h r h i "
figure, which is called a memofy map:
'I
he eliir tr xr huti.r ilwry. gros. lo\vrrd" lhp r.isht,I o rhe ..emo
a r p a . T h e l p f r r i J e o r r h e e J i r r F r r L r r f I p r i . f i r c a i n p t a , . o n . e v o u l r , u . r. n r . r i i e
Y o u r p f o b l e D , i s r , , d c r . r m i n e w l ) e r F r o , r o r e J h c o b i p , r L o d , D r , , ( l u ( . e db v r h e
A . " e m b l e r . l f y o u n u r r h F , , h j e c r c o d F i n l o r h F r c g i o ' n qm . r k ; d o s R A M , D O S
R A M . o r d . . p l a v R A M . ) o u $ i l . p f o l r l l ' c , r r r " .r h . c o m p u r e rr . , r " " h , , n d a t l
J
y o J r . l y p i n g \ \ i l l b e l o " l . l f y , , u p u r i r i n r o r h F p t d c ,c r " , t r h . e d i r r p \ r b u r t ; r ,
' h c o b i c c r , o , l e w i l l o v c f w r i e r h e s , , u rr ' e , o d e . , : s i n { m o , c . h d o ! . . i L e u n l v
s i r i p l d . e r u t , , ) o l r . o b j e . r , u . t ci s i n r h c . ? m p , v r , ) e ; , , , y . . i r . , .
You can find olrr wherF rhis empty memory area is by ryping SrZr mffini.
I hree hexade.rmaL number" will be displayed.likF so:
SIZEffi
0700 0880 5c1F
NDIT
The tust number (0700in this example)is the addressofihe bottom of usable
RAM, th€ point labeled "A" on ih€ m€mory map. The second number is the
addrcssofthe top of th€ edit text bufer, Iabeled.r8,, on the memory map. The
third number is ihe addressofthe top of empty memort, labeled-,,C,,;n the
memory map. The difference between the second and third rumbers (how
good ar€you at hexadecimal subtraction?) is the arnount of€mDtv memoru. you
can use the SIZE command any time you d€sire to know h-ow much lmpty
memory remam6.
Having decidedlo ilore rhe obtect program slarrinq ar ad&ess $5000.vour nerr
raskis ro declarethis to rhe compurer.rh;s is done-wirt .- direcrive."The
velv
firsr starementofrhe sourcecode would read:
10 { -$5000
This direcrive rells rhc Assemblerro pul all subsequenrobject code inro memory
startingar address$5000.Alhough ir is nor abdlurely neces"ary.;r i. always
wise praciice to make the *= directiwe the v€ry jirst line oi your source
program.
You have
havF two l$o olher
other strsrralegiesfor dllocaringmemory sprcc tor vour obiecl
program.Il he lirsr
program. firsrand simplest
simplestsrrareqy
srraregyis ro placeyourobjFcl code
ro-placeyouiobFcr codeon paeeo
6n Daee t oI
or
memory.
m e m o r y . The
r n e z256
5 b tlocarion. on
o c a t r o n !o page
n p a g e ro-6ave bi,en
j have b c e n ssir
etaa.ide
s i d e ffor
b r yyou.
our uu"J.
r e . Iriyour
fyour
objecr
-program and its drra wil Jl fir inro 256 byres. rhen you can put pur itir there
iher.
wiih the directive:
10 r =$0600
t I
os Dos Empty 180 EdilTexl
Buffer I Emply Dlsplay
Top ol
BAM YoUiRAM
wher€ XXXX is the hexadecimal address ofth€ new boftom edge ofthe edit t€xt
buffer rpoint A in the mernory mapr. you musl not ser LOMf,M to a smaller
varue rnan normalty rs. or you will overwrite OS data or DOSand .rdsh rhe
system.rurthermore, ifyou set LOMIM roo high, you will have too little room
ror your source Fogram. you must esiirl-Iate how much memorv your obiect
cod€ will require, and bum_p the edit teni buffer upward by thit"-".r,
!t""
some more for insurance. Then your firsi program instruction becomes: '
10 * =$YYYY
wherF YYYY is rhe old lalue of A given by rhe StZr commandbefore you
turned oll lhe compuler,'Lrrnedir brck on, and usedrhe LOMiM command
You might wonder why anybody would want to use the LOMIM command and
store the object prcgram in front ofthe sourc€program instead of behind it.
The primary reason ihis conunand is prcvided com€s fiom th€ fact that the
Assembler program. as ir rranslaresyour souice program inro an object pro-
obiecl pro-
gram. usesso^me addiiionalmemory tca ed a symboliabJerjusraboverhe edit
rerr buffer. lfyou realll wanted io, you.ould-fieurejusr how much memorv
rhe symbol iable usesi
uses;ir i" lhrep bJa;!
b!Ie! tor eJch dlsrinci Iabet plus
olu. on€
one bl-te
bq" for
r"',
each chdracler in €ach labpl. Mosr progr€mmers $ ho doni e^joy ngoing our
now org rnrssymool tabte,susethe LOMTMcommard so rhev won r have Lo
worry abourir. {Only rhe labelir"elfcoLlrts,nor rhe number ofiimes ir aooears
rn lhe program.r
Alloc"ring memory can be a confusing rask for rhe beginner. OrJy rwo insrruc
I'ons iLOMI_Il and =) JJe used. bur if they are miiused you ian crash the
sy"rpm.andloseyour.work..fonunarely.it yoLrresrricryour"elfto small pro_
gram" iniriallyyou ll havpplpnryofempry memory spa,i and tewer atJocaiion
Statement Number
Every statementmusi siart with a number from O to 65535.It is customary to
number statementsin incremenis of 10, 20, 30Jetc. Th€ Editor automaiically
puts the statements in numerical order for you. Numbedng by tens allows you
to insert new statements at a later date between existine stat€ments. To assist
you. rhe tdilor hasseveralconvenienrcommandsfor aur;miricallynumbering
statements(seeNUM, REN).
Label
A label, if used, occupies the second field in the statement. You must leave
€xactly one 6pace(not a tab) after the statement number. The label must stafi
with a letter and contain onlv letters and numbers. It can be as short as one
charact€r and as long as the limitation of statement length pelrnits (106 less the
number ofcharacters in the statement number). Most programmers use labels
ihree to six characterslong.
You are not forced to have a label.To go on to the next field, eDteranother space
(or a iab). The Assembler will interyret the ent.ies after a tab as an operation
operand
Thc fieldofthc opcrand startsat leastone space(or a iab) after anoperaiion code
mnemonic. some operaiion code mnemonics do not require an operand. The
Assembler will expect an opemnd ifthe op code mnemonic requircs one. Each
differeni way of wriiing an operand is given in the section called HOw TO
WRITE OPERANDS.
Cornment
A comment appears on the listing ofa Fogram, but does not in any way aIt'ect
the assembled object code. Programmers use comments to €xplain io others (and
to themselves)how a seciion of code works.
There are two ways to hawe the Assembler interpret €ntries as comm€nts. One
way is ro mal.elhe entriesin lhe commenifield.;hich occupiesrhe remainder
of the line afier the insrru.lion fieldtsl. Ar leasr one sDacemusr seDaraLerh€
instruflion fields from rhe commenl field. There may iror be enougL spacein
the comment field for the comment you wish to write th€re. rn th;t c;se it is
best to use one or more lines as comment lines dedicated onlv to makinq com-
ments and conraining no code. To do so. you .nt.r one spaci ara a semicoton
followed by any comment or explanarory markings you de6ire. jtveryrhing
berween rhe iniriai semicolonandlhe m@iffl is ignored by rhe a,sembter. bui
wrx Deprrn(eorn rhe Islrng ot lhe pmgram.
s.mple, Reproducible
ATARI ProgIamming rornr
""^^* 't
6Anz"t.. *qn
'"*'""""Jor+rrl-noar l 4 t I A D
LINENO COMMENT
---/\/\\ ^
Figure 5 shows the entriesin Figue 4 asthey should appearon the screenwhen
entered or ihe keyboard with the recommendedspacing.In general' the spac-
ine recommerded in this manual is the minimum spacingthat willbe correctly
inlerpreied by the Assembler Editor. Ifyou prefer to have more vertical slign-
ment offields, use TAB, raiher than the single sPacingbetween fields that we
recommend. The statements below show various examples of comments cor-
rectly positioned in the staiement.Xach comment in the examplessiarts with
"COMMENT" or semicolon(r.
. The examplesuse By (for b)1€) and ABS (for absotuie)as a one_byteand a two_
byte number, respectjvety.Thi$ use implies rhar the proeram i;cludes defini_
rionsofBy and ABSrs. ror exdmptc:
Hexadecimal Operands
A number is interyrcied as a decimat number unless ii is preceded by g, in
which caseit is interpreied as a hexadecimalnumber.
Examples:
30 sTA 99325
80 ASL 915
Imrnediare Operands
,\n immediate operad js_an operand that contains the dara ofrhe instruction.
The pound sign (/l must be p;sent io indicate an immediar€operand.
E"xamples:
40 LDA i72
70 oRA ,fg3c
1OOOCPY /BY
Example8:
150 LDX 912
250 ROR 33
5OO DEC !Y
Absolute Operands
Absotuie operandsare evaluatedas 16_biinumbers.
Examples:
20 LDX 91212
40 cPY 2345
990 DEC 579
2350 nIT AB5
string operands
ODerands or pai-ls ol operands enclosed in double quotaLion marks are
rr:anslaredinto rhe ATASIII codes of lhe characiers berween lhe quota(ion
marks. The use ofsuch operandsmusl ofcourse be appropriate to lhe U?e of
insrruclion or diredive io which they are appended.
Examples:
..9+1 =S TEN"
10 ADDR .BYTE
"9",
Ex€cutio[ ofthis direciive causesth€ ATASCII numb€rs coresponding to
''', erc.)io be sroredal successive localionsslarJingal ADDR. Note.lhallhe
(") can be
ATASCII represenlationol any character except rhe quoration mark
sroredwirh lhe.BYTL directivehaving a slring operand.
Exhibit I
Sample, Reproducible
ATARI Programming Form
L I N EN O , LABEL OP OPERAND
CODE COMMENT
NOTES:
3
0
USING
THE EDITOR
COMMANDS au n commano rs nor rhe same fhine as an instruction. An insiructioir has a line
EDIT A numbe.; a command has no line number.and is executedimmediatety.
PROGRAM NDw Command
This command clears the edii text bul]br. After this command
restore your sourceprogram; it has been d€stroyed.
Somc programmers ha1,e th€ habit ot giving the NEw coDrmand (or its
e.luivaleDtwith olher asscmblers)whcn thev start a programming sessioD.r.he
r€ason is to remove any .,garbage,,ihal may be in mernory by misrake. SiDce
thc.ATARI PcrsonnlCompuier Sysiem clearsjts mcmory rvtren it is turned or,,
such rouiine useolNDw wouldbe a needlcssprecaution.BecauseNEw destroys
your cniire sorrcc progranr! it is more importanr io dcvetop a trabii of NO,l.
usxrg ii roulinely. You should. .atherJ useNEw in a very dctiberatefashion only
rvhen you rv:Dt to rcmove a sourceprog.am from RAtvr.
DEL Command
This command deletesstatementsfrom your souce progfam.
NUM Command
This command assign$staiement numbers auiomatical|y.
I
I NUMnn
numbcr, fbllowed by a space,is auto
matically displayed.
It
l'i1Xi+l}
ncrement is nn instead of10.
I
mm and the indement to be nn.
10 LDX *$EF
2n CMP MEMORY
NUM 75,5
75
which
A{ier statement number 15, the next statement number v\rould be 20,
NtM c;mmand is cancelled' rhe automatic numbedns of
;;;;;;;;-iJ.;lh;
"i'i"i'""i"Gri -"tl""e until the next number is exactlv equal to an existing
""t"iler. .t sfigftt ctta"ge from the above example iUustrates this:
10 LDX r$EF
20 CMP MEMORY
NUM 15,6
15 TAX
27
other
Caution: You cannot us€the specialkeyboard ediLing-keys to cbange
$atemenis while the NUM command is in effect will
YoLr succeed'n cnangmg
;;;i;;;;; "; tt" "ceen, but, in an exceptioil to the general rule' the con-
t€nts oiihe edit text buffer will not be changed
REN Co'xrmand
This command r€numbers stat€ments in your source program'
FIND Conunand
aft
This commanal finds a specified string The ways to wdte th€ command
shown below.
FIND DAD
finds the lirst occur:rence ofthe character A. The delimiter is the character D.
The delimiter is de{ined as the flrst character fnot cowting space or tab) a{ter
ih€ keyword FIND. This featue is p€rplexing to beginners; its purpose is io
allow you to search for strings that contain slashes (, or, for that matter, any
special characters.
In the general form, symbok l'jthin a pair ofbrackets are optional qualifier8 of
rne comrnano.
REP Comrnand
This command replaces a sp€cified string in your source Fogram with a dif
fa.anr cnp-ifip.l crrind
In these examplesj the strings OLD and NEW are delimited by the charact€r "/'.
As with the FIND comman4 any character except Bpace,tab and RETURN, can
be used as the delimiter. For examplej the comrrand
REP+RTS+BRI(+JA
replac€sall occurences ofRTS with BRK.The de]imiter is the character "+".
'lu, I
Then when you type it in it would appear on the screen as shown in figure 7:
LIST Comrnand
I device: I r,xx,yyl
Format: LIST' I filespec I
Examples: LIST/E:
LISTID:MYFILD
This command is used to display or savea sourcep.ogram. The device where
the sourcep.ogram is to be displayedor savedis give; in the command. rf no
device is specified,the sc.ecn is assumedby default. Other possibledevicesare
the pdnter (tPJ, Program Recorder(/C, and disk d ve (/t1: throuEh /Ds: or
tD:, which defalllts to /D1r. The commands to transfer a prog.am OrST it) to
these various devicesa.e:
cautlon: The DOSmakes sure that every file haBa unique name by deleting old
files ifnecessaly. Therefore, do not name a file you are listing to drskette with
the name of a file that is already stored on the dfukette, unless you wish to
replace the existing ffle with th€ one you are listing.
EDIT
LIST@
10 | =$3000
20 LDY /00
30 REP LDX, ABSX,' Y
40 BNE XEQSAME PAGE
50 INY TALLY
60 JvlP REP
70 ABSX = $3744
80 XXQ = * +$60
90 .xND
EDIT
Lrsr3o @@
30 REP LDX ABSX, Y
EDIT
LrsT 60.80 @
60 JMP REP
70 ABSX=$3744
80 xEQ=. + $60
IDTT
I
The examples above show the appearance ofthe screen, since that is the default
d€vice. Th€ program or the particular lines in the examples could be displayed
on the p nter or sav€d on cassetteor diskette by using the forms ofthe LIST
command described abov€. Not€ that the commarlds tolerate a certain amount
ofvariation in th€ inseftion ofblanks.
PRINT Comnand
This command- is the same as LIST, excepi that it prints statements without
statement numbers.
Erampl€:
EDIT
PRINT E@
* -$3000
I,DY 'OO
REP I,DX ABSX, Y
BNE XEQ SAME PAGX
INY TALLY
JMP REP
ABSX-$3744
xEQ= * +$60
.END
EDIT
PRrNT3O@!1o
REP I,DX ABSXJ Y
I@
EDIT
PRrNr60.80tr4El
JMP REP
ABSX= $3744
xEQ- ' + $60
@D
EDIT
l
After using a PRINT command, no funher command can be enter€d unlil vou
pressE@t, which causesrhe jtDlt messageand culsor to be displayed. '
EI\rTER Comlnand
Format: ENTERrIdevice: I
ltilespecl
Examples: ENTER/C:
ENTER/D:MYFILE
The command ENTER is used to retrieve a souce program. As with the com_
mand LIST. a device has ro be specified,in thi..u"i, rti a."i.e *r,"r" ihe ".o_
grarn i6 siored. There is onty one device, rhe disk drive, on which a named Dro_
gram is stored in a retrievabl€ form. To rctrieve a source program froin a
diskette in a di6k drive, the command is:
ENTER'D:NAME
'where "NAME ' is the aibitrary name you gave to the program rvhen you listed
it on the disketi€. This command cleaft the edit text bufer before transferdng
data from the disk€tte.
To merge a souce program on casseti€with the source Program in the edit text
t, bu{fer, the command is:
INTER'C:,M
i: In the above command, whexe a stat€mmt numb€r is used twice (in the edit iext
: bufer and on tape), the siatement on cassetteprevails.
commands for saving and r€trieving an obj€ct progran are SAVE and LoAD.
Ttrey corespond to r-lST and ENTER, respectively.
.i
rl SAVE Comnrand
l,i
li ronnat:
f,r..;-. )
sAVE/{ ;i.:::. I <addressr.ad&ess2
lil
itL
I,OAD Cotnmand
lli fil€spec
Exampl$r I-OAD/C:
It li LOAD'{D:MYFILE
til1
!l
||l|
To retrieve.dnobjen program that had preyiously been SAVED aod which had
pre!,rousryOeencalled NAMX, rhe command fu:
LOAD/D:NAME wfrere NAME i6 the arbilrary name lhar you gave io rhe
obJeclprogram when you savedit on disketle.
Wherea$embly lisring
ls to be sroredordisplay€d
The defaulr valuesof lhe rhree paramelers of lhe ASM command are lhe edjr
len buffer for the source program. rhe relevision screen for ihe assembly
lilting. and compuier RAM for rhe objecl program rthe ass€mbledprogram). To
assemblea program tr8ing defauli values of ASM. type
ASM E@
8E4437
D064
Operand
Op CodeMnemonic
Label
StatementNumber
lnstruction
Commentfrom Previous
Iine starts here
Address
:'l"J*'fi"Hx:
ffiLT:i$?,'#H.:'#T:il*i?Yff"1*:i:##i?1f
overide s€lections are explained below
iJ:.Hffi$Filrd#ff
:tiIEt,ffi?.ti:,1:T*'J.::,f :.iif{'ffi
:"";:E:?"Tll
:n:'l:#"',llT^t:Y-::Rffi
;Al;x,l;l';"1":ln*;::ii:,1'i
Where Aesembly Listing Is To Be Stored
.xf
ilulilf; *"
Ii;f,i*"
ff ,tlilH#;;".'*";T,;::"':i*"T':""t?:fi
wh€r€ Object Prograln Is To Be Stored
llil;";.;kd
lT$If
;s."-
Ii,8i!-t:?iTii"{:ffi
'-Jfl
You may specify that the assernbl€dprograrn isllo b.estor€d
I:*rfl ""**t[ti:Ti:i"f; hasbeensivenihe extensionoqr'
i:T^";i#:fi t
Extensions are oPtronar'
ll'#:I"'i.:ffi"T?;:it'i:l#lxT:"":'"'f:$3Hgl;Li.
r.ti3:tg;**l*:*$"'ts*r::r:r:uli"#.i1"";,
Note c.-eqld!h:".y"i,llxlTl#:":l#iJT
thatintheASM :f:';::;:*
f;3i# I'i':5',ffiL"i:S.'*#l*"'k;;;oo ."qu"es
th.a""embrer
r"1hat
i;;;;";"" ;iit".";*p-g.* T9,tr f l::*f ;|#J#'JJ"1H5
to permit two pass€s However, you can "li"ffi
with your Progran Recorder. Iirst transfer the program from program
Recorder to the edit text buffer with the command:
ASM/D:SOURCI,TP:,$D2:SEMBLED.OBJ
ffi
The above command takes the souce program that you had previousty stored
on diskeit€ and called SOURCE,assembl€sit, lists the assembledform on ihe
printer, and records on the diskette the machine code translation ofthe prc-
grdm rrhe obrecr programr. The objefl pmgrrm is given rhe nlme
''SLMBLLD.OBJ. Nore rhar commandsof rhi" lorm srorerhe machinemde on
diskette, not in computer RAM.
ASM,rpr g$frffti$
The above command takes the source program from the defaulr edit text buffer,
assemblesand lisis it on the printeias before, and stoles the machine codi
object prcgram direclly into computer RAM.
A directive must have a line number, which it follows by at least two spaces.
The directive LABEL= is an exception-there must be only one spacebefore the
label.
OPT Direriive
This direciive specifiesan option. Th€re are four seis ofoptions. Thes€are:
: OPT NOLIST
. OPT I,IST (this is the defbult condition)
. oPT NOOBJ
, OPT OBJ (ihis is the de{hult condition)
. OPT NOXRR
. OPT ERR (this is ih€ de{bult condition)
. oPT NOqJXCT
. oPT qIECT (this is ihe defautt condition)
The second listed of€ach pair represents the standard or default condiiion. ti{&i I
100 . OPT NOLIST The effec1ofthese directives is to omit from the listed
(part ofsourc€ form ofthe assembledprogram the lines between lines
program) 100 and 200. (The6eline numbers arc arbitrary.)
2OO. OPT LIST
1OO. OPT NOOOBJ Assembly is suppressedbetween lines 100 and 200. The
(part of source effect ofthese direciives is to omit from the objeci prc-
progran) gram code conesponding to the lines between lines 100
200 . oPT oBJ and 200. Memory correspondirg io the6elines is skipped
over, leaving a r€gion of untouched bltes in the object
program. (These line numbers €re arbitrary.)
1OO, OPT NOERR The effect ofthese directives is to omit error m€ss3ges
(pa of souce fo. the assembledprogram lines between lines 1oo
and 200.
2OO, OPT ERR
More than one option may appear on a line. Opiions ar€ ihen separatedby a
comma, as follows:
These directives ale most useful when the assembledprogram is listed on ihe
TITLE and PAGE allow you to divid€ your program listing into s€gments ihat
bear m€ssageswriiten for your own conv€nience,much as you might add short
explanatory notes to sny complex material.
The PAGi directive caus€sthe pdnter to put out six blank lin€s (printers so
equipped will executea TOP oF IORM), followed by the messagesyou have
given for TITLE and PAGE. This causes the messagesto stand out somewhat
from the rest ofthe assembledprogram listing.
Usually there is only one TITLE directive, giving the program nam€and date,
and diferent PAGE directives for giving different page messag€s. Then on
listing the assembled prcgram, the same TITI,E messageon every page would
be followed by a differcnt PAGE message.
The blank lin€s that the PAGEdirective produceson the 4o-columnATARI 820
P nter can be used to break up a long program into segments that can be Wtb
mounted in a notebook.
To .emove a title, use the following form
The PACt di-re(ljve.onirs owr causesa pagebreak -rhe prinrer simpty purs out
a nrunDef oI bl:rDRlrnes
Tab Directive
10 - TAB n1,n2Jn3
The TAB directive seis the lields ofth€ statement as they appear when assem-
bled and lisred_onrhe screenor the prinr".. r..r u. u.e ri,. !p".i,jc e\arnpte ot
slatement 40 ofthe small sampleprogram we previously u6edfor itjusi ration. rr
was wntten as lollowsi
30
40 BEQ XEQ SAME PAGX
50
The previou! example bas a sourceprogrdm rhar was compressedin rhe rbove
falhion. Norethe djfferencebetweenr6e spacingof rhe;Lu.ce Iisringard ihe
"
assembled program. This is arl example ofihe d;fautt.TAB spacing.
The effect ofihe TAB directive ofline xxx is confinedto the aDDearance oflines
following xxx when rhey are assembled and ti6redon rhe p.inr", o. scr."n.
Th€ appearance of this line on the screen will be different only because the w4)
screenhas 38 characterspositions,while the printer has ,10.
These direciives are similar in ihat they are used to insert data rather than
insiructions into the proper placesin the program. Each directlve is slightly
different in ihe manner in which ii insefts data.
BYTE Directiwe
The BYTDdirective reseNes a location (at least one) in memory. The directiv€
increments the program counter to leavespacein memory to be filled by infor-
mation required by the prcgram. The ope.and suppliesthe data to go into that
Exampl€s:
10.....
20 , BYTE 34
30.....
DBYIE Directive
The DBYTEdirective reservestwo locations{br each expressionin the operand.
The value ofthe expressionis assembledwith the high-order bvte first (in the
lower numbe. location).For example:
10 ' =$4000
20 . nBYTr- ABS $3000
when line 20 is assembledand ihe value ofABS + $3000is deiermined to be (say) {,{g/
$5123,$51 is put in location $a000and $23 is pui in location $4001.
WORD Dlr€ctive
The WORD directive is the sam€as the DBYTE directiv€ €xcept that ihe value of
th€ €xpression i6 stored with th€ low-order bj,te Iirst.
For example:
10 ' =$4000
20 .woRD ABS+$3000
60 ABSX=$3744
70 XEQ=* +$60
Sincerhe symbol that is given a value is a tabel, there musr be only one space
aller the sratemenrnumber. The expressionon the right cannoLf,i"", uitue
greater than rffr (hex,. The rdes foi wriring and evaluaringan expressionare
given in Appeodix 4.
When rhe LAaIL= dircciive is used ro give a value ro a labet, the label can be
usedin an operand.by itselc as in siatemenrs30 and aOin the sampte
Fogram.
A delined label may also appear as part ofan expression.Our sampteprogram
ooes nor conlarn an example.so we give one below in line 240.
100 TAB1-$3000
24O TAB2-TAB1+92O
You should oote thar delining a label in rhis wav Eives rhe Iabel a soecific
address:it doe6nor define thaconrenrs of rhe addiesi. rn rhe examp)e,ibove,
TAB1 and TAB2 might be the location oftra.o tabtes that cortained tht values of
variables that your prcgram r€quired.
* = Direcrive
100 '- expression
You should not confuseihe * = directive with the LABEI-- direclive. The * in
* = is not a label. Note, however, that the - = directiv€itselfmay have a label, as
follows:
200 GO * =expression
500 JMP GO
IF Directive
900. IF expression@LABEL
wl
990 LABEL End of conditional assembly
SOURCE CODE
0100 ;CONDITIONALASSEMaIY EXAMPLE
0120 z=o
0130 * =$5000
0140 LDA=$45
0150 . If Z@)ZNOTDQUAT-0
0160 TAX;THIS CODEASSDMBLDD IFF Z=0
0170 ZNOTEQUAL0
0180 . rF Z- 1@ZNOTEQUALI
0190 ASL A ;THIS CODEASSDMBLED IFI Z=1
02oo ZNOTEQUALI
0210 INX;THIS CODEALWAYS ASSEMBLED Wa
ASSEMBLY LISTING (.to-coL forrnat)
0100 ;CONDITIONALASSEMBLYE
XAMPI,E
oooo 0120z = o
0000 0130 *= $5000
5000 A945 0140 LDA r$45
5002 0150 . rF z@zNoTEQUA
LO
5002 AA 0160 TAX ;
THIS CODXASSEMBI,ND IIF Z=O
0170 zNoTEQUAr,o
5003 0180 .IF Z I@ZNOTEQ
UAIl
O19OASL A
0200 ZNOTEQUAT-1
5003 x8 0210 INX ;
THIS CODE AIWAYS ASSEMBLED
O1OO;CONDITIONALASSEMBLYE
XAMP]-E
OOOI O12OZ = 1
0000 0130 *= $5000
5000 ,4.945 0140 r,DA 445
5002 0150 .IF Z@ZNOTEIU1.
LO
0160 TAX ;THIS CODEASSXMBL
ED IFEZ=O
0170 zNoTnQUALO
5002 0180 .IF Z-1@ZNOTE(!
UALl
5002 0A 0190 ASL A
02oo zNoTnQUALI
5003 E8 0210 INX ;
THTSCODE ALIl!r'AYS ASSEMBI,XD
END Directive
loo0 . tND
Every prcgram should have one and only one END directive. It tells the
Assembler to stop assembling. It should com€ at the v€ry end of your source
program. Later, if you decide to add more statements to your program, you
shornd remove the old . END directive and place a new oni at tlie iew end of
your source program. Failue io do m w.ill result in your added sourc€code not
being a€sembled. Thi6 misiake is pafticularly ea6y to make when you make
your additions with the NUM command. It is not always essential to have an
. END directive, but it is good practice.
t"- {
NOTES:
q-{
DEBUGGING
DEBUG
I]
Th€ command to return to the Writer,4ditor is:
x Eso
DEBUG The debug comrrands are listed below. h the list, ,,mmmm,, indicates that the
COMMANDS form ofth€ command may include memory address(es).The actuat methods of
specifying the memory ad&ess(es) and the default addrgssedar€ shown in the
examples given later in this section. If you use the commands with no
address(es), the Debugger assigns a default ;ddress (es):
DR Display Registers
cR change Registers
D or Dmrrunm Display Memory
CorCmmmm ChangeMemory
Mmmmm Move Memory
Vmmmm Verify Memory
L or Lmmmm List Memory with Disassembly
A Assemble One tnstruction Into Memory
Tmmmm Trac€ Operatior
S or Smmmm Single-Step Operation
Gmmmm co fExecute Program)
X Return LoTDITOR
G@ Pressing th€ @ k€y halts ceriain op€rations.
we now give several examplesshowing horir to use the commands.In the
examplesjthe line8ending with @ are edteredon the keyboard. Ttre other
lines show the re8ponseofthe system,as displayedon the screed.
DR Dtsplay Regtsters
r:xample:
EDIT
BUG @
DEBUG
DR@
A=BA X=12 Y-34 P-80 S=DF
DEBUG
I]
The regist€rs and contents are displayed as shown. A is the Accumulator, X and
Y are the Index Registers, P is the Processor Status R€gister, and S is th€ Stack
Pointer.
CR Chang€ Registere
Exarnpl€:
EDIT
BUG 3@!
DEBUG
cR<1,2,3,4,5 @!
DEBUG
II
The elfect ofthe command above is to set th€ cont€nts ofthe rcgisters A, X, Y, P,
and S to 1, 2, 3, 4 and 5.
You can skip rcgisteN by u.sing comnas after the <. For exampl€,
cR<,,,,E2 @
sets th€ Stack Point€r to E2 and l€av€s th€ other r€gisters unchanged. Registers
are changed in order up to l@. For example,
cR<,34 @
5000 A9
DEBUG
tl
This shows that address5000containsthe nwnber A9.
5000 A.9 03 18 E5 F0 4C 23 97
DEBUG
D@@
5008 1a 41 54 41 52 49 20
DEBUG
I]
Dmmmm,,'J'yy where yyw is great€r than mmmlq shows the contents of
addresses mmmm to yyly.
Example:
DEBUG
D5000,500F @
5000 A9 03 18 EB FO 4C 23 91
5008 18 41 54 47 52 49 20 20
DEBUG
tl
The display can be stopped by pressing the BREAK key.
Example:
DEBUG
c5001 <23 @
DEBUG
I]
The effeci ofthe command is to put the number 23 in location 5001. A comna
increments the location to be changed.
Example:
-DEBUG
c5008 <21,rF @
DTBUC
c700B<31,,,87 l@
DEBUG
I'
The firsL command puts 2t and tr in locarions5008 and 500C.respecrively.
The secondcorrlmandpuis 34 and 87 in locations7008 and 700t resp€ctively.
You can conveniently use th€ C command in conjunction with the Display
Memory command, and you n€ed not enter the addres€a second time rvith the C
command. The C command will default to the last specifled addre6s.
Erample:
Dsoool@
5000 A0 03 18 E5 r0 4C 23 91
c<AA,14 @
Dsooo@@
5000 AA 14 18 E5 F0 4C 23 91
DXBUG
I]
Mmrnlrm Move Memory
MnlJJtrrll'l]<yyw,zzzz copies memory from 'Tyy to zzzz to m€mory stariing
at mmrnm. Ad&ess mmmrn must be le8s than ywy or greater thaJJzzzz.lf tbe
origin and destination blocks overlap, rcsults may not be corr€ct.
Example:
DEBUG
M1230<5000,500F @
DEBUG
I]
The command copies the data in location 5000-500I to location 1230-123I.
F-ralnple!
DEBUG
v7000<7100,7123 @
DEBUG
I]
The command compared the contents of 7100'7123 with the contents of
7701 00 7001 22
7105 7a 7005 70
L345, 567 @ This form lists addr€ss345 through 567. Only the
last 20 inshuctions will actu€lly be visible at the
compleiionofrhe responseofthe system.
The command Lmmmm differs from Dmmmm in that Lmmmm disassembles
the contents olmemory.
Example:
EDTT
BUG E@
DEBUG
L5000,0 @
5000 A9 03 LDA r$03
DEBUG
tl
Thtu example Bhows that the Debugger examined the contents of memory
address 5000 and dfuassembled A9 to LDA. Since A9 must have a one-byte
op€ran4 the Debugger made the next byte (the contents of address 5001) the
op€rand. Therefore, although the debugger was only "asked" for the content of
location 5000, it showed a certain amount of int€lig€nce and r€plied by show-
ing the instruction that started at address 5000. l
DNBUG
How€v€r, ifthe {ir6t instruction you wrote was LDA $8A, then you would have
obtained the folowing, apparently inconsistent, results while debuggingl
Example:
DEBUG
L5000,00 A9 8A LDA,fS8A
DEBUG
L5001,0 8A TXA
i,
Because the disassembler starts disassembling from the first address you
specify, you have to take care that the frst address contains the fir6t ble ofa
"real" instruction,
A @
Once in the Ass€mble mode, you stay there until you wish to retlfn to
DIBUGGI& which you may do by pressing @[ (on an empty tine].
To assembl€a]rl instruciion, first enter the address at which you wish to have
the Irrachin€ code inseried. The number that vou enter will be interDreted as a
'folJowed
hex address.Now t}?e -< by at leair one space.rhen the insrruction.
You may omit an addr€ss ifassembly is to be in successive locations.
Example:
EDIT
suc l@
DEBUG
A 831@
5001<LDY $1234@
5001 AC3472 Computer Responds.
<nwl@
. 5004 cB Computer Responds.
| ] @
DEBUG
tl
Since the miDi-ass€mbler assembles only one instruction at a time, it cannot
refer to anorher instrucrion. Therefore, ir cannot interpret a label. Conse-
quenrly. labelsare nor legal in lhe mini-assembler.
The execution stops at a BRK instruction (machine code 00) or when you press
the @ key on the keyboard.
Exatnple:
DEBUG
r5ooo l@
5000 A9 LDA r$03
A=03 X=02 Y-03 P= 34 s=05
5002 18 cLc
A=03 X-02 Y=03 P= 34 S=05
5003 t5 IO SBC $r0
A:03 X=02 Y=03 P= 34 S=05
5005 4C 23 71 JMP $7123
A:03 X=02 Y=03 P- 34 S=05
7723 00 BRK
A=03 X=02 \=O3 P=34 S=05
DXBUG
X Exit
To return to the Xditor typ€:
xEl@
NOTES:
APPENDIX 1
) * ,
ERRORS
when an elror occrlls, the consolespeakergiwesa short "beep" and ihe error
number is displayed.
Errors numbered less than 100 refer to the Assembler Editor cari dge, as
follows:
ERROR
NUMBER
1, The memory available is insufiicient for the program to be assem-
bled.
For the command "DEL xx,yy" the number xx cannot be found.
3. There is an ellor in specifying an address(mini-assembl€r).
4. The ffle named cannoi be loaded.
5. Undelift d lab€l reference.
6. Elror in syntax of a staiement.
7. Label defined more than once.
8. Buffer overflow.
9. There is no label or - before "=".
10. The value ofall expressionis greai€r than 255 where only one bl.te
was requifed.
11. A null srring hasbeen uscdwhere invdlid.
12. The addrcssor addresst}?e specifiedis incorrect.
73. Phaseerror. An inconsistent result has been found from Pass1 io
Pass2.
Undefined forward refercnce.
I-ine is too large.
16. Assembler does not recognize the sou.ce statemeni.
17. Line number i6 too large.
18. IOMIM command was attempted after other command(s)or instruc-
tion(s).LOMEM, ifused, musi be the first command.
19. Therp ic nn cf,rlind r.l.lreqs
Errors
Errors numbered more than 100 refer to ihe Operating Systemand the Disk
Operating System.For a complete list ofDOS errors, refer to the DOs manual.
I
t
I
!
l
d
1
APPENDIX 2
| \ul
ASSEMBLERMNEMONICS
(Alphabetic List)
50 HERE= * +5
Example:
1A
1 9 RTS
20
2 1 TAX
X x Register
Y Y Register
S Stack Pointer
P ProcessorStatusRegister
NOTES:
APPENDIX 4
?\ :E 6qi5 6=H?R!
rh
z eg;ggFHlIFgn
zz
o 4 eel
riEESEt5;fiE
+EEEfiEe
't
,nj
e!4SS 4 €. 4
=gfic! :t9
a : { E; ; E E
f,,,l :
ri ti;; !:8PEn
r'\ ;;Eg!cEigiEH
z
!FElFIgE
a s . . e . E: ! r E ! s
= g = g = 1 I t€ i { i g =
F : : ? i €B t t ; : E t e t
a
BU
a z
i r i H ; =: r3 :F
. : .
H odg 1g g *9*
F I F ?oe i6 F ;:;
rh : VZHA? 6 i*'5
F } E
? EEE
i
*
.l
c . fi sgieF9 eE;
tr 3 6H E b? : 6 H + E
E 5 E 5 - ; 9 : ; 5 h
r r'l
Fl *
i
EfilE
6rai1tE#
F
.',,
lt?i
] F H E
=
X { S ; E : E : 5 - B
iElri
lIEE!
-rEE
Ei;ei:tEI::i
=H
>
1FHH
HiH
g
g?qlEE
l
= E { d ^ i
NOTES:
APPENDIX 5
EXPRESSIONS
Examples:
100 *:$90+1002
200 JMP 3 + 2*25'4./5_3 These instructions are equivalent.
300 JMP 0097
400 JMP $0061 i
1oo LDA *NUM1+NUM2 NUMI and NUM2 must be defined some-
where in the program. The instruction
loads the AccumuGtor with the sum of
the numbers in the locations NUM1 and
NUM2.
600 L-DA i-ABf,L €p$00FF This yields I he low order b}1e of rhe value
610 rr^ QUL ofLABEL_ '|
620 ' 56 "rderorb''teorthe
630 3lf J'ABE *i""*'*;H.ntto i
iI
j
I
I
. . tl
. i
- u
I
il
I
I
NOTES:
APPENDIX 6
)
DIRECTIVES
. IF Expression
. ]-ABEL assemblesfolowing code, up io . LABXL, ifand only if
expre$ion evaluates to zerc.
)
NOTES:
APPENDIX 7
ATASCII CHARACTER SET
AND HEXADECIMAL TO
DECIMAL CONVERSION
t'n o'o'
.p" ""{ .re
r"y -"8 #""u$".'"t
/ne
t ..J,{,
d
r+/
c.' 6$i,. ."*t{"o"o'"'"
0 0
o FI 26 1A E
1 1 G E t 27 1B EI
2 il F
il 2B 1C o
) _.r
3 3 g 10
tr 29 1D tl
4 4
il 11
b 30 o
5 5 il L2
EI 31 1F o
6 6 B 13
u 32 20 Space
7 7 S tr 33 21 !
B B El 75 E 3+ 22
I I E 16 U 35 23
1U tr 1.7 EI 36 24 $
11 B E 1B gl 37 7a
) ! e 1.2 C
g 19 II 3B 26 €",
*1/
.$' ^+
#
,o! ..sv .9,':
.$ '"""{"""t"6_&
..\w^} -g'-o' - r''
*Y.-ilr' 4)
^of o' -$t "
+9" .lo
39 27 3 7 7 71. 4 7 c
40 2B ( 56 3 8 B 72 H
41 29 ) 57 3 9 9 73 49
42 3A .. 4 A J
28 3 8 ; 48 K
M 2C 60 3 C < L
45 2D 61 77 4 D M
46 2E 62 3 E > 7B N
2F 63 3 F ? 79 o
4a 30 0 4 0 @ BO 5 0 P
49 31 1 65 4 7 4 B1 51 A
32 2 66 + 2 8 a2
51. 33 3 67 4 3 C B3 5 3 S
34 4 6B 4 4 D B4 54 T
5 69 4 5 E B5 5 5 U
36 6 70 4 6 F a6 5 6 V
'"$*'$"d
87
{""$
103
,"d"/d$'"t$"*"
67 c 119 77
8B x 104 6B h 720 78
89 59 Y 105 69 I 121 79 v
90 5A z 106 j 122 z
91 i 707 6B 723 7B tr
92 10B 6C I 724 I
93 5D l 109 6D Ifll 7D E
94 110 6E n 726
tr
95 777 6F o 727 D
96 60 o 772 70 p 728 B0 (att* ctdrcte's
97 61 a 773 7 7 q 729 81
99 63 c 115 / J S 131 B3
r.:$ .+ O- -t'-
$Yt,
4::'.arr' -
61v"*$$.."*c .,+'
735 a7 97 167
136 BB 98 A8
737 B9 99 169 A9
138 BA 9A
(EOL)
139 BB 9B uEtt]iut AB
747 BD 9D
tr AD
BE 158 9E
tr 174 AE
8F 9F
tr AF
90 AO BO
.745 91 177 B1
92 778 B2
747 93 A3 779 B3
148 94 B4
749 95 A5
150 96 A6 B6
*1r'
C d "$, ^+
A:: {,5
.O'- ^{re
"-.;$".tt$r"d .lY
0'6'
orr
- ts
$o
own!
c9'
brJ
183 B7 199 C7 D7
185 B9 207 C9 D9
193 C1 209 D1
"t$ .".."$"".*cf
231 E7 F9
232 EB
233 E9 FB
234 FC
EB FD
236 EC FE
f,'?;::n",'
ED FF
238 EE
239 EF
1. ATASCII stands for ATARI ASCIL Letters and nurlrbels hav€ the same values as those in ASCrr, but
some of the special characters are different.
4. To get ATASCITcode, t€ll compurer (dirccr mode) ro pRrNT ASC (,,_) Fill blank rvith tetierJ
ch:racter, or numbel ofcode. Must rse the quoiesl
APPENDIX B
REFERENCES
ATARI PUBLICATIONS
Obtainabl€ from your ATARI dealer, or ATARI Consumer Division, Customer
SupportJ1195Bonegas Avenue, SunnyvaleJCA 94086
ATARI4!00rMOperator'sManual COl4zGa
ATARI S00TMOperator's Manual CO:.476g
ATARI SIoTM Op€rator's Manual CO1476O
ATARI SI5TM O-perator's Manual CO76377
ATARI Disk Op;raring Sysiem II ReferenceManual
ATARj4l0rM Operaroi's'Manual CO148t0
OTHXRPUBLICATIONS
6502 Progt'clmtni.ngManual
SYNERTIK, 3050 Coronado Drive, Santa Clara, CA 95051 or
MOS Technology, 950 RitteDlou& Road, Nori.istown, pA 19401
#ir$#t{i*lfu
i;rt*i#:i':'i'.$"q!'ffi
:l:{f
*x.r.:"*
rd;r:."Iffi
$$ilHf L*|tl:r,*,k*Hr*l}*il:f
:ri",rr#.#di#*1rf ;'":*:i
tr13*lkt${$"::ji:J3";::,.
n+'.:l;'*l*+iili*n**h{+
11ffi:TT#::itJ#ff.li1#:"'ilxr1t,'" rrest
used
todev€,op
machine
' -
i$:.1=:1ixii:,?tir,."-..";fi*"ffi ,]:i{*ffi
il#f :f ."',;'#*:
+:ffi1"i':JTi*JtT i::i"iii,Tl"**'"stemwiththis-'r'r""i'"
m!;xl*";xniil""?Hl{irxid**f.'fi::"l;:i"
. ce ain speciat togical operaiions not feadity
ff.l;."r" avaitabte fr.om
tr+
Most of theseapplications:j.e situaiioDstl:
l**i*i,{*+*i'ilrr;[5t
rl*-*;;i {il.frii*i*
rw
ll,
ry,
*,,1;*i
5i,+,w+illlii:#,*ulrr',
;,:,t,lti:ii",f
il:ri-tii'i*l:J"i:i;F"il:til::t
f.]j:j: :i;1.,.,-j
f{;,;i
:il:,ti"'",i.*
L:ll;i:Tf.::ff"i?:*'J:.1"::;lr;ul;t*:,_l#l
show horv to execute some of the most commonly used funclions. These
programs are meant only for demonstration purposesrrhey certain)y do nor
exercise ihe full power ofthe machine. You may \' ish to entranc€them, adding
whatever features you desirc. In this rvay you will leam mor€ about the ATARI
Personal Computer System.
All four programs have been written to .eside on page 6 ofmemory. These256
bytes have been reserved for your use. On page zero, oriy 7 bles have been
reserved for your use by rhe BASICcarrridge; they are locaLionsgCBthroush
$Dl r203rhro'ugh209r.L;carions$Dl and $D; r2l2 ;nd 2 t3rarealsousable;rh;y
ate Lrsedro rerurn paramereN from machine language roulines ro BASTC
though the USR function. Flrthermore, locations gD6 through gF1 are used
only by ihe floating point package; you may use them from BASIC USR calls if
you do not mind having ihem altered every time an arithmetic operation is
peformed. fyour program runs only with the Assemblex Editor cartridg€ and
not the BASIC cartridge you may us€z€ro page locations gBo through gCF. you
will have to be very sparing in your use of page zero locations, as nine safe
locations will not take you far. It is not wise to usurp other locations on page
z€ro, as they are us€d by the operating system and SASIC; there is no way to
know ifyou ther€by sabotage some vital function and clash the system untit it
is too late. For the moment, we recommend that you limit yours€fto programs
that fit onto page 6 and use less than I byi€s of page zero. The four sample
programs meet that restriction; later we will show you how to make larger
programs with BASIC.
Our fiIst sample program is v€ry simpls it takes two 16-bit numbers, exclusive
OR's them iogether, and returns the resulting 16-bit number to BASIC. lt is only
17 bles long and use6 oriy 4 bytes ofpage zero. we will us€it as a vehicle to
show you the rudiments ofintefacing machine language to BASIC. Here's how:
First, t}?e in the program with the Assembler Editor cartridge in place. Make
sure that you have typed it in properly by assembling th€ program (the
command ASM) and verifying that no ellors are flagged to you. If it squawks
unpleasantly, you have offended its delicat€ sersitivities; note the line number
where the erlor occuffed (CONTROL-1is a handy way to stop the listing so you
can seewhat happen€d). Then list the offending line and corect the typo. you
may r€st assured that ih€ program as we list ii r^/ill indeed assemble without
effors; i{ you t}?e it in exactly as listed it will work fine. Now assemble the
progran with th€ object code going to your nonvolatile storage medium (either
diskette or cas6ette).If you have a disk drive, type in:
ASM,J/D:EXCLOR.OBJ
ASM,.rC:
Follow normal procedures for using these devices.After the object code is
stored to your diskette or casseti€,open the ca ridge slot mver and replacethe
AssemblerEditor cartridge w iih the BASICcaltridge. Closethe cov€r andwhen
you seethe READYprompir load the program from diskette orcassett€tape into
RAM.
lfyou have a diskeite. rype DOSto call DOS.then lwe L ro load a binary file.
when ir a6kswhat file ro load.respondwith:
ExcLoR.oBJmi@
x+*x#l*irffi$
1g*tilixflrfr
?PEEK(1536J
*ff
mfig
#r*.',f..r;r*:ti11f#*"lfu;g;$
l
A-USR(1S36,
1, 3):?A Ggm,
ut;***g*$*ffirim
g**-**$$**#*H*
***$ffi*t**lm*fis
A USRfrs36.
50. ro.s0.200jE!&Et
ffi$;tilg"mqg$*#:s$
e$#5f
$#1lj#l#iF:#"#;
cR. 19:A -USR{15361
F&g{!
fl?:,,f""Fffi
*:il
$hr#iH:,:""#,tt*H?i"T:5#ii;"&.ffi
The lasi sample program demonstrai€sa very useful capabiliiy ofthe ATARr
Personalcomputer System-the display list inierrupt. perhaps you have been itch-
ing to have more than five colors on the scre€n.with display lisi interrupts you
can have up to 128 colors. Her€'sthe idea behind it: the ATARr displav svsiem
u"esa displd) li"r and di"plry memory.The displa) lisr i" a *quence oiinvruc
||on" rhar rpll rhe ' ompurerwhar Eraphicsformat ro usein purringinformarion
onlD lhe scrcpn.rhe displaymemory r" rhe informationSo'ngon{o rbe s.reFn.
The addressofthe b€ginning ofthe display list canbe found inlocations 560and
561 (decimal).Theaddressofthebeginning ofthe display memory can be found
in locaiions 88 and 89 (decimal).won&ous things can be done by changing the
display list; this program demonstrates onlv one of the capabilitiea oa the
di"playIist"yilem. lfbir 7 oIa displaylisr insrrud'on is setrequ;l ro r,. rhen rhe
computer will generate a non-maskable iirierrupt for the 6502 when ir en
counters that display list instruction.
lf w€ place an interrupt routine which changes the color values in the color
registers, the color or the screen wjtl be changed each tim€ a disptay list inter-
ru_ptis ercountered. This program consists oftwo parts: an initializing routine
which sets up the display list interrupt vectors, setsa]l ofthe display lisi instruc-
tions to g€nerate display list inteuupts, and lastly, enables the display lisi inter-
rupts. The s€cond routine actually seruices the display list interrupts by chang-
'ng rhe color value in the color regisrersevery rime it is called. This rourine is
designedio operarcin cRqPHICS5 mode; iL will pur ajl t2B colorsonro lhe
screen. rls rhar enough for you?r To see il iD aflionJ foliow lhe familiar pro-
cedure for Fnlering. a"sembling,saving. and loading rhe program. Then key in
lhe rouowineBASICimmediaTe insLruction:
GR. 5: FOR I= 0 TO 3: COLORI: FORJ=20*I TO 20*I+19: PLOTJ, 3:
DRAWTOJ,39: NEXTJ: NXXT I: A=USR(1536)
we hope that these four sampl€programs have given you a clearer id€a ofhow
your ATARI Assembler Editor cartridge might be useful. Therc are some more
advanced techniques for getting even more us€out ofyour cartridge. The irst
proolem many programmers encolurrer arises when rhey atrempt to wrjTe a
program larger rhan 256 byieb-long.Ii will no longer fir onio pagee and the pro-
grammer musr find a new place ro pur rhe program. The probtem js made
worse Oy the Iact that lhe Operating Sysremand BASTCu6ememory all over the
acldess space.The programmer will have a hard iime t]ndins a safe olace in
memory where the machine langLragerourine wju nor be wip;d our by BASIC
or lhe OperaringSyslem.Thereare a numberofsolurionsro rhisoroblim: ach
solurion has aclvanTage! and djsadvantages.we recommend lhe followine aD-
proach. which is dimcLrl ro undersrand bur i! also rhe mosr usefrdand;fe;i
route. What we are going to do is store the machin€ language program inside a
BASIC program and then touch it up so that it will run from ;nywhere in
2 DIM ES(2179i
Herc the m W symbol m€ans ihat you pre$ the escapekey twice. Now tyT)e
in the following direct comnands:
J=0ffi
c =p2a7 sqw
LIMIT=2179 ffi
The valu€ ofc is the address ofthe b]'ie before the lirst byte ofyoru plograIn.
The value of LIMIT is the length of youl objeci program. Now type GOSUB
25000 gffiffi.
The computer will prini a BASIC line onto the screen. It will look very
strange-all sorts of strang€ characters inside a string. They are the scre€n
representation ofyour object code. To make this lin€ part ofyou BASICprgram
simply move the cursor up to the line and press ffid&. You might reassue
yourself ihat you were succe$ful by entering:
LrsT5 S:fSW&
and vedfying that line 5 r€aly did go in. Now type GOSUB25000 @! again
and another line \vill be pdnted. Enter this one the same way as before.
Continue this process of printing ard entering lines until the entire object
program has been encoded inside BASIC statem€nts. You will know you have
reached this point when the computer pdnts "LAST LINE ' onto the screen.
There is one po$ible hitch with this process. If you have a hex code of $22
(decimal value 34) anywhere in your code it wil be put onto the sceen as a
double quotation mark. This will confuse ihe BASIC interyreter, which ltvill
give you a syntax error when you try to enter the line. Ifihis happens, carefuly
count which byte is th€ oft€nd€r and wdte down the index ofthe anay which
should contain the double quotation mark. Then go back and replac€ th€
offending quotation mark with a blank space; that will keep the BASIC
interyreter happy. Make not€ of all 6uch occumences. When you are done
entering th€ characters, iype in a f€w more lines like:
This line puts the double quotation mark into the 292nd array elem€nt by brute
force. It should come immediately after the lines that declare the string. You
should have a line similar to this for each instance ofihe double ouotation mark.
Ma}.esure lhat you havecountedproperly and pur rhe doublequotarionmarks
into the right places.
Now your object program is a part ofthe BASTCplograIn. You can SAVE and
LOAD the BASIC program and the object prcgram will be saved and loaded
along with ii-a great convenience. You can run the obj€ct program by running
the BASIC program and then executing the command:
A = USR(ADR(E$))
But there is still another possibl€ hitch. Th€ 6502 machine language code is not
fully relocatable; any absolute memory references to the program are certain to
fail. For example, suppose yoru progran has a jumpto-subroutine oSR)
insiruction that refe$ to a subroutine within the object code. This instruction
would rell ii rojump Loa specincaddress.Unforruna-tely.your program has no
way ofknowing at what specific address that subrouiine is stored and thus will
almost ce ainly jump to the wrong addre$. The probl€m arises from the fact
that BASIC might move your object program almost an}'.wh€r€ in memory.
There are s€veral solutions to this problem. The simplest solution is to write
fully relocatable code; that isJ code with no JMP'S, no JSR'Sand no data tables
enclosed within it. Put all data tables and subroutines onto page 6. Ifyou stil
need more space,put very large data tables into the BASIC string and point to
them indirectly. Replace long JMP'S with a bucket brigade of branch
instruciions. These techniques shodd allow you to wdte large machine
languag€ programs.
Exarnple 1.
10
20 ; ROUTINE EXCLOR
30 ; PERFORMSEXCLUSIVE OR OPERATION ON
40 ; TWO BYTES PASSEDTHROUGH THE STACK
; PASSESRESUI,TSDIRECTLY THROUGH USR FUNCTION
60
70 t
0000 80 $0600
00cc 90 TEMP]- $cc TXMPORARY HOLDING LOCATION
00cD O1OO TEMPH $CD TXMPORARY HOI,DING LOCATION
00D4 O11O RESLTL $D4 ADDRESSFOR PASSING RESULTS
00D5 O12O RESLTH $D5 ADDRESSFOR PASSING HIGH RDSULT
0600 68 0130 xxcloR PLA
0601 68 o140 PLA
0602 85CD 0150 STA TEMPH SAVE HIGH BYTE
0604 68 0160 PLA
0605 85CC o170 STA TEMPL SAVE LOW BYTE
0607 68 0180 PLA
0608 45CD 0190 EOR TEMPH PERFORMHIGH EXCLUSIVE OR
060A 85D5 0200 STA RESI-TH STORERESULT
o60c 68 o210 PLA
060D 45CC o220 EOR TEMPL PERFORMlOW XXCLUSIVE OR
060F 85D4 o230 STA RESI,TI, STORERESULT
0611 60 0240 RTS WHAT COULD BE SIMPLER?
0612 0250 .END
Example 2,
10
20 I nourr^"^otr
30 ; GENXRATESNOTDS I,UTH CONTROLLABI,E ATTACK AND DXCAY
40 ; TIMIS
50 ; CALL FROM BASIC WITH COMMAND:
60 ;A=USR(1536,F, A, P, D)
70 i WHERE
80 ; F Is THE FREQUINCY
90 ; A Is THE ATTACK TIMI
0100 ; p IS THE PEAK TrME
. 0110 ;D rs THE DECAY TIME
0720 ;
o13O ; ALL TIMES GIVEN IN UMTS oF 1.6 MII,IIsxCoNDs
oooo ot4o $0600
D2OO O15O AUDT1 = $D2OO AUDIO fREQUENCYREGISTER
D201 0160 AUDCI = $D201 auoro coGnol xpcrsrun
OOCC O17O ATTACK = ATTACK TIME
$CC
OOCD O18O PEAK = PEAK OR PLATXAU TIMN
$CD
OOCE O19O DECAY = $CE DECAY TIMX
0600 68 0200 NOTE PLA
0601 68 o21O PLA
0602 6a a22n PLA
0603 8DOOD2 O23O STA AUDI1 SNTIREQUENCY
0606 68 o2ao PLA
0607 85CC O25O STA AfiACK SET ATTACK TIME
0608 68 0260 PLA
060A 68 0270 PLA
0608 68 0280 PLl^
O6OC 85CD O29O STA PEAK SET PEAK TIME
060E 68 0300 PLA
0601 68 0310 Pr,A
0610 85CN O32O STA DXCAY SETDECAY TIME
0330 ;
0340 ; ATTACK LOOP
0350 :
0612 A9AO 0360 LDA /$AO START WITH ZERO VOLUME
0674 ADO7D? O37O ATI,OOP STA AUDC1
0617 A6CC O38O I,DX ATTACK
0619 204106 0390 JSR Dfl,AY
o61C 18 0400 cLc
051D 6901 0410 ADC ,901
061F C9B0 O42O cMP ,gBO
0621 D0F1 0430 ENn ATLOOP
0440 ;
0450 ; PEAK LOOP
0460 ;
0623 A90E O47O LDA ,gOE
0625 A6CD O48O PKI,OOP LDX PEAK
0627 204106 0490 JSR DILAY
0624 38 0500 sEc
0628 E901 0510 sBc #g01
062D D0F6 o52O 3NE PKT,OOP
0530 ;
0540 ; DxCAy LOOP
0550 ;
O62E Ag1^F 0560 LDA ,$AF
0631 8D01D2 0570 DcLooP sTA AUDC1
0634 A6CE 0580 LDX DECAY
oa36 204106 0590 JSR DXLAY
0639 38 0600 sxc
063"1 E901 0610 sBc r$01
063C C99F 0620 cMP *$9F
063E D0F1 0630 BNE DCLOOP
0640 60 0640 RTS
0650 ;
0641 A013 0660 DELAY LDY r$13
0643 8a 0670 DELAY2 DEY
0644 D0rD 0680 BNN DLLAYZ
0646 CA 0690 DEX
0647 DOFA 0700 BNX DEI,AY
0649 60 0770 RTS
064A 0720 .END
Example 3.
10
20 ;
; ROUTINE SPLAY
40 ; PUTS A PRETTY DISPI,AY ONTO THE SCRNEN
50 ; CALI, IROM BASIC WITH THE FOLLOWING COMMANDS
60 ; GR. 19: A- USR(1536)
70 ; EXIT PROGRAM WITH &3 m
80
90
0100 $0600
00cc 0110 TEMP $CC TEMPORARY LOCATION
00cD 0720 xl-oc $cD HORIZONTAL POSITION OF PIXEL
00cE 0130 YLOC $CE VERTICAL POSITION OF PIXEL
00cF 0140 DIST $cF DIST. OF PIXEL FROM SCREENCENTER
00D0 0150 PHASE $D0 COLOR P}IASE
00D1 0160 COI,OR $Dl COLORCHOICE
0058 0770 SAVMSC $58 POINTER TO BEG. OF DISPI,AY MEMORY
o2c4 0180 coLoRo $o2c4 LOCATION OF COLOR REGISTERS
D20A 0190 RANDOM = $D2OA HARDWARE RANDOM NUMBER LOCATION
0600 68 0200 SPI-AY PLA POPA ZEROFROM STACK
0601 85D0 0210 STA PHASE STOREIT IN PHASX
0603 AA 0220 TAX SET COUNTXR
0230
0240 ; THIS IS THE MAIN PROGRAM LOOP
0250 ; FIRST WE RANDOMLY CHOOSETHE SCREENLOC. TO MODIFY
0260 ; SCREENIS 40 PIXELS HORIZONTALLY BY 24 PIXEI,S VERTICALLY
o270 ; WITH 4 HORIZONTAI,I,Y ADJACENT PIXELS PER BYTE
0240 ; HXNCX THERE ARE 10 BYTXS PER HORIZONTAL ROW
0290 ; AND 2l ROWS FOR A TOTAL OF 240 BYTES
0300 ; TO REPRESENTTHE SCREEN
0310
o32n ;
0330
0604 ADoAD2 0340 BEGIN LDA RANDOM GET A IIANDOM NUMBER
0607 290f 0350 AND /$OF MASK OFF I,OWXR NYBBI,E
0609 c90A 0360 CMP '$OA MUST BE SMALLER TIIAN 10
0608 B0F7 0370 BCS BEGIN IF NOT, TRY AGAIN
srA xr'oc sroRn
rHxRE'u,r
iiSi 35"' 3:33
3313?8Sj :f: :* 1j0u crr x_DrsrANcE
rRoMCENTER
B:t;i;" 3j* # #, i:'J;:?:iilf,ff,u'iffi,?l*
:::l 9:Sl o44o aoc o$0,
::i: ljri_ i1i3ff""". ilx il'I".,:iI"^1H.ffi.*,HJ#i1,,,.
3:f ,!r MASKoFrLowER
5 Brrs
:31: ra L.)_"
oezznoiz ;;; ;gi. 1'{1* ily$,?.,,,H#l#1il"?,._"*o
i:# 3:"' ff?8 ""oc*;;;;";;L"r*?*'
*l ,$ic
3r; Hff y.Drsr
c-Er fRoM.ENTER
oFscRErN
ffi3 :::
i!;3i3" os6o
i:# :S f*, flG:X'iTi,f,flXtrf#H,",
o62E 6901 io" oso,
o57O ,
; Now CALCULATE
rm cor,oRTo pur rNro THrsposrrroN
3;33
0630 1a .0600 xB
0631 65CI
cLc
0610
0633 65DO i:9 ?].. TorAL DrsTrRoM CENTER
Of ScREf,N
o62n ADC PHASE COLOR P}IASE OFFSET
0630 :
rtrs r aNl I Now crvx rHEcoloRro usx
!ff8 ;
0635 291f 0660 AND r$1F MASK OUT BITS 5, 6, AND 7
0637 4A 0670 ]-SR A
0638 4A 0680 LSR A
0639 4A 0690
063A :.ll A sHrfT oFF Brrs 0, 1, AND 2
85D1 0700 5IA COLOR STORERJGIJT.ruSTFIEURI]SULT
0710 :
O72O ; Now wx MUST DETERMINI wHIcH oF THE
0730 4 PIxxLS
i rN THr BYTE Cf,T TIIE COLOR
0740 :
:::: fl?9^* :::9 LDA RTNDOM
0;; ;;" !ti." ^o' GErA RANDoM No.BrrwEEN
0 AND3
fl' usEIrAsA couNrER
0642 Fooz i7; EQ .NoslIFT
;i-: ^- -
SKIPAIIEAD lI rT Is o
uTso ;
t** o*o twrcE FoREACH
srEPrNY
3313 ;
06D1 O82O SIIFTLP ASI, COI,OR
06D1 0430 ASL COtoR
88 0840 DEY
DOF9 0850 BNE SHI1TLP
0860 ;
O87O : N^OW MUST CALCULATE WH_LRIIN.MI]MORY
UddO _WI TO pUT OUR
; SQUARE
]15CE O89O NOSHFT LDA YLOC
OA GIT VERT]CAL POSMON
,trsL A \'LOC.2
064E 85CC 0910 STA TEMP SAVE IT FOR A FXW MICROSECONDS
0650 0A 0920 ASL A
0651 0A 0930 ASL A YLOC*8
0652 65CC 0940 ADC TEMP ADD IN YI,OC*2
0950
0960 ; RESULTIN ACCUMULATORIS YLOC*10
4970 ; REMEMBER,THERE ARE TEN BYTES PER SCRXENRO.\ry
0980
0654 65CD 0990 ADC X],OC
1000 ;
1010 ; RESULTIS MEMORYLOCATION OF DESIREDPIXEL GROUP
0656 A.8 7020 TAY
0657 A5D1 1030 LDA COLOR GET COLOR BYTE
0659 9158 1040 STA (SAVMSC),Y
PUT IT ONTO THE SCREEN
0658 CA 1050 DXX \^/E S}IALL PUT 254 MORESQUARES
065C DOA6 1060 BNE BEGIN ONTO THE SCREEN
1070
1080 ; END OI MAIN INNER LOOP
1090 ;
065E C6D0 1100 DEC PHASE STEPCOLORPHASEFOR EXPLOSION
0660 A5D0 1110 LDA PHASE
0662 297F 1120 AND '$1F EVERY 32 PHASE STEPS
0664 D09E 1130 BNE BEGIN WE C}1ANGE COLOR REGISTERS
1740 ; THIS SECTIONUSES BITS 5 AND 6 OF PHASE
1150 ; TO CHOOSE WHICH COLOR REGISTXR TO MODIFY
1160
0666 A5D0 7770 LDA PHASE
066A 4A 1180 LSR A
0669 4A 1190 LSR A
0664 4A 1200 LSR A
0668 4,{ 1.210 I,SR A
066C 4,4. 1220 LSR A
066D 2903 1230 AND /$03
066F AA 1240 TAX
1250 ;
0670 /'DoADz 1260 LDA RANDOM CHOOSEA RANDOM COLOR
0673 9DC402 1270 STA PUT NEW COLORINTO COLORREG,
COLORO,X
0676 4CO406 1280 JMP BEGIN START ALL OVER
0679 1290 .END
Exampl€ 4.
10
20 , "-A.t"U', CO"O* O-A""tt"
30 ; PUTS ALL 128 COLORSONTO THE SCREXN
40 i CALL FROM BASICWITH THE FOLLOWING COMMANDS:
50 ;GR.5
60 ; FORI-0 TO 3: COLORI: FORJ-20*I TO 20*I+19: PI-OTJ, 3:
65 ; DRA1ir'TOJ, 39: NiXT J: NEXT I
70 ; A =USR(1536)
80 ; BASIC IS STILL USABLE
90 ; EXIT WITH SYSTEMRESETKEY
0100 ;
0110 ;
0000 o12O 90600
00cc O13O POINTA = $CC POINTERTO DISPLAYI,IST
0OcE O14O COI,CNT = $CE KEEPSTRACK OF COLOR I,vE ARE ON
00cr O15O DECK = $CF BIT O KEEPSTRACK OF WHICH DECK
0230 0160 DSLSTL = 90230 o. s. DIspr,Ay LrsT ADDRESS
DlOE O17O NMIEN = NON-MASKABLE INTERRUPT ENABLE
$D4OE
D{OF O18O NMIRIS = $D+Of NON-MASKAELI INTIRRU|T RESET
D4OF O19O NMIST = $D4OF NON-MASKABLE INTERRUPT STATUS
0200 0200 vDslsr = 90200 DrspLAyr,rsr rNTERRupr
vriioi--
DOlA O21O COI,BAK = $DO1A BACKGROUNDCOLORREGISTER
D016 O22O COLPEO = gD016 COLOR REGISTER,0
DO17 0230 COLPF1 = gD017 CO]_ORREGISTER,f1
D018 0244 COLPF2 = $DO1S COLOR REGISTXR.2
D4OA 0250 wsyNc = gD,r0A wArT FOR HORTZONTAL SYNC
0600 68 0260 SETUP PI,A CLEAN STACK
0270 ;
0280 ; SnT UP POINTER ON PAGE ZERO
0290 ;
0601 AD3002 0300 LDA DS]-STL
0604 85CC 0310 STA POTNTA
0606 AD3102 O32O LDA DSLSTL+1
0609 85CD O33O STA POINTA+ 1
0340 ;
0608 A007 0350 LDy tgoT POINT TO 3RD MODE BYTX
060D A98A 0360 LDA #gBA NEw MODE BYTE
0370 ;
O38O ; STORE16 DISPLAY ]-IST INTERRUPT MoDE BYTES
0390 ;
060F 91CC O4OO LOOP 1 STA (POINTA), Y
0611 C8 0410 INy
0672 C017 O42O Cpy iglz
0614 D0F9 O43O BNE LOOPI
0440 ;
0450 ; SKIP IOUR BLANK LrNES
0460 ;
0616 C8 O47O INy
0617 C8 0480 INy
0618 C8 0490 INy
0619 C8 0500 INy
0510 ;
O52O ; STORE16 MOREDISPLAYLIST INTERRUPTMODE BYTIS
0530 ;
0614 91CC o54O LOOPZ STA (POINTA)j Y
061C C8 o55o INy
061D C02B os6o cpy *$28
061F DOFg O57O BNE I,OOP2
0580 ;
0590 ; SrT UP DISPLAYLrsT INTERRUPTVECTOR
0600 ;
0621 A950 0610 rDA rgso
0623 8D0002 0620 STA VDSI,ST
062A A906 0630 LDA rg06
062A 4D7020640 STA VDS]-ST+ 1
0650 ;
0628 A900 0660 LDA /$00
O62D 85CE 0670 STA COI,CNT INITIALIZE COLOR COUNTER
O62F 85CF 0680 STA DECK INITIALIZE DECK COUNTER
0631 8DOFD4 0690 STA NMIRES RESETINTRPT. STATUS REGISTER
0634 ADOFD4 OTOO WAIT ]-DA NMIST GET INTERRUPT STATUS REGISTER
0637 2940 O71O AND r$40 rrAS !'ERTICA] BLANK OCCURRED?
0639 FOTg O72O BEQ WAIT NO, KEEP CHECKING
0638 ADOED4 O73O LDA NMEN \TS, ENABLX DISPLAY LIST
063E 0980 O74O ORA /$80
0640 8DOED4 O75O STA NMIXN THIS XNABLES DLI
0643 60 0760 RTS AI,I, DONE
0770 ;
0780 ;DISPLAY LIST INTERRUPTSERVICEROUTINE
0790 ;
0644 0800 $0650
0650 48 O81O DLISRV PIIA SAVE ACCUMULATOR
0651 AsCN OA2O I,DA COLCNT GET CURRENT COLOR
0653 18 0830 Cr-C
0654 6910 0840 ADC '$10 NEXT COLOR
0656 85CE 0850 STA COLCNT SAVE tT
0658 DO13 0860 BNE OVER END OF DXCK?
0870 . ;
0880 ; xND OF DICK, BLACKIN SCREEN
0890 ;
065A SDOAD{ O9OO STA WSYNC WAIT TOR NXXT SCAN I,INE
O65D SDOADO O91O STA COI,BAK BLACKEN ALL REGISTERS
0660 8D16D0 0920 STA COLPFo
0663 8D17D0 0930 STA COLPF1
0669 E6CF 0940 STA COLPEz
0668 68 O95O INC DECK NEXT DECK
O66C 40 0960 PLA RESTOREACCUMULATOR
O97O RTI DONE
0980 ;
0990 ; PUT OUT NEXT COLOR,WITH FOURI-UMINOSITIES
1000 ;
O66D AsCI 1010 Or,aER LDA DECK UPPEROR LOWER DECK?
o66t 2901 1020 AND r$01 MASK OFf RE]-XVANT BIT
0671 0A 1030 ASL A SHIFT INTO HIGH ]-UMINOSITY
0672 0A 1040 ASL A
0673 0A 1050 ASL A
0674 05CE 1060 ORA COLCNT MERGEWITH COLOR NYBBLE
0676 8D0AD4 1070 STA WSYNC WAIT FOR NEXT SCAN LINE
0679 8D1AD0 1080 STA COLBAK STORECOI,OR
067C 6902 1090 ADC /$02 NXXT HIGHER LUMINOSITY
067E 8D16D0 1100 STA COLPFO STORECOI,OR
0687 6902 1110 ADC r$02 NEXT HIGHER I,UMINOSITY
0683 8D17D0 1120 STA CO'-PTI STORECOLOR
0686 6902 1130 ADC r$02 NEXT HIG}IER LUMINOSITY
0688 8D18D0 1140 STA CO]-PF2 STORECOLOR
0688 68 1150 PLA RESTOREACCUMUI,ATOR
068C 40 1160 RTI DONE
APPENDIX 10
QUICK REFERENCE:
COMMANDS RECOGNIZED BY
THE ASSEMBLER EDITOR
Y."1i:r""i'.Ti;,r":',
lll*lilri{t:ffi1#"trfffTi#'t":l$::"Hr*rf
EDITOR Ref€renoe
Page No,
NUMxx, yy providesduro line numberingsrrfring
al xx jn increments 15
OI Jry
RENxx, yy r€nulnbels all statemeniB in inclemenis
ofly, starting 16
DEBUGGER
Mxxxx<yryy, zzzz copi€s memory block yyyy t}rroltg}tr zzzz \r]to block starting 3a
Vxxxx< yyr.y, zzzz compares memory block yyw tbro.ug}] zzzz with block 38
starting at xxxx, displaying mismatches.
x 41,
APPENDIX 11
MODIFYING DOS I TO MAKE
BINARY HEADERS COMPATIBLE WITH
ASSEMBLER EDITOR CARTRIDGE
fq+'i*$'r:r*.:nf""rH.iri';i*,I.tl-.
;:,fi?,f
'1",*:#j#?*:n|::#jj;i;;FFFi;;''til;;
:;H",fl
EDIT
10 r:600
20 LDA r$IF
30 STA $u41
40 STA $2448
50 STA $148F
60 STA $14C0
70 END
DoS I will now have header bles that are fully compatible with the Assembler
Editor cart dge.
Instead of using the Modilication Program, you could use BASIC io POKE
d€cimal255 inio memory locations 9281J9284,5311rand 5312. A{ier making
the pokes, t}?e DoS @ to display the Dos M€nu. Type H l@l to writ€
the DoS modification onto diskeite.
NOTES:
INSTRUCTION
SET (oPERAT|ON
CODES)
!L! l
tr
fl
{Ii I =
t
r- t
t
-tI- +
l -
++
1 1
T
+r
-
r!t!:r"t tl1,r!
/\
ATART
a warnercommuf,calions
companyO