0% found this document useful (0 votes)
82 views92 pages

ATARIAssembler Editor User Manual

This document lists various error codes and their corresponding messages that may occur when using an ATARI computer system. There are over 170 different error codes grouped into categories such as memory errors, input/output errors, and device errors. The error codes are accompanied by brief explanations of what caused each error.

Uploaded by

ali avcı
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views92 pages

ATARIAssembler Editor User Manual

This document lists various error codes and their corresponding messages that may occur when using an ATARI computer system. There are over 170 different error codes grouped into categories such as memory errors, input/output errors, and device errors. The error codes are accompanied by brief explanations of what caused each error.

Uploaded by

ali avcı
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 92

ERROR CODES

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

-lfoter The fouowing are INI'UT/OUTPUT er-


rors rhdl rerult during rhe useof di"k dri!e".
prinlerr. or other acce.sorydevice\.ruflher in-
formation is provided with th€ auxiliary hard'

19 LOAD program too long


20 Device number larger
za LOAD file erlor
aza BREAK abort
7zs IOCB
13o Nonexistent device
131 IOCBwrite only
132 Invalid command
13J Device of lile not open
7J4 Bad IoCB number
13s IOCBread only error
136 EOF
737 Truncated record
13a Device timeout
139 Device NAK
74o Serialbus
117 Cursor out of range ror explmation of Errcr Messges see Appendix 1.
ASSEMBLEREDITOR
MANUAL

/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.

This manual stafls by showing the structure of sLarementsin assembly


language.The mdnual then illusrraresLhediflereni rype6of6502 operands.Thi
Assembl€r Editor ca:rtridge contains three separate programs:

. tDlT (rdiror program). Helpsyou pur programmingsrarements in a form


