# Assembly Cookbook for the Apple II/IIe — source transcripts, page 1

[Canonical transcript page](https://www.vintageapple.net/transcripts/media/va-assembly-cookbook-foor-the-apple-ii-iie-1984-986489/1)

## Transcribed source material

Machine transcriptions and image descriptions; uncertain copy may be marked [illegible]. Verify against the linked originals. Historical rights remain with the original owners.

These are transcribed excerpts, not the full publications. Open the originals for remaining pages.

### Image 1

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-assembly-cookbook-foor-the-apple-ii-iie-1984-986489/1#scan-68fac79966bf2bb1803014ed7a1e1ab51688739792120db8fb8a73fb796a5ed2)

Transcribed text:

SAMS
22331
Assembly Cookbook for the Apple II/IIe
Don Lancaster
Assembly
SAFF:
SAFF:00
S800:00
S801:4C 04 8B
804:18
:AD 00 8B
71 ;
73
74 COLOR DFB $00
75 PICK DFB $00
76 ERASE JMP BRASE
77 CLC
78 LDA
79 ASLA COLOR
80 ASLA
81 ASLA
82 TAY
83 NXTBYT LDX
84 TYA #$00
******MAIN PROGRAM******
; ADJUST HRCG SET START
; COLOR POKES HERE
; OPTIONAL INVISIBLE LOCK
; FILE POINTER * 8
; GET COLOR

Image description: A green-bordered cover photo shows several glossy dark red apples with green leaves in a white ribbed baking dish, with an index card showing handwritten 'Assembly' and assembly code listing in the foreground.

Reading notes: Assembly code listing on the index card is skewed and partially cut off at the bottom edge, so some line-level alignment and the final lines are uncertain. Handwritten 'Assembly' label on the card is stylized and read from the image. Small figures such as '804:18' and ':AD 00 8B' are partially obscured and may be incomplete. Reading order of the code listing columns is approximate.

Printed product names: Apple II/IIe

Languages: English

[Original Image 1](https://www.vintageapple.net/files/4fb1e3f86498103e06b8fc0f151386a36b966e34846935da758244f5337d7b55/29359782f34d7e06de61ce80.webp)

### PDF page 1

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-assembly-cookbook-foor-the-apple-ii-iie-1984-986489/1#scan-08bb88afcbedcdb0b6333da230b0db2db1261b140b9b9ccbf132ba1ef992d26e)

Assembly Cookbook for the Apple II/IIe

Transcribed text:

SAMS
22331
Assembly Cookbook
for the
Apple® II/IIe
Don Lancaster
Assembly
SAFF:
SAFF:00
SB00:00
SB01:4C 04 8B
04:18
AD 00 8B
71 ;
73 ;****MAIN PROGRAM******
74 COLOR DFB $00
75 PICK DFB $00
76 ERASE JMP ERASE ; ADJUST HRCG SET START
77 CLC ; COLOR POKES HERE
78 LDA COLOR ; OPTIONAL INVISIBLE LOCK
79 ASLA ; FILE POINTER * 8
80 ASLA ; GET COLOR
81 ASLA
82 TAY
83 NXTBYT LDX
84 #$00

Image description: A cover photo shows several dark red apples with green leaves in a white ribbed dish, with a ruled listing sheet of assembly code overlapping the lower left, all set on a green background with the title in cream lettering.

Reading notes: Code listing on the lower-left paper is partially cut off and angled, so line numbers and some operands at the edges are uncertain. The handwritten word 'Assembly' at the top of the listing is script and read as approximate. The number 22331 is a catalog or product number rather than a date and is listed under printedDates only as printed. Reading order of the code listing lines and side comments is inferred from layout.

Printed product names: Apple II/IIe · SAMS

Printed dates: 22331

Languages: English

[Original PDF page 1](https://www.vintageapple.net/files/9d01a190feef4de8f3155bb19972d041cefd95336506c2b403245097a1aad46d/Assembly_Cookbook_foor_the_Apple_II_IIE_1984.pdf#page=1)

### PDF page 2

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-assembly-cookbook-foor-the-apple-ii-iie-1984-986489/1#scan-fe42a21ad0210ba3664d5e96c40bf2ec35c0915f414d5790cd0f224bf9490262)

Transcribed text:

Assembly Cookbook for the Apple II/IIe

Image description: A mostly blank off-white page with a single centered red bold title line, and very faint ghosted text blocks near the top and middle that are too washed out to read.

Reading notes: Faint ghosted text near the top of the page and in the middle area is too washed out to transcribe and was omitted. Title appears in red and is clearly legible.

Printed product names: Apple II/IIe

Languages: English

[Original PDF page 2](https://www.vintageapple.net/files/9d01a190feef4de8f3155bb19972d041cefd95336506c2b403245097a1aad46d/Assembly_Cookbook_foor_the_Apple_II_IIE_1984.pdf#page=2)

### PDF page 3

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-assembly-cookbook-foor-the-apple-ii-iie-1984-986489/1#scan-35a19b3c9c451d454230f6f46e5a887f89cfa9f3143fd022db50e5e15fbaafc2)

Transcribed text:

Don   Lancaster   heads   Synergetics,   a new-age   prototyping   and   consulting   firm
involved   in micro   applications   and   electronic   design. He is the   well-known   author of
the   classic   CMOS   and   TTL Cookbooks.
He is one of the microcomputer pioneers,   having introduced the first hobbyist
integrated-circuit projects, the first   sanely   priced   digital   electronics   modules,   the first
low-cost TVT-1 video display   terminal,   the first   personal   computing keyboards, and
lots   more. Don's numerous books and   articles   on   personal   computing and   electronic
applications   have set new standards as understandable,   useful,   and exciting   technical
writing.
Don's other interests   include   ecological   studies, firefighting, cave   exploration,   bicy-
cling,   and tinaja questing.
The Don Lancaster Library
Active   Filter   Cookbook   ............................................. No. 21168
Assembly   Cookbook for the   Apple   II/lie   .............................. No. 22331
CMOS   Cookbook ................................................. No. 21398
Don Lancaster's Micro Cookbook,   Vol.   I.   ............................. No. 21828
Don Lancaster's Micro Cookbook,   Vol.   II   ............................. No. 21829
Enhancing Your   Apple   II,   Vol.   I, 2nd Edition   ........................... No. 21822
The Cheap Video Cookbook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . No. 21524
Son   of Cheap Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . No. 21723
The   Hexadecimal   Chronicles ....................................... No.   21802
TTL Cookbook. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . No.   21035
TV Typewriter Cookbook   ........................................... No. 21313
The   Incredible   Secret Money Machine   (Available   only   from Synergetics)

Reading notes: OCR text shows 'lie' in 'Apple II/lie' which is likely 'IIe' Catalog numbers are listed as 'No.' followed by digits but no prices are printed

Printed product names: Active Filter Cookbook · CMOS Cookbook · Don Lancaster's Micro Cookbook, Vol. I · Don Lancaster's Micro Cookbook, Vol. II · Enhancing Your Apple II, Vol. I, 2nd Edition · The Cheap Video Cookbook · Son of Cheap Video · The Hexadecimal Chronicles · TTL Cookbook · TV Typewriter Cookbook · The Incredible Secret Money Machine

Languages: English

[Original PDF page 3](https://www.vintageapple.net/files/9d01a190feef4de8f3155bb19972d041cefd95336506c2b403245097a1aad46d/Assembly_Cookbook_foor_the_Apple_II_IIE_1984.pdf#page=3)

### PDF page 4

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-assembly-cookbook-foor-the-apple-ii-iie-1984-986489/1#scan-193bba669902b8dcaf52ef4ec0467978ef18135c80b5bb8f88902517fdaf81a8)

Transcribed text:

Assembly Cookbook
for the Apple   I   I/I   le
by
Don Lancaster
Howard W. Sams & Co.,   Inc.
4300   WEST 62ND   ST .   INDIANAPOLIS.   IN   DIANA   46268   USA

Reading notes: Apple model designation 'I   I/I   le' is garbled; likely 'Apple I / Apple II' or similar

Printed product names: Apple I

Languages: English

[Original PDF page 4](https://www.vintageapple.net/files/9d01a190feef4de8f3155bb19972d041cefd95336506c2b403245097a1aad46d/Assembly_Cookbook_foor_the_Apple_II_IIE_1984.pdf#page=4)

### PDF page 5

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-assembly-cookbook-foor-the-apple-ii-iie-1984-986489/1#scan-c802c3447a0fc203cd3110948c4ef4a9c51fc826750e0dd4d7de9dc2d08bb70a)

Transcribed text:

Copyright   01984   by Don Lancaster
Fl   RST   EDITION
FIRST   PRINTING-1984
All   rights reserved. No part of this book   shall   be
reproduced, stored in a   retrieval   system, or transmitted by
any means,   electronic,   mechanical,   photocopying,
recording, or otherwise, without written permission from
the   publisher.   No patent   liability   is assumed with respect
to the use of the information contained herein.   While
every precaution has been taken in the preparation of this
book, neither   publisher   nor author assumes any
responsibility for errors or omissions. Neither is any
liability   assumed for damages resulting from the use of the
information contained herein.
International Standard Book Number:   0-672-22331-7
Library of Congress Catalog Card Number:   84-50247
Edited by:   Pryor Associates
Illustrated   by:   Wm. D. Basham   and T.   R.   Emrick
Printed in the United States of America.

Reading notes: Copyright year printed as 01984 with a leading zero; the 'Fl RST EDITION' heading has irregular character spacing

Printed dates: 01984 · 1984 · 84-50247

Languages: English

[Original PDF page 5](https://www.vintageapple.net/files/9d01a190feef4de8f3155bb19972d041cefd95336506c2b403245097a1aad46d/Assembly_Cookbook_foor_the_Apple_II_IIE_1984.pdf#page=5)

### PDF page 6

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-assembly-cookbook-foor-the-apple-ii-iie-1984-986489/1#scan-70207900f0078137e6d0315c4e9114865e47352282d07b069e323203d5e04aee)

Transcribed text:

Contents
zero
WHY   You   GonA L EARN AssEMBLY LANGUAGE........ . . .. ............   9
part   I
Some Theory
one
WHAT   Is   AN AssEMBLER?   . ...••..•.....•... . .. • .. .. .. • . •.. . ... ...   25
Types of   Assemblers-How   Assemblers   Work-Which   Assembler?-   Tools
and Resources-Disassemblers-What an   Assembler   Won't Do
two
SOURCE   CODE   D ETAILS   ...... .. . . .. . .. .. .. . .....•.. ••....• • ......   57
Sou rce   Code   File   Formats-More on Operands- More on   Pseudo-Ops-
Your   Own   Assembler
three
SOURCE   CODE   STRUCTURE   • .. .•.••.•.•.•••.. . . . •. . ..••.........•.   93

Reading notes: Source appears to be a table of contents with OCR noise such as 'Sou rce' and 'D ETAILS'; some page numbers and dots may be misread.

Languages: English

[Original PDF page 6](https://www.vintageapple.net/files/9d01a190feef4de8f3155bb19972d041cefd95336506c2b403245097a1aad46d/Assembly_Cookbook_foor_the_Apple_II_IIE_1984.pdf#page=6)

### PDF page 7

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-assembly-cookbook-foor-the-apple-ii-iie-1984-986489/1#scan-8438400de7e65b5c40c16c05784f79f07ba264e84525ca85f7fc7759a8298290)

Transcribed text:

four
WRITING   AND   EDITING   SOURCE   CODE   (THE   OLD   WAY)   . . ..•.•...••...•.   123
Program   Style-U nstyle-Writing   "Old   Way"   Source   Code-An   Editing
Hint- A Label List
five
WRITING   AND   EDITING   SOURCE   CODE   (THE NEW WAY)   ••..• ... . . .••. . .•   163
Source   Code   File Structure-Line Numbers-To Tab or Not to Tab?-
Trying   It
six
ASSEMBLING   SOURCE   CODE   INTO   OBJECT   CODE   • .. .•.•...••. .. .•......   177
Assembler Commands-Assembly Listings-Error Messages-Debuggi ng-
Something   Old,   Something New
part   II
The Ripoff   Modules
How   TO   U SE   THE   RI POFF   MODULES   ..••.....•.••. . .. . .••..•......••   205
0
THE EMPTY SHELL   • • ..••.•..••.•• . ..•.•..•. . . . .•. ... •••. .. ••• •   211
A framework you can use to create most any machine language program
of your choosing.
1
FILE   BASED   PRINTER   ....................•......•. . ••.• . . . .••. . .   229
The standard way to output short and fixed text messages using a
common message   file.
2
IMBEDDED   STRING   PRI NTER   ..• •• •. ...••.. • ... ...•...• •. ...••....•   251
A much better way to   " mix   and   match"   fixed test messages that are
imbedded directly into your source code.
3
M ON ITOR   TIME   DELAY   • .• ... . ••.... . ••......... . .••. . ....• •. .•.   267
How to use the Apple's   WAIT   subroutine for animation and other system
timing needs.

Reading notes: Table of contents format; page numbers and chapter titles may be partially garbled by line breaks. Heading for chapter three is ambiguous because the title line is split across lines.

Languages: English

[Original PDF page 7](https://www.vintageapple.net/files/9d01a190feef4de8f3155bb19972d041cefd95336506c2b403245097a1aad46d/Assembly_Cookbook_foor_the_Apple_II_IIE_1984.pdf#page=7)

### PDF page 8

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-assembly-cookbook-foor-the-apple-ii-iie-1984-986489/1#scan-b084348081f82014c372fe674ab085b9016d803dae8451f8879b552442de90ff)

OBNOXIOUS SOUNDS

Transcribed text:

4
OBNOXIOUS   SOUNDS   ..••.•.•...•. . ......... . •.. .. .. . . . ........   287
A multiple sound-effects generator that   " calculates"   lots of different
sounds with minimum code.
5
MUSICAL   SONGS   .. . ..••......... ... . .••.. . . ..•.•..•..........   301
The standard   " red   book   tones"   method of making music, along with a
few improvements and upgrades.
6
OPTION   PICKER   ••...•... . •••... ..•.••....•.•.•..•..... . ......   321
How to do menu options or pick modules using the forced subroutine
return method.
7
RANDOM   NUMBER   . . .•. ... •. .. . .••••.....••..... . .•...........   345
A fast and usable way to generate   " random"   numbers, without the fatal
flaws of the Applesloth   "RND"   code.
8
SHUFFLE   •...• . •. .. •.••••.......••.... . ••••..••.••...•• . .•..   363
An extremely fast   " random   exchange"   method of rearranging an array of
numbers or fi le values.
Appendixes
A
DIFFERENCES BETWEEN   "OLD"   AND   " NEW"   EDASM   • . . ... •.. . •..•••..   381
B
SOME   NAMES AND   N UMBERS   •.•.•••.....••••...• • •••••.•.. . .••.•   387
c
LABEL   LISTS   TO   (OPY   .......• . ......... . .••....•..... • ••• ....•.   393
INDEX   •• ....... ...••. ...• •..•.....•••.•..•.• ..• •.•••. . .••. .   399
COMPANION   DISKITTE AND   VOICE   H OTLINE   . ••••...••...• •.• .••.•••.•   407

Reading notes: Table of contents layout may affect reading order of entries

Languages: English

[Original PDF page 8](https://www.vintageapple.net/files/9d01a190feef4de8f3155bb19972d041cefd95336506c2b403245097a1aad46d/Assembly_Cookbook_foor_the_Apple_II_IIE_1984.pdf#page=8)

### PDF page 9

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-assembly-cookbook-foor-the-apple-ii-iie-1984-986489/1#scan-0cabd2760fedf42ab64056aa9afb344971cbf12a7cf374815eef64789a19afb7)

WHY YOU GOTT A LEARN ASSEMBLY LANGUAGE

Transcribed text:

@
WHY   YOU   GOTT A LEARN
ASSEMBLY   LANGUAGE
Check into   Softalk   magazine's listing of the   " top   thirty" programs for
your Apple.   II   or   lie,   and you' ll find that thirty out of thirty of thi s
month's winners usually invo lve machine language programs or sup-
port modules, written by authors who use assemblers and w ho make
use of assembly language programming   ski ll?.
And, last month' s top thirty were also swept by machine language,
thirty to zip . And   next month's listings probably wi ll be the same.
Somehow, thirty to zero seems statistically significant. There's got to
be a message there.
Yep.
So,   on the basis of w hat is now happening in the real w orld , you
can easily concl ude that ...
The only little thing wro ng with   BASIC   or
Pascal   is that it is categorically impossible
to write a decent Apple   II   or   lie   program
with eithe r of them!
Naturally, things get even worse if you try to work in some specialty
language,   such as FORTH,   PILOT,   LOGO,   or w hatever, since you
now have an even smaller user and interest base and thus an eve n
more miniscule market.
What would happen if, through fa ncy packaging, heavy promotion,
9

Reading notes: Headline spacing and hyphenation may be irregular due to extraction Some names such as 'lie' and 'Apple II or lie' may be OCR artifacts for 'IIe' Page number '9' and line breaks may affect reading order

Printed product names: Apple II · BASIC · Pascal · FORTH · PILOT · LOGO

Languages: English

[Original PDF page 9](https://www.vintageapple.net/files/9d01a190feef4de8f3155bb19972d041cefd95336506c2b403245097a1aad46d/Assembly_Cookbook_foor_the_Apple_II_IIE_1984.pdf#page=9)

### PDF page 10

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-assembly-cookbook-foor-the-apple-ii-iie-1984-986489/1#scan-858fdeb2c12fd3f6116fb3adc6b9128ec0690f5ad3ce05c02fa3bdf5435e4c9b)

Transcribed text:

70   Why   You   Cotta Learn Assembly   Language
or outright   lies,   a   BASIC   or a Pascal program somehow happened to
blunder into the top thirty some month?
One   of three things . .   .
-maybe-
1.   Word   will   quickly   get out over the   bulletin   board systems and
club   grapevines over how gross a ripoff the program is, and the
program   wi ll   ignominiously bomb out of sight.
-or-
2.   A competitor   will   recognize   a germ or two of an undeveloped
idea in t he program and come up with a win ning machine   lan-
guage   replacement   that does much more muc h faster and much
better, th us runn ing away w ith   all   the   marbles.
-or,   hopefu lly-
3.   The program author   will   see the blatant stupidity of his ways and
will   rework   the   program   into   a decent,   useful,   and   popu lar
machine   language   version.
The   marketplace   has spoken, and its message is   overwhe lming   ...
If   you want to write a   best-selling   or
money-making program for the Apple   II
or   lie,   the program   must   run in machine
language.
OK,   so it' s obvious that   all   the winning Apple   II   programs run in
machine language. But,   w h y   is this so? What makes machine   language
so   great?   How   does   machine   language   differ   from   the   so-called
" higher   level"   languages? What is machine language   al l   about?
Here are a few of the more obvious advantages of machine   lan-
guage . . .
MACHINE   LANGUAGE   IS-
Fast
Compact
Innovative
Economical
Flexible
Secure
User   Friendly
Challenging
Profitable
That's a pretty long   list   and a   lot   of heavy claims. Let' s   look   at a few
of the big adva ntages of machine language one by one . . .

Reading notes: OCR spacing irregularities in some words such as 'wi ll' and 'overwhe lming' 'Apple lie' likely a misprint of 'Apple IIe'

Printed product names: Apple II

Languages: English

[Original PDF page 10](https://www.vintageapple.net/files/9d01a190feef4de8f3155bb19972d041cefd95336506c2b403245097a1aad46d/Assembly_Cookbook_foor_the_Apple_II_IIE_1984.pdf#page=10)

### PDF page 11

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-assembly-cookbook-foor-the-apple-ii-iie-1984-986489/1#scan-8e373d961713e19041ae25c7a615de3ca72f612479095d7c3d12dab4bf9bfa9c)

Assembly Cookbook fo r the Apple /I/lie

Transcribed text:

JJNd.
cc
0
Assembly Cookbook fo r the Apple   /I/lie   11
Speed
It   takes from two to six   millionths   of a second, or   microseconds,   to
store some   value   using   Apple' s   6502   machine   language.   Switch to
interpreted   Integer   BASIC   or   Applesoft,   and   si milar   tasks take as much
as two to six thousandths of a second, or   milliseconds.   This is   slower
by a factor of one thousa nd.
The   reason for the   1000:1   speed   difference   between   interp reted
" high   level"   languages   and   machine   language   is   that   there   are
bunches of housekeeping and overhead   involved   in deciding w hi ch
tasks have to be done in what order, and in keepi ng things as pro-
grammer   friend ly   as   possible.
Now, at first   glance,   speed doesn't see m   like   too big a   deal.   But
speed is   crucial   in many progra ms. Let's   look   at three   examples.
For   instance,   a word   processo r   program   that   inserts characters
slower   than you can type is a   total   disaster, for one or more characters
can get dropped . Even if it doesn't drop c haracters, a word processor
that gets behind   disp laying   stuff on the sc reen gets to be very infuriat-
ing and annoying.   So,   word processing is one area where machine
language   programs   are   an   absol ute   must,   because of the   needed
speed.
Business sorts and searches are another area where the speed of
machine   language   makes a   dramatic   difference.   Several   thousand
items sorted in interpreted   BASIC   using a   bubble   sort might take a few
hours. Go to a quicksort und er mach ine   language,   and the same job
takes a few seco nds at most. Thu s, any business program that   involves
sorts and searches of any type is a prime candidate for mach ine   lan-
guage.
Finally,   there is any program that uses animation.   Interpreted   BASIC
is way too   slow   and far too   cl umsy   to do anything   useful   in the way of
screen motion, game respo nses, video art, and stuff   like   this. Thus, a//
challenging   or   interesting games   need   machi ne   language   to   keep
them that way.
But, you may ask, w hat about   compilers?   Aren' t there a bunch of
very expensive programs   available   that   wi ll   compile   BASIC   listings   into
fast- running machine   language   programs?
Sure   there are.
Most   compiled   code   usual ly   runs faster than interpreted code. But,
w hen you find the   real-world   speedup you get and co mpare it to the
same program done in mach ine   language   by a   ski ll ed   autho r, it is   still
no contest ...
Most programs   compiled   from a   "higher
level"   language   will   run far   slower,   and
will   perform far more   poorly,   than the
same task done in a machine   language
program written by a knowing author.
Some   specifics.   If   you run   exactly   the worst-case benchmark pro-
gram on one of today's   highly   promoted   compiler   programs, you get a
blinding   speedup of   8 percent,   compared to just using   plain   old   inter-
preted   BASIC.   Which means that a task that took two hours and fifty-
five minutes can now be wh ipped through in a mere two hours and
forty-two minutes instead.

Reading notes: Running header 'JJNd.' and 'cc' and '0' are unclear fragments Headline spacing in 'Assembly Cookbook fo r the Apple /I/lie' may be OCR artifact Some hyphenated line breaks and spacing errors in body text

Printed product names: Apple /I/lie · Apple' s 6502 · Integer BASIC · Applesoft

Languages: English

[Original PDF page 11](https://www.vintageapple.net/files/9d01a190feef4de8f3155bb19972d041cefd95336506c2b403245097a1aad46d/Assembly_Cookbook_foor_the_Apple_II_IIE_1984.pdf#page=11)

[Next transcribed scans](https://www.vintageapple.net/transcripts/media/va-assembly-cookbook-foor-the-apple-ii-iie-1984-986489/2.md)