rhe Ahrembler (ASMIprogram undersrands.The tDIT program leis you u"e
a prinier to p.int a lisiing ofyour program. programs can alsobe stored and
rccalled using ENTIRJ LIST and SAVX, LOAD. The Assembler Ediior allows
automatic numbedng, rerumbering, delete,find and .eplace.

. ASM (Assemblerprogram) - Take6 the program statementsyou ceate in


the EDIT step and converts to machine code.
. DEBUGGER- Hetps you trace through the program stepsby running the
program a step at a time while displaying th€ contents of important internal
6502 registers. The DEBUGGERprogram also contains programming
rcutines which allow you io display registers, change register contentsJ
display memory, change memory contents, move memory, ve fy memory,
list memory with disassembly,assembleone instruction into memory, go
(execuie prograd, exit. The disassembly rouiine is especially usefut ir
rcading and understanding machine languagecode.

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

3 USING THE EDITOR


Commandsto Edit a Program 15
NEW Command 7.5
DEL Command 15
NUM Command 15
REN Command 15
FIND Command 7.5
REPCommand 77
Commandsto Save(or Display)
and RetrievePrograms 19
LIST Command 19
PRINT Command 27
ENTERCommand 27
SAVE Command
LOAD Command
4 USING THE ASSEMBLER
The ASM Command 2E
Directives 27
OPT Directive 27
TITLE and PAGEDirectives 2A
TAB Directive 2S
BYTE,DBYTE,and WORD Directives 30
BYTE 30
DBYTE 30
w'ORD 31
LABEL = Directive 31
* = Directive 31
IF Directive 32
END Directive

5 USING THE DEBUGGER


p1rrn^cp ^fnphrrddpr
aallihd +Lp np}!'rddpr

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.

lfyou have had no experiencewirh compurer!and no DroerammrndexDer-


ien,e. rhen thi" manudlis pr obabtJrooadvancedtor you anJyou st oita "rarr
Dy wntlng someprograms using ATARr BASICand your ATARr personalCom,
pt'rcr Sysremrobc, ome lamiliar s rlh proqramminein eenp1.3t.
Readineoneol
thF hooksre.nmn,endedin Appcndi\ I wi help you leirn as.embtvlanguase.

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,.

YouncednIr havpany equipmenrej.epr rhe ATARI rer$onatCompurcrStsrFm


.onsole. your lele\ision or d \ideo moniror tor disotav. dnd-rhe 4fARr
AssemblprLdirorcar-rridge. However.wirhour a pcrmanenisror"gedeviceyou
wrrr havelo pnle' yo,'r programon rhe kpyboardea(h rime you u i.h to uspir.
This canbp_rpdious and rime-consuming.An ATARI 4 ro v irogrrm necorder,
) ATARI 810rMDisk Ddve, or ATARr 8151MDuat Disk Drive (do;bte densitvl is;
pr:ctrcalne,e-sitv,
The ATARI 410 Program Recorder i6 an acc€ssory that functions with ihe
ATARI 400and LheATART800Per"onalComputerSystems. The proper opFra-
tion ofyour ProgramRecorderis expla;nedin Secljon8 ofrhP ATARI 400and
ATARI 800 Opdator's Manuals.Befor€usiDg the Program Record€r with the
Assembler Editor cartridge, be sure you know how to operate the Program
Recoder. The disk &ives are accessodesthat function with any ATARI Per-
sonal Comput€r system with ai leasi 16K RAM. To us€a disk drive you need a
specialprogram, the Di6k operatiDg System(DoSJ.At least 16K of memory is
required to accommodateDOS.Consequently,if you are using an ATARI 400
Personal Computer System, you must upgrade it from 8K to 16K (RAM). This can
be done ai any ATARI ServiceCenter.

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

To translate youl source code into object code.


To monitor and debug the operation of your object program

These thiee rasksare handled wirh rhree programsincluded in lhe ATARI


As6embler Ediror. The firsr program. called-rhi bditor. Provides many handy
features for €nte ng the program and making insertions, deletions, and co ec-
tions to it. It also aliows you to save and retriive your source code The second
program, called lhe AssFmbler,will translateyour sourceprogram 'nio an'
-assemblylisting.
;bieir prcsram. whi)e doing so,ir will provideyou with an
a ;sct;l listing in which your sourcepiogram is lined up side by side with rhe
resultingobiecl program.The rhjrd progrdm is.a ed rhe Debugspri;r helps
you to monnoranddFbugyolll objen program.The relarionshipberweenrhese
ihree programs is depicted as follows:

YOU

SourceProgram ObjectProgram

Figure 7. Rel.,tiot?.ship ofvariorr,s pans of Assembter Editor .llrtridee


to you and your softwdre,

In Section3 we explain the Editor; in Section4, the Assemble( and in Section5.


rhe Debugger.There are somefunddmentatideauwe musr explainfirsl.
),

GETTING
STARTED

ALLOCATING The very lirst.decisionyou must make when you sii down to write your source
MEMORY program involves the allocationofmcDlory spac€.

All p, ogram".,lgdrdlpss,,f l"ngu"ue.occrrplme ,ory \p4ce.rhe(.ompurerha"


a rrmrrc(ldrnounlot ,npmoryand mu5t manr.'Fiti merno|v.dr.full\ . alloLJlmu
p " r t i o n "o f m . r , r o l Jr o r p r o g r d m . d r r a . d r . p i r y " f , a , " . r , , d . o r o l t .r r . , . ; , , i i
donr automdlRatlyin BASIC.c,,rhc BASICu".r nced nor worcv about$ hele in
nremurylri. p'ogrJm and daradrc,tored. Su.h is nor quire rie crsc rvirh rhe
As.emblpr LdIor c"r'rridge.y,,u hare Jhe powpr ro ptlrlF vour L,ruerams
rnJ whei e in me ory, haryou dcn.e. u irh rhF po-", ,oln.sr6.,.sp;n,i"b,tirl.
to allocatcmenor.v iviselv,

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:

os DOS 180 EditToxt Empty Display


Bufter BAU

EigtJre 2. Mernorynap without rtse of LOMEN.

'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.

Liberally estimat€ihe amouni of memory yorr object'ror pm$am wi[ require,


then subtract that amount from ihe third numb".. i*t.i i""u.a"... .ir.-i
the rpsulr down. for example.ifyou rhoughl rhar your objen code mighr
require 1.5K,you'd subtract 2K from g5C1Fto g€t $541Fand then for simptclty
(and additional insurance) you would round atl the way down to
$5004. yo;
would therefore store your object cod€ at g5OOo,confident that it would not
encroach on the display memory. More conservaiiwe estimates and greater carc
would be necessary if m€mory werc in short supply.

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

This is a good safeway to sra when you are !rill tearninqassembtylanguase


programming and are wriring only very shorr proeramsi as your proE"raris
grow larger, you will wanr ro move rhem offpdgi 6 ;nd usepag; 6 io; d; and

t he secondsrrdlegy is 10 bump rhe edir rexr butTpr{your sourceprogram) ut)-


waro rn memory. leavrng some emply memory spare betow ir. you can rhen
praceyour oDJecl codc into this empry space.FigL're3 showsrhe adjuslmFnlof
rne memory map.
I
i

t I
os Dos Empty 180 EdilTexl
Buffer I Emply Dlsplay

Top ol
BAM YoUiRAM

Figure 3. Memory tnap with ttse of LOMEM.

This bumping is accomplishedwfth a speciat cornmand ca ed LOMIIM. The


command rs specialbecauseir must be rhe very fir"l command you enler aner
iuning on the computer. Its form is simple:

LOMEM xxxx g!19fiffi1

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

The - directive will be followed by your sour.e proeram. The solDceDroerall


is composed ot strlempnrs. The sraremenrsmuit be writren .ccord'i"j," .
rigorousfbrmar.The rulestor wriring slaremenrs are given in rhe nexrs;tion.
PROGRAM A source program consistsof statements.Each statement is ierminated with
g:!8W. A statementmay be 1-106charact€rslong, or almost ihree lines on the
FORMAT-HO\^/
scleen. A statement is al6o called a line. The distinction is made between a
TO WRITE A physical line (a line on the screen)and a logical line (the stdng ofcharacie$, up
STATEMENT. to three physical lines between ffiFs).

A siatemenican have up io five parts or "fields": the statementnumber, alabel,


the operation code mnemonic or dircctive, an operand, and a comment. These
five fields occupy successive positions in the statement, with the statemeni
number coming first and the comment coming last. Fields ar€ separated
("delimited"l by single spaces.

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

Ope.ation Code Mnemonic


The operation mde (or op code) mnemonic must be one of thos€ given in
Appendix 2. It musi be enter€d in the {ield that sta s at least two spacesafter
the statement number, or one spac€al}er a label. An operation code mnemonic
in th€ wrong field will not be ideniified as an error in the Edit mode, but will be
flagged when you assembleih€ program (Eror 6).

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.

A sampleprogramming form lor assemblylanguageir rcproduced as figule 4.


The form shows examplesof how to enrer line number. Iibel. op code.operand
and comments. These classesof entry ar€ lined up vertically on the program-
ming form. Most vadation occurs in the method of ent€rinE a comment.
Therefore.Figure4 includesexamplesofthe rariousways ro enier commenrs.

s.mple, Reproducible
ATARI ProgIamming rornr

""^^* 't
6Anz"t.. *qn
'"*'""""Jor+rrl-noar l 4 t I A D

LINENO COMMENT

t0 LT6L Ultt4AJf tl at'4Ae f f'rLn


-lt+
bt4t6 r tl rnaabJr f,F.L:>
tt^tlf.rlr irJ'1+t6 t.rE, *r1h^ta
'tiLAL!4 Utlli^lU-6 .a -ll+6 Dle
lruAE;r bi-r1t' l,itJ. bnr
J60 t tA hn-7*13 ^hHl\arr$ t)1.
++,b,
n1 ^nmt ntt
t-e'aLA6€L

,'P?tlt6r1 t t^lr l!4^\ . ^'tdtn<


o^\Luslr'.tr5 . lertJ. "aA . t)lE
Jal ct,.'.|.qti;6 o a1 T1E tA#.L
d A]Jtllx u.JtlM4!4 At Ar,c t "

---/\/\\ ^

Figvre .Exdrnple of haw ta wfite Line No.., L.tbel, Op Code,Operani!,


and Ldbel on the Atari progratnningforn.
The spacingon ihe pmgramming form is not the sameas the spacingto be used
on the screenjcontrolled by keyboard eDtry. On the screenthe classesofeniry
(the {i€lds) are not lined up verticaly. The screen has 38 positions (you can
change it to a maximum of40), {ewer than the progrsrnming form) and that is
the main reasonnot to use many spacesbetween fields. Another differencebe-
r\{raparound' on the
tw€€n the programming form and screen is the
screen-auiomatic continuation of charactersonto the next line.

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.

Figure 5. Stct,a,nents as ttEy would appear on tlle screel:, when entereil


on the keybooril rrith the reconmendcd spacing. The v.trb s
vrays to enter cot'-,'tents arc illustrdElL Conapdre with FEu]e 4.
HOW TO \ /RITE This sectionshowshow to write operands.The examplesusestatemenrnumber
OPERANDS xxxx (alsocaled line number xxxx). An insiructi; entered without a siate_
ment number is not alowed by the Editor.

. 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:

0100 By= 155


0200 1\85=567
pl€aserefer to rhe d€scripiion ofthe r,ABL = direcrive
fbr an exptanarionofthe
definitions of lines 1ooand 200.

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

Pag€ Zero Operands


when_an operand is a number less than 2s5 decimdl, (FF h€x) and is not
immediate, the number is inrerpreted a$ a page zero address.

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

Absolure tndexed Operands


An absotut€indexed operand uses regist$ x or y. The operand is written
_,x or _,Y
Examplesr
10 AND $3C26,x
110 F,OR 20955,Y
1110 STA

Non-Indexed Indireca operands


ln Eeneral.an indjrecl operand is wrilten with pa-rentbesesThe addresswirhin
rbe-Darenihesesi" an i;rermediare addresswhich itself con(ains Ihe effective
addrless.The onlv instrudion with a non-indexedindirecl operand isJump In'
dired. The operand is a number enclosedin parentheses.The parcnlhesesin the
operand enciosea number or an expression lhar is inlerpreted ae an inter-
mediate addr€ss.
Dxamples:
JMP t$6000)
JMP (ABS)
JMP (7430)
JM? (ABS+256-BYJ

Indeied Indtiect oPerands


An indexed indftect instruction us€s register X. The operand is wdtten (-,Xl
Examples:
10 rNc ($99,X)

Indirect Index€d OPerands


An indtect indexed instruction uses register Y. The operand is wdtt€n (-)'Y
Exarnpld:
10 LDA I$28),Y
110 .CMP ($E5),Y
1110 ORA (BY),Y

tndexed Page zero operandg


A zero page indexed operand is wrirlen -.X or -.Y
Eramples:
10 lNc $34,X
110 STX $AB,Y
1110 I-DX BY,Y

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

Now that we havc explanrcd how to gct started writire a proeram. rt is uD ro


you to actually $'ritc the program. This manual coniiins-r eiy liiitc jni;r mdijon
on assem}]y
.laDguage pfogramDring rectrniques. wc assume thar you are
alrcrLly fdmilirr wilh Jssenrbty language. ihe remainder of the section
, i F s . . i L r p s l r nr o
$ r b " r h c A . s c m L r t ^r d
. i r , , r, n , r r i d g r

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.

Drlxx S.qe* deletesstaiement nnmber xx.


DEIxx,n' $itR:* dcleiesstatementnumbers xx trrrcugh yy.

NUM Command
This command assign$staiement numbers auiomatical|y.

NUM liflnir& incremcnts statemeni number by 10


t a{ier cach 4FilH. rhe nerv statement

I
I NUMnn
numbcr, fbllowed by a space,is auto
matically displayed.

has the sameeilact as NUM, but ihe

It
l'i1Xi+l}
ncrement is nn instead of10.

NUMmm,nn llltl:i't forces the next statementnuDber io be

I
mm and the indement to be nn.

i;'r,:SS fiitjtlj cancelsthe NUM command.


number
The eff€ct ofthe NUM commanal stops automatically when a statement
that already €xists is reach€d. For examplel

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'

RXN @ r€numbe$ aI the statements.in


incremenls of 10, stafiing wilh 10'

RENnn @ rcnumbers all the statementsin


increments ofnn, stafiing with 1o

RENmm,nn l@ renuJnbersall lhe stalemenrsrn


incremen{s ot nn, startmg \r'rtD mm'

FIND Conunand
aft
This commanal finds a specified string The ways to wdte th€ command
shown below.

fIND/SOUGIII/ -@ finds the first occurrenceofthe stdng


soucrt,r. the statem€ntthat contains
the string is disPlaYed'

FrND/souGHT/,4 G8!E! fmds all occurences ofth€ string


SOUGHT. All statem€nts containing such
occurences are displayed.

FIND/SOUGHT/XX @ finds the stdng SOUGHT if it occu$ in


stat€ment number xx. Statement xx is
displayed if it contaiff th€ string

FIND/SOUGHT/XX,YY,A finals all occumen€es ofthe string.


SOUGHT b€tween statement number xx
and yv. All the statem€nts that contain
th€ ;t;ng are displayed.
In these examples, the string SoUGHT is delimited (marked ofD by the
character /. Actually, any character except space,tab and @ can be used as
th€ delimiter. For exampl€, the command

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.

The general form ofthe comlr1alrd is

FIND delimiter st ng d€limiter tlineno,linenol t,Al

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

REP/OLD,NEW @ replac$ the fir6t occurrence ofthe string


OLD with the stdng NEw.

REP/OLDArEWxx,yy @ replaces the first occurrence ofthe string


OLD between statements number xx to
},'y with the string NEw.
REP/OLD/NEW/,,A. @@ replaces atl th€ occurenc€s of th€ string
OLD with the st ng NEW.

REP/OLD.NEWXX,]?,A @ replaces all the occurrences ofthe string


OLD between statements xx to }? 1'Jith
the string NXw.

REP/oLDA.lEWxx,]'y,Q @ dfuplays, in turn, each occurrence ofthe


stridg OLD between statemedts xx and
vv. "query." To replace the
Q stands for
displayed OLD with NE\ry, type Y, then
@. To rctain the displayed OI-D,
press@.

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 "+".

The general lorm of rhis command is


I a I
Rtt delimiler OLD delimirer Ntw delimiler tlineno. linenol L.AJ
In th€ general form, symbols within a pair ofbrackets are optional qualifiers of
the command arld the symbols within braces (A and Q) are alternatives.
Sample Prograln
Let us assume you have wdtten a program on an ATARI Programming Form as
shown in Figure 6:

'lu, I

FEure 6. Satnple Prcgrarn a6 you write it on the


ATARI progranming form

Then when you type it in it would appear on the screen as shown in figure 7:

Figure 7. Appearance oJl ptograrn ia [4,


entereil on the keybodrd.
COMMANDS TO The commands to save (or display) and reideve programs are:
sAvE (OR
I-IST savesor displays a source program
DISPLAY) AND PRINT is the sam€as LIST,but omits line numbers
RETRIEVE ENTER retri€v€s a source prcgram
PROGRAMS sA\.E saves an object prcgram
LOAD retriev€s an object Fogram

wirh ea,h ot rhesecommandsrhereis a paramFrerr har sppcifie$ rhedevi.e rhar


rs rhe sour.e or desiinationof rhe program thar is ro be saved.di"ptayedor
r€trievpd. rhe po$ible devicpsdre di{TFrenrtor differenr commanai, ana the
defar i device is also diferent. some ofih€ commands have optionat paramet€rs
that limit the application ofthe command to specifi€dparis'ofthe
irogran.
The parameter that specifiesthe device thai is the sourceor atestinationofihe
prcgram is wdtten as follows:

iEt is the soeen editor


iP: is the pdnter
rC: is the program Recoder
*DIn]:FI]-INAME is a disk drive.
n is 1, 2J 3 or 4. D: is interyret€d as D1:.
A program saved on or ret eved from a diskette must be
named (FILENAMEJ.

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:

I-IST'E: (LIST'E: is th€ same as IIST)


LIST/P:
LIST/C: (Use cassette'handling procedues describ€d in youl pro-
gram RecorderOperator's Manual.)
LIST,{D:lilename where filenam€is an arbitrary name you give to the
program. rilename must siart with a letter and have no
more than eight charactersJconsistingof letters and
numbers only. It may also have an extension of up ro
ihree characters.Ior example,NAME3, ST5,and
JOHN.23are all legal names.
The forms ofthe commands to transfer only particdar lines (lines xx to yy) to a

LISTTE:,xx,yJr (LISTtE:,xx,yy is the sarne as LIST,xx,ry)


LISTTP:,xx,yJr
LISTTC:,xx,J,'y (Us€cascelte-handling procedues described in ihe
Program Recorder operator's Manual.)
LIST*D:NAIm,xrK,yy where "NAME" is an arbitrary name you give to the
program. Seethe description above.

A single line may be display€d or saved with the command:

LlsTlineno wher€ lineno tu the line number.

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.

The LIST command is ilustrated below. No device is specifie4 so the display


device is the screen, by default. The smaU sample program, nritten in the
previous section, is us€d for ilustration.

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 retdewe a souce program from mssetie, the command fu:

ENTER'C: (Follow the cLoAD Procedue given in your 410 Pro-


: Eram RecorderOperator's Manual.) Nole tbal ENTDRzC:
;lears ihe edit re;tbufier before rerfieving the
i sorfce program.

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

Examples: SAVE C:<1235,1736


SAVE#Dz:MYFILE<1235,1736
1i
To save an obj€ct program residing in hex addressl to address2 on cassette
lr or diskette, the commands are:
lli
ll i, SAVE C:< addressl,addr€ss2
CAUTION: Use the CSAYE procedu.e illustraied in your 410 Program
lI L Recorder Operator's Manual.
ll
tI i sAvE#D:FIr-ENAME< addressl,ad&ess2
ti where FILENAME i6 ar arbitrary name you give to the block of
memory ihat you are savirg (where your object program is
lli stored).
I$ t
l,l,
til

lil
itL
I,OAD Cotnmand

I]r Fonnat t OAD,


device:

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.

LOADral (Us€the CLOAD proc€dure descfibed in your 410 pro-


gram Recorder Operator's Manual.)

These commands will reload rhe memory locationsaddresst ro ad&ess2 with


the conlents thar were previously saved.The numbers addressr and addres62
are those rhat were given in the original SAVE command.
NOTES:
USING
THE ASSEMBLER

THE ASM Th€ eeneral form ofth€ ASSEMBLEcommand is


COMMAND
f,t#PN I
AsM*[#Dln]:PROGNAME[.SRCl]
l,EEi I
L,t{Dtnl:LrSTlNGI.LSTlll [,*Dln]:SEIVBLEoI.OBJI]

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@

On receiving rhis commaod. lhe Assemblertrdnslateslhe soulce program in the


edit text buffer into object code and wdtes the object code into the memory loca-
tions specified in the somce program. Wh€n this process is completed, the
a€sembledprogram is displayed on the screen. For an example ofassembly with
default parameter values, we use the srrall sample program that we wrote.
figure 8 shows the appearanceofthe screenafter the ASM command.

Figlrre a. Appearance ofth€ scr€en as your sarxrple progfam i3


a$embled,
""f
:H'f:is""i".?:,Ti,"1"?:tif; :i:19:'f;il"7
ti?::??":T'":1,j1""trffi
TAB directive.

8E4437
D064

Operand
Op CodeMnemonic
Label
StatementNumber
lnstruction
Commentfrom Previous
Iine starts here
Address

Fisiuie e. Normal (de*to"fffr:t-"3.f;:Trnblv listing as it appears

:'l"J*'fi"Hx:
ffiLT:i$?,'#H.:'#T:il*i?Yff"1*:i:##i?1f
overide s€lections are explained below

Location of Sourc€ Prograln

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:

ENTERTC:*i{Eal (Follow the cassette-handling


instruciions in your Prograi-r
RecorderOperator'sManual.)

The ASM command with no default param€ters is illustrated in the example

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.

To make a default selection, enter a comma, as in the following useful

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.

DIRECTIVES Directivesare instructions to the Assembl€r. Dir€ctives do not, in general,pro-


(PSEUDO duce any assembled code, but they affeci the way the Assemble. assembtes
other instructions dllring the assemblyprocess.Directivesare alsocalledpseudo
oPERATIoNS) operationsor pseudo ops.

Dire.live\areidenrifiedby lheAs"emblprbJ rhe'. ar rhebeqinning.


" rhpont!
exceprion!are Ihe LABLi directiveand rhe . direflive.

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

100 . oPT NOXJECTThe effect ofihese directives is to suppr€ss,between


(part of sourc€ lines 100 and 200, the 4line pag€spacingthat is
normally inserted after every 56 lines ofthe listed form
200 . oPT qlxcT of the assembledprcgran.

More than one option may appear on a line. Opiions ar€ ihen separatedby a
comma, as follows:

1000 . oPT NOLISTINOOBJ


w l
fitleand Page Dtuecrives
10 . TITI-E "name"
20 . PAGi "optional message)'

we explain these directives together becausethey are intended to be used


iogether to provide easily read information about ihe assembledprogram.

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

1000 .TITLE ""

The above directive removes titles afier line 1000.

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

Norerhat one space,rarherthan a lab, is usedbelwepneachfield. UsinesDa(e6


rather rhan tabslersyou wrire longerprograms,sin.e rhe edir texr buh-eiwill
nor be f led up wirh the exrra spaies ahairabs woutd require.

Compressingrhe program in this way makes il te6! easity readablerhan we


mrghl wi\h. bul we can use lhe TAB direcrivero give
- us a more readable
a"sembledversion. The form ot rhe direcliv€ is

lineno . TAB 10.15.20


or, more generally,
lineno . TAB nlunberl,number2,number3

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.

In ihe caseofline 40, th€ appearanc€


on the Finter wontd be as shown below:

3005 D064 40 BNE XEQ SAME PAGE


-ror I I
_15J I
-26J
II-rheTAA direcliveis nor used.rhen lhp appearancp
otrhe assemblcrlinc on the
prinrer will be as shown below in rhe deftLrlL
mode:
3005 D064 40 BNX XEQ S
AME PAGE
_ -, , 1 - It Il
_77J
I

That isr the default setting correspondsto . TAB 12,17,27.


I]]]l

Th€ appearance of this line on the screen will be different only because the w4)
screenhas 38 characterspositions,while the printer has ,10.

BYTE, DBYTE and ['ORD Dir€ctives


100 . BYTEa,b,...,n
200 . BYTE*A,B,... N"
300 . DBYTEa,b,...,n
400 .],I/ORDa,b,... ,n

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.....

Here, the Assembler assemblesinto successiv€ locationsthe instruction of line


10, then the decimal nunber 34, then the insiruciion of line 30.
twl
10.....
20 . BYTE 34, 56,78
30.....

Here, the Assembter assemblesinio successiv€ locationsthe instruction of line


10, then the decimal numbers 34, 56 and 78, ihen ihe instruction ofline 30. The
operand may be an expressionmore complex than the numbers used in the
examples. The rules for writing and evaluating an expression are given in
App€ndrx D.
10 .....
20 . BYTE *ATARI"
30.....

Here, the Assembler assemblesinio succ€ssivelocaiions ihe instruction ofline


10, ihen ihe (ATASCII code)hex numbers a1,54,41,52 and49, then thc instruc
tion of line 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

When line 20 i6 assembledand rhe valueofABS+g3000 i! derermined.as b€fore-


to be $5123.923 is pur in locarion s'4000and $5r is pur in location ga00r.

The wORD dfective sjmplifies someprogramming sinceaddesses in machine


mde are always given in rhe order low byre fotlowed by high byre. Therefore,
the woRD directive is u.6eful.for example.in consl'-uc(inga rabteofaddresses.

LABEL= 100LABEL erpression


DIRECTIVE
The LABEI - directive iB u.sedto give a value to a label. Two examples app€ar in
the- sample program we used before. Stat€ments 60 and 70 give values io ABSX
and XXQ as folows:

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

wh€n the program is assembled, TAB2.will be giwen the vatue $3020.

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

we encounreredthe ' = direfiive in rhe ..gening sraned comrnands.where ir


is used.Lo set rhe srafiing location of fue asiembled program. When the
Assemr,ferencountefs the ' expre$io4. ir sets lhe program counter io the
varue or rne €xpr€ssron.
You write *= without the initial "." that the other directives have (exc€pi t{!
LABEL= ). Also, note that you write * = wiihout any spacesbetween * and = .

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

The Assemblerwill assemblestatement500 as ajump to the value the program


counter had BEFOREit was changedby line 200.

The - = directive is useful for setting asidespaceneededby your program. For


example,you will frequcntly want spacercserved siarting at a particular loca-
tion. Use the following form:

720 TABLE35 r=*+$24


740 ...

The efect ofthe directive is to reserve24locaiions immediately after TABLE3s.


Other parts ofyour code will not b€ assembledinio these locations(unlessyou
take pains to do so). Your program can use TABLE35 as an operand and
TABLX,3scan be uscd as an element in an expressionthat you. instructions
ewaluatein accessingthe table.

IF Directive
900. IF expression@LABEL
wl
990 LABEL End of conditional assembly

The IF directive permiis conditional assemblyofblocks ofcode. In the illustra-


tion above,all the cod€between lines e00 and 990 willbe assembledifand only
ifthe expressionis equal to zerc. Ifth€ expressionis not equal to zero, the IF
directive has no effect on assembly.
The €xample given below shows how different parts of a sourceprogram may
b€omitted from assemblyaccordingto the value assignedtothe LABEL in the IF
directive. Th€ souce program is assembledwith Z=o in one caseand Z=1 in
another. wiih Z=0, the insiruction TAx is assembl€d,and with z=7 t]]e ii
struction ASI- A is assembled.Obviously, this kind olselective assemblycan be

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

PURPOSEOF The Debuggerallow6.youto follow rhe operarionofan objeci program in derail


DEBUGGER ano ro maKe mtnor chandesin it.

A knowledge ofmachin€ langxageis helpfr when you usethe debugger.buLir


is not essential.The Debugger is able to convefi machine mde intoissembtv
language(disassemble). so you can make code allerarionsat parricl ar memorv
locarions.All numbers usedby rhe Debugger.borh in inpur andouipur. are he;-

CALLING THE The Debugg€r is caled from the Editor by typing:


DEBUGGER
BUG @

ThiB produceson the screen:

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 @

Sets the X R€gister to 34 and leaves the other regtui€rs unchanged.


D or Dmrn't|'r Dtuplay Memory
Dmmmm, yJ,TT rnihere 'Tyy is less than or equal to rrmmm shows the contents
of address mmmm.
Examplel
DIEUG
D5000,0 @

5000 A9
DEBUG
tl
This shows that address5000containsthe nwnber A9.

Ifthe secondad&ess(yt?T) is omitted, the contedtsofeight successivelocatio4s


are Bhorrn. The processcan be continuedby typrng D @EO.
Example:
DEBUG
D5000 @

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.

C or C[rmInIn Change M€mory


Cmmrnm < yy changes the contents of address mmmn to J,y.

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.

Vmrnrntxr vertt, Memory


y mmmm< Wyy.zzz comparesm emory y)7y Lozzzz w i rh memory sta-rri ng at
mmmm, and shows mismatches.

F-ralnple!
DEBUG
v7000<7100,7123 @

DEBUG
I]
The command compared the contents of 7100'7123 with the contents of

Mismatches would be shown as follows:

7701 00 7001 22
7105 7a 7005 70

L or Lmnnln List M€lnory with Dtgassembly


This command allolvs you ro look ar aJr|yblock of memory in disassembled
form.
F.ramplea:
I-7000 @ Ltut a screen page (20 lines of code) starting at
memory location 7000. Pressing the @ key
during lisLing halrs rhe lisiing.

L @ This form ofthe command lists a soeen page start-


ing at the instruction last shown, plus 1.

L7OOO,O @ Theseforms list the instructiom at address


L7OOO,70OOl@ 7000oriy.
L7000,6000 @

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

To illustrate this fuiher, the number 03 corresponds to no inachine code


instruction, so the Debugg€r wor d interyret 03 as an illegal instructio& and
alert you to a possible error, as shown below.
Example!
DEBUG
L5001,0 @
5001,03 ???

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 Assemble One Instruction Into Memory


The DEBUGGERhas a mini-dssembler, that can ass€mble one ass€mbly language
i. ifftruction at a time. To enter th€ Assemble mode. tvDe:

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.

You can use the directives BYTE, DBYTE, and WORD.

Gmmmm Go (Ex€cule ProgFan,


This cominand €x€cutes instructions starting at mmmm. For exampte;

GTBOO @ Executes instructions starting at location 7800.


Execution continues indefnitely. Execution is
stopped by pfessing the @ key (unless the pre
gran at 7800 tricks or crashe8 the operating system).

Tmmmn Tlace Operatlon


This command has th€ same e{Ieci as cirunmm. exceDt that aft€r execution of
each insrru(Iion the sffeen shows the instrucrion adidress,rhe inslrucrion in
machine code, the irNtruction in assembly language (disassembled by the
debugg€r-not necessarily the sane as you rffote it in ass€mbly language) and
the valuesofRegisrers A, X. Y. P and S.

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

S or Smmrnm Step Op€ratlon


This comnand has the s€me e{fect as T or Trnlnmm, except that only one
inslruction is executed.To step through a program. rwe S @!tr repe;redly
aner rhe first command ofSmmrnm @

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.

128 m key pressedduring an I/o operation.


130 A nonexistent device specified for I/O.
132 The command i$ invalid for the device.
EOF.End of file read has been reached.This €rror may occur when
r€ading jiom cassette.
737 A record was longer than 256 characters.
138 The device specified in the command does not respond. Make surc
ihe device is conneci€dto the consoleand powered.
139 The defice specified in the command does not return an Acknowl-
edge signal.
140 Serial bus input framirg error.
142 Serial bu6 data fiame ov€rrun.
143 Serial data checksum error.
Devic€ done effor.
145 Dfukette erlor: Read-after-write comparison fail€d.
146 Function not implem€nted.
162 Disk flrll.
165 File Darne elror:

I
t

I
!
l

d
1
APPENDIX 2
| \ul
ASSEMBLERMNEMONICS
(Alphabetic List)

ADC Add Memory to Accumulator with Carry


AND AND Accumulato. with Memory
ASL Shifi Le{i (Accumutator or Memoryl
BCC Branch if Calry Clear
BCS Branch ifCarry Sei
BEQ Branch ifResult=Zero
BIT Test Memory Against Accumulator
BMI Branch if Minus Result
BNX Branch if Result+ Zero
BPL Branch on Plus Result
BRK Break
BVC Branch if V llag Clear
BVS Branch ifv llag Set
cLc Clear carry Flag
CLD Clear Decimal Mode Flag
CLI Clear Interrupt Disable Flag (Enable Interupt)
CLV Cl€ar V FIag
CMP Comp3r€ Accumulator and Memory
cPx Comp:re RegisterX and Memory
CPY ComFre RegisterY and Memory
DEC DecrementMemory
DEX DecrementRegisterX
DEY Decrcmeni RegisterY
EOR Erclusive-OR Accumulator with Memory
INC Increment Memory
INX Increment RegisierX
INY Increment Regist€rY
JMP Jump to New Location
JSR Jump to Subroutine
LDA Load Accumulator
LDX Load RegisterX
LDY Load RegisterY
LSR Shift Right lAccumulaior or Memory)
NOP No Operation
ORA OR Accumulaior with Memory
PIIA Push Accumdlaior on Stack
PHP Push ProcessorStatusRegister(P) orio stack
PLA PUUAccumulator from Stack
PLP Pull PrccessorStatusRegister(P) ftom Stack
ROr, Rotate Left (Accumulator or Memory)
ROR Rotate Right (Accumulator or Memory)
RTI Return from Intenupt
RTS Return tiom Subroutine
sBc Subtraci Memory from Accumulato. with Bonow
sEc Set Carry Flag
SED Set Decimal Mode Flag
SEI Set Interrupi Disable Flag (Disable hterrupt)
STA Stor€Accumul.ator
sTx Stor€R€gistex x
STY Stor€R€gister Y
Transfer Accumulator to R€gister X
TAY tansfer Accumulator to Register Y
TSX Tra[6fer Register SPto Register X
TXA Transfe. Register X to Accumulator
TXS Transfer Register X to Register SP
TYA Transfer Register Y to Accumulator
APPENDIX 3
)
SPECIAL SYMBOLS

Below we give a lisi of specialsymbols that have a restricted meaninE io the


Assembler.You shouldavoid using rhesesymbol! as a marrerofcourie. lrosr
atremprslo u\e rhescsymbolsin dnv bur rheir specidlsensewill resujrin Frror".
They mry be u.ed. wirhour rhFir .pecjatmeining. in commenrFand in rhe
operands01 memory r€senation directiwes.

The semicolon is used to indicate the start of a comment. Eventhins


between the semicolon and RETURN appears in the listed {brm'of th!
program and is ignored bv the Assemb'lir. When comments iake more
than one lineJ staft each n€w line {,ith a semicolon.

The / sign is used as th€ lirst symbol of an immediate operand, as in


LDX *24.

The $ sign is usedbefbrenumbem to signi{y that they are io be interpr€ted


as hex numbers. For example,LDX 1934.
) The aste sk is used to signify the vatue ofthe current location counter. For
example,the instruction in line 50 give6the symbol HEREa value equatto
5 or more than the number in theiurrent location counier:

50 HERE= * +5

Example:

1A
1 9 RTS
20
2 1 TAX

when this exampleis assembled,line18 causesthe location courier to be 90911,


RTS is placed in location 90911, line z0 causesthe tocation counrer to be
increased ftom $0912 to 90921, and TAX is placed in $0921. This leaves 15
empiy bytes between the RTSand the TAx.

lhe a"rerisk alsorignifiesmulupli.arion,"ee Apppndix6r. ThF A.semblpruseq


lhe !ynlax ol the riarpmenrro dr"ringui"hrhp rwo meaningsofrhe asterisk.

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

Frl a; lfr: F !: EIF


z EigE4+
gF+e
;
! -. .i
"Fi.Fi3:.sFF.' i t r ,
X
rr''l
g::lHEt!; *:!! c o ooq iii 7 T!)s

*
.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

WheD an insrrucrion or djrefljve callsfora number


in the op€rand,lhe number
may be given as an ,,expafession.', the n
*1i**r.'.. a' "*i,"".;;; i:"ffii; i[T "' ffieraused being the varueor the

Exprcssionsare rnade up ofoperators and Lerms.Terms


are either numbers or
laDelswhich sfand for numbers. An expressionconLaining
a f"Ua ,.rrn_,f,ri
cloe8not have a nlrmeric value will be nagged as an
error.
There are five operatorsj four are arithmetiq and one
is logicat.
Addirion is signified by rhe 6ign
subtraction i6 signified by the sjdn
Mrdriplicarion is sjqnified bv
"
Division is signifiea by ,
Logicai AND i6 signified by ajr
Expre$ions must not contain parentheses.

Expressionsare evaluaredfrom tefi to fighr.

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

. OPT Operand specifies an option. Operand can be LIST or NOLTST,


OBJ or NOOBJ, ERRORS or NOERRORS, EJXCT or
NOUECT. (Default options are LIST, OBJECT,ERRORS,
and lEcT.)

, TITLE "NAME" causesNAME to be printed at the top ofeach page.

. PAGE (MESSAGE' produces a blank space in th€ listing, then caus€s


MESSAGEto be pdnted alier NAME.

. TAB n1,n2,n3 contrcls the spacing of the {ields of Op Code


Mnemonic. Op€rand. and Commenl as lhey appear in
the listing.

. BYTE a,b...n places in successivememory locations the values ofthe


expressionsa, b, ..., n [one byte for each value).

. BYTE *AB...N' places in successive m€mory locations the ATASCII


values ofA, B, ..., N.
)
. DBYTEa, b,...n places in successive pairs of memory locations the
valuesof rhe expressionsa. b. ..., n rrwo byle6 for each
value. high byte firstl.

. WORD ar br...,n places in succ€ssive pairs of memory locations the


valuesofthe €xpressionsa, b, ..., n (two bytes for each
value, low b].te firsi).

AB=nxpre$ion makes ih€ Label AB equat to the value of the expres-


sion (up to FFFF hex).
* = Expre$ion mak€s the Program Counter equal io the value ofthe
expression (up to FFFI hex).

. IF Expression
. ]-ABEL assemblesfolowing code, up io . LABXL, ifand only if
expre$ion evaluates to zerc.

, END indicates th€ €nd of the prcgram to be assembled.

)
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

98 62 b 174 '72 r 130 B2

99 63 c 115 / J S 131 B3

100 64 d 116 1.32 B4

101 e 1.1.7 133

102 66 f 118 734 86


srv r't
.+ ..I} -e
.c! ^w ,o\'- ,{"'
^v^t 1n) ,/n,

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

140 BC 156 9C tr 772

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

184 BB 200 C8 216 DB

185 B9 207 C9 D9

186 BA 202 21.8 DA

1.87 BB 203 CB 279 DB

1BB BC 204 CC 220 DC

189 BD 205 CD 221 DD

190 BE 206 CE 222 DE

191 BF 207 CF 223 DF

792 CO 208 DO 224 EO

193 C1 209 D1

794 C2 21.O D2 226

195 C3 21.7 D3 227 E3

196 c4 21.2 D4 228 EA

L97 C5 213 D5 229

198 C6 274 D6 230 E6


.$t .+

"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.

2. Except as shown, characiers Ilom 128255 arc reverse colors of 1 to 127.

3. Add 32 to upper casecode io get lower casccode lbr same ]erte..

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

6502 Assembly Language Prcgrammingby Larrce Leventhal


Osbome^4ccraw-Hill, 630 Bancro{t Way, Berkeley, CA 94770

Ptwrumming the 65A by Rodn€y zaks


Sybex, 2020 Milvia Street, Berkel€y, CA 94704
NOTES:
)
APPENDIX 9
USING THE ASSEMBLERCARTRIDGE
TO BEST ADVANTAGE

#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

. To gencfaie speciatsound effectsthat BASTCi$


too slow to generare
. To gercfate high-spcedgraphics and animation
. To utilize the inicrrupi capabilitiesofrhe machine
. To accomplishhigh-speedcomptex togical
calcutationsand manipulations

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

Ifyou have a Program Recorder,type in:

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

we begin by writing an assembly language progran with the Assembler Editor


cartridge. Originate the program near the top ofyour available memory. For ex-
ample. ifyou have 2K ofobject codeand a t6K machine, o.iginare rhe program
ai the l2K boLmd€rywirh the direclive =$3000'.This leaves4K ofspaci-zr
for your program, I K for a CRAPHICSmode 0 djsplay. dnd 1K or extra;pace for
good measure.Now go through ihe procedure ofasspmbling rhe objecfcode ro
ctjskelle or casserre.ch€nging rhe canridges. and loading The objefl code into
memory. Calculatethe decimal ad&essesofihe beginniDg and end ofyour ob-
ject code. Let u3 say that your program is 2179 bytes long. It begins at g3000 or
p2a8 decimal, so the last byte is at 14466.Pdnt PEEK(12288)and PEEK(14466)to
verify that these addressesreally do contain the flrst and last bytes ofyou. pro-
gram. Remember.the computer will print rhe resul" in decimat,nor tex-
adecimal.so you will havFro ( onven in your heador wirh rhe compurer.
Now start writing a BASIC program, begin with:

2 DIM ES(2179i

Ther add this subroutine (which you can delete later):

25OOOA =90*J+ 1:B=A+89: II B > LIMIT THEN B =LIMIT:?"LAST LINE"


250101+ 5;"E$(";A;",",B,") - ";CHR$(3a);
25020FORI-A TO B:?..8M @,,;CHR$(PEEK)I+C));:NEXTI
25030?CHR$(34)J -l +1:RETURN

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:

30 E$(292, 292)= CHR$(34)

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

DELxx, yy deletes statemeni numbers xx through yy


NEW wipe8 out source program
75
FIND/SOUGHT/XX,yy, A finds and disptays all occurences of the
srnng soUGHT
Detween xx and yy
RiP/OLD,NEWXX, yy, A
ween rines x.\ and yy orrhe srrins
::ol":.::iil,"*"'1"*:s.bei
ULIJ wrrh the strjng NEW 77

LIST rP: lists souce program to p nter


19
PRINT 'P: p nts souce program on pdnter
27
ENTER 'D: NAME r€tneves source program from diskette
21
SAVI /C: xxxx, yyyy saves data in addresses xxxx through
yyyy to cassett€ 22
LOAD 4C: r€trieves data from cassette
22
ASSEMBLER

ASM'D: NAME. SRC,/P:, /D: NAME. OBJ


retrieves source file caled NAME. sRc 2s
on diskette. lists
a.ssembry risrjnsio pri.,*. ""0 *;;ri*i.iii.i,"i"i,ii.
diskerreunder trtenameNAMr. OBI

DEBUGGER

DR displays 6502 registers A, X, y, p, alld


S.
cR<,,x purs an x into the y_rcgister.
36
Dxxxx, ylyy displays cont€nts ofaddresses xxxx through
yyn, 36
Cxxxx < yy puts yy into address xxxx. 37

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.

disassembles memory starting at addrese xxxx. 3a

activates mini-assembler [no labels, one line at a time). 40

Gxxxx runs object program at xxxx. 40

trace; displays 6502 registerE while running object program 40


ai addre$ xxxx at readable speed.

single-steps object program at xxxx, displaying r€giste$.

x 41,
APPENDIX 11
MODIFYING DOS I TO MAKE
BINARY HEADERS COMPATIBLE WITH
ASSEMBLER EDITOR CARTRIDGE

The following assemblylanguageproqrar

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

To assemble the modification program, rype ASM and press


G@.
To mn this prograrn, you must be in DEBUG mode so, t}T'e the following.
. Type BUG and prcss @.
. Type c600 and press @.

The screen will display:

DoS I will now have header bles that are fully compatible with the Assembler
Editor cart dge.

To chang€ DOS I permanently on your diskette:

1. Run the Modilication Program.


2. T}?e x G@ to g€t out ofBUG.
3. Typ€ DOSEn@ to enter DOS.
a. Type H l@ to $ryite a fully compatible Dos on diskette.

CIIANGES AND LOCATIONS

LOCATION PR.ESENT CONTENTS CIIANGE TO


DECIMAL HEX DECIMAL HEX DECIMA]- HEX
9281 2441 132 84 255 FF
9288 2444 9 0 9 FF 'LOAD

5311 14BF 732 84 FF


5312 14CO 9 0 9 FF .SAVE

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)

A""' s.r l. I"i,,"d-


' l ! " Il' [ r ] 1l1l Lr!r!
'j'
il

!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

You might also like