<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.softalkapple.com"  xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>The Softalk Apple Project - Programming</title>
 <link>http://www.softalkapple.com/tags/programming</link>
 <description></description>
 <language>en</language>
<item>
 <title>Digging In to the Roger Wagner Archive</title>
 <link>http://www.softalkapple.com/content/digging-roger-wagner-archive</link>
 <description>&lt;div class=&quot;field field-name-field-tags field-type-taxonomy-term-reference field-label-hidden view-mode-rss&quot;&gt;&lt;ul class=&quot;field-items&quot;&gt;&lt;li class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/news&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;News&lt;/a&gt;&lt;/li&gt;&lt;li class=&quot;field-item odd&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/assembly-language&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;Assembly Language&lt;/a&gt;&lt;/li&gt;&lt;li class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/programming&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;Programming&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden view-mode-rss&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; property=&quot;content:encoded&quot;&gt;&lt;div class=&quot;image-right&quot;&gt;
&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;//www.youtube.com/embed/pgJuilzsAmQ&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;p&gt; For all of you &lt;strong&gt;Assembly Lines&lt;/strong&gt; fans out there, STAP&#039;s multi-award winning &lt;strong&gt;Chris Torrence&lt;/strong&gt; recently posted this excellent YouTube video showcasing the new book, &lt;em&gt;&lt;a href=&quot;/blogs/assembly-lines-complete-book&quot;&gt;Assembly Lines: The Complete Book&lt;/a&gt;&lt;/em&gt;, the first in his series of Assembly Lines videos. To date he has posted three videos. The first of his videos is reposted here. It provides an overview of the table of contents with general information about the book itself and where you can get it.&lt;/p&gt;
&lt;p&gt;His next two videos drill down into more specific topics: &lt;a href=&quot;https://www.youtube.com/watch?v=p4vexfGMjEY&amp;amp;index=2&amp;amp;list=PLulp9MiRMeNonsKuYpPBr7QkGRciah7aL&quot;&gt;Assembly Lines #1: The Merlin Assembler&lt;/a&gt;; and &lt;a href=&quot;https://www.youtube.com/watch?v=ZQiandPA49E&amp;amp;index=3&amp;amp;list=PLulp9MiRMeNonsKuYpPBr7QkGRciah7aL&quot;&gt;Assembly Lines #2: Merlin Assembler Editor&lt;/a&gt;. Since they are consecutively numbered, be looking for many more in this series as Chris takes us on his passion-driven journey into the heart of the Assembly language.&lt;/p&gt;
&lt;p&gt;We are very proud of STAP&#039;s first &lt;a href=&quot;/content/roll-your-sleeves-become-stap-volunteer-archivist&quot;&gt;Volunteer Archivist&lt;/a&gt;. By taking on the task of archiving the &lt;strong&gt;Roger Wagner&lt;/strong&gt; and &lt;strong&gt;Assembly Lines&lt;/strong&gt; content in the 48 issues of &lt;em&gt;Softalk&lt;/em&gt;, Chris is doing an amazing job of reinvigorating interest in Assembly Language programming. We are pleased to have him on board and look forward to more amazing contributions from Chris as the &lt;strong&gt;Softalk Apple Project &lt;/strong&gt;continues to evolve.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Tue, 20 Jan 2015 21:08:02 +0000</pubDate>
 <dc:creator>Timlynn Babitsky</dc:creator>
 <guid isPermaLink="false">193 at http://www.softalkapple.com</guid>
 <comments>http://www.softalkapple.com/content/digging-roger-wagner-archive#comments</comments>
</item>
<item>
 <title>Assembly Lines: The Complete Book</title>
 <link>http://www.softalkapple.com/blogs/assembly-lines-complete-book</link>
 <description>&lt;div class=&quot;field field-name-field-image field-type-image field-label-hidden view-mode-rss&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;figure class=&quot;clearfix field-item even&quot;&gt;&lt;a href=&quot;http://www.softalkapple.com/sites/default/files/ALCover%20small.jpg&quot;&gt;&lt;img typeof=&quot;foaf:Image&quot; class=&quot;image-style-large&quot; src=&quot;http://www.softalkapple.com/sites/default/files/styles/large/public/ALCover%20small.jpg?itok=6MUi3A9n&quot; width=&quot;265&quot; height=&quot;400&quot; alt=&quot;Assembly Lines: The Complete Book cover&quot; title=&quot;Assembly Lines: The Complete Book&quot; /&gt;&lt;/a&gt;&lt;/figure&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-tags field-type-taxonomy-term-reference field-label-hidden view-mode-rss&quot;&gt;&lt;ul class=&quot;field-items&quot;&gt;&lt;li class=&quot;field-item even&quot;&gt;&lt;a href=&quot;/tags/reprint&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;Reprint&lt;/a&gt;&lt;/li&gt;&lt;li class=&quot;field-item odd&quot;&gt;&lt;a href=&quot;/tags/programming&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;Programming&lt;/a&gt;&lt;/li&gt;&lt;li class=&quot;field-item even&quot;&gt;&lt;a href=&quot;/tags/roger-wagner&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;Roger Wagner&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden view-mode-rss&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; property=&quot;content:encoded&quot;&gt;&lt;p&gt;I am very excited to announce that Assembly Lines: The Complete Book is now available as a &lt;a href=&quot;http://www.lulu.com/shop/roger-wagner/assembly-lines-the-complete-book/hardcover/product-21959093.html&quot;&gt;hardcover from Lulu press&lt;/a&gt;. Roger Wagner’s Assembly Lines articles originally appeared in Softalk magazine from October 1980 to June 1983. The first fifteen articles were reprinted in 1982 in &lt;a href=&quot;https://openlibrary.org/books/OL8356855M/Assembly_Lines&quot;&gt;Assembly Lines: The Book&lt;/a&gt;. Now, for the first time, all thirty-three articles are available in one complete volume. This edition also contains all of the appendices from the original book as well as new appendices on the 65C02, zero-page memory usage, and a beginner’s guide to using the Merlin Assembler. The book is designed for students of all ages: the nostalgic programmer enjoying the retro revolution, the newcomer interested in learning low-level assembly coding, or the embedded systems developer using the latest 65C02 chips from Western Design Center.&lt;/p&gt;
&lt;p&gt;The book will be available in a few weeks from Amazon and other online retailers. I am currently working on an eBook version, which I hope to have finished in early 2015.&lt;/p&gt;
&lt;p&gt;You can download disk images of all of the assembly-language programs from the &lt;a href=&quot;ftp://ftp.apple.asimov.net//pub/apple_II/images/programming/assembler/&quot;&gt;Asimov ftp site&lt;/a&gt; in the pub/apple_II/images/programming/assembler directory:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;AssemblyLinesWagnerDOS1.DSK contains DOS versions for chapters 1-17&lt;/li&gt;
&lt;li&gt;AssemblyLinesWagnerDOS2.DSK contains DOS versions for chapters 18-30&lt;/li&gt;
&lt;li&gt;AssemblyLinesWagnerProDOS1.DSK contains ProDOS versions for chapters 1-17&lt;/li&gt;
&lt;li&gt;AssemblyLinesWagnerProDOS2.DSK contains ProDOS versions for chapters 18-30&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Note that a few of the programs (in the DOS chapter) will only work in DOS, not ProDOS. &lt;/p&gt;
&lt;p&gt;To create your own programs, you can download a copy of the Merlin assembler from the same directory: &lt;/p&gt;
&lt;ul&gt;&lt;li&gt;merlin/Merlin-8 v2.48 (DOS 3.3).dsk &lt;/li&gt;
&lt;li&gt;merlin/Merlin-8 v2.58 (ProDOS) Disk 1-2.dsk&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;These disk images can be opened in any of the Apple II emulators, such as &lt;a href=&quot;http://www.virtualii.com&quot;&gt;Virtual ][&lt;/a&gt; for the Mac or &lt;a href=&quot;https://github.com/AppleWin/AppleWin&quot;&gt;AppleWin&lt;/a&gt; for Windows. You could also use &lt;a href=&quot;http://adtpro.sourceforge.net&quot;&gt;ADTPro&lt;/a&gt; to transfer the disk images to an actual Apple II.&lt;/p&gt;
&lt;p&gt;I would love to get your feedback on the new book. If you have any questions or comments on the new book or the original articles, please post them below.&lt;/p&gt;
&lt;p&gt;Here&#039;s a video &lt;a href=&quot;https://www.youtube.com/watch?v=pgJuilzsAmQ&quot;&gt;explaining more about how the book was created&lt;/a&gt;...&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Mon, 22 Dec 2014 17:45:30 +0000</pubDate>
 <dc:creator>Chris Torrence</dc:creator>
 <guid isPermaLink="false">171 at http://www.softalkapple.com</guid>
 <comments>http://www.softalkapple.com/blogs/assembly-lines-complete-book#comments</comments>
</item>
<item>
 <title>Assembly Lines by Roger Wagner - Part 16</title>
 <link>http://www.softalkapple.com/content/assembly-lines-roger-wagner-part-16</link>
 <description>&lt;div class=&quot;field field-name-field-image field-type-image field-label-hidden view-mode-rss&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;figure class=&quot;clearfix field-item even&quot; rel=&quot;og:image rdfs:seeAlso&quot; resource=&quot;http://www.softalkapple.com/sites/default/files/styles/large/public/images/AssemblyLines_masthead.png?itok=00-q9QGP&quot;&gt;&lt;a href=&quot;http://www.softalkapple.com/sites/default/files/images/AssemblyLines_masthead.png&quot;&gt;&lt;img typeof=&quot;foaf:Image&quot; class=&quot;image-style-large&quot; src=&quot;http://www.softalkapple.com/sites/default/files/styles/large/public/images/AssemblyLines_masthead.png?itok=00-q9QGP&quot; width=&quot;420&quot; height=&quot;114&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/figure&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-tags field-type-taxonomy-term-reference field-label-hidden view-mode-rss&quot;&gt;&lt;ul class=&quot;field-items&quot;&gt;&lt;li class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/reprint&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;Reprint&lt;/a&gt;&lt;/li&gt;&lt;li class=&quot;field-item odd&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/programming&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;Programming&lt;/a&gt;&lt;/li&gt;&lt;li class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/roger-wagner&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;Roger Wagner&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden view-mode-rss&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; property=&quot;content:encoded&quot;&gt;&lt;p&gt;&lt;em&gt;Assembly Lines, Part 16 was first published in Softalk in January 1982. This was the first article in what was supposed to be &quot;Volume 2&quot; of &quot;Assembly Lines: The Book&quot;. Unfortunately, Volume 2 remained unpublished when Softalk went bankrupt in August 1984. Part 16 is actually the first of three parts where Roger Wagner explains how to interface assembly language with Applesoft Basic.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Everyone&#039;s Machine Language Guide, Part 16&lt;/h2&gt;
&lt;p&gt;One useful application of machine language programming is in the enhancement of your existing Applesoft programs. Some people are inclined to write all their programs in machine language, but it may be more efficient on occasion to write “hybrids”—programs that are a combination of Applesoft and machine language. In this way, particular functions can be done by the operating system best suited to the particular task.&lt;/p&gt;
&lt;p&gt;If you had to write a short program to store ten names, it would be best to do it in Applesoft:&lt;/p&gt;
&lt;p&gt;10 FOR I = 1 TO 10&lt;br /&gt;
20 INPUT N$(l)&lt;br /&gt;
30 NEXT I&lt;/p&gt;
&lt;p&gt;This is much simpler than the equivalent program in machine language. In cases where neither speed nor program size is a concern, Applesoft is a completely acceptable solution.&lt;/p&gt;
&lt;p&gt;However, if you had to sort a thousand names, speed would become a concern, and it would be worth considering whether the job could best be done in machine language.&lt;/p&gt;
&lt;p&gt;If you have ever done a call in one of your Basic programs, then you have already combined Applesoft with machine code. For example:&lt;/p&gt;
&lt;p&gt;10 HOME&lt;br /&gt;
20 PRINT &quot;THIS IS A TEST&quot;&lt;br /&gt;
30 PRINT &quot;THIS IS STILL A TEST&quot;&lt;br /&gt;
40 GET A$&lt;br /&gt;
50 VTAB 1: HTAB 5: CALL-958&lt;/p&gt;
&lt;p&gt;In this program, a line of text is printed on the screen. After you press a key, all text on the screen after the first word “THIS” is cleared.&lt;/p&gt;
&lt;p&gt;Now although it might be possible to accomplish the same effect in Applesoft by printing many blank lines, it would not be as fast or as efficient in terms of code as the call -958.&lt;/p&gt;
&lt;p&gt;In executing the above program, the Applesoft interpreter goes along carrying out your instructions until it reaches the call statement. At that point a JSR is done to the address indicated by the call. When the final RTS is encountered, control returns to the Basic program. In between, however, you can do anything you’d like!&lt;/p&gt;
&lt;p&gt;Calling routines is hardly complicated enough to warrant an entire article on the subject. The real questions are, how do you pass data back and forth between the two programs, and how can the problem of handling that data be made easier for the machine language program?&lt;/p&gt;
&lt;p&gt;Simple Interfacing. The easiest way to pass data to a machine language routine is simply to poke the appropriate values into unused memory locations, and then retrieve them when you get to your machine language routine. To illustrate this, let’s resurrect the tone routine from the May 1981 issue of Softalk.&lt;/p&gt;
&lt;p&gt;To use this, assemble the code and place the final object code at $300. Then enter the accompanying Applesoft program.&lt;/p&gt;
&lt;p&gt;1 **********************&lt;br /&gt;
2 * SOUND ROUTINE #3A *&lt;br /&gt;
3 **********************&lt;br /&gt;
4	*&lt;br /&gt;
5	*&lt;br /&gt;
6	OBJ $300&lt;br /&gt;
7	ORG $300&lt;br /&gt;
8	*&lt;br /&gt;
9 PITCH EQU $06&lt;br /&gt;
10	DURATION EQU $07&lt;br /&gt;
11	SPKR EQU $C030&lt;br /&gt;
12	*&lt;br /&gt;
13	BEGIN LDX DURATION&lt;br /&gt;
14	LOOP LDY PITCH&lt;br /&gt;
15	LDA	SPKR&lt;br /&gt;
16	DELAY	DEY&lt;br /&gt;
17	BNE	DELAY&lt;br /&gt;
18	DRTN DEX&lt;br /&gt;
19	BNE	LOOP&lt;br /&gt;
20	EXIT RTS&lt;/p&gt;
&lt;p&gt;From the Monitor, this will appear as:&lt;/p&gt;
&lt;p&gt;*300L&lt;br /&gt;
0300-	A6	07	LDX	$07&lt;br /&gt;
0302-	A4	06	LDY	$06&lt;br /&gt;
0304-	AD	30 CO LDA	$C030&lt;br /&gt;
0307-	88	DEY&lt;br /&gt;
0308-	DO	FD	BNE	$0307&lt;br /&gt;
030A-	CA	DEX&lt;br /&gt;
030B-	DO	F5	BNE	$0302&lt;br /&gt;
030D-	60	RTS&lt;/p&gt;
&lt;p&gt;This Applesoft program is used to call it:&lt;/p&gt;
&lt;p&gt;10 INPUT &quot;PITCH, DURATION? &quot;;P,D 20 POKE 6,P: POKE 7,D 30 CALL 768 40 PRINT 50 GOTO 10&lt;/p&gt;
&lt;p&gt;The Applesoft program works by first requesting values for the pitch and duration of the tone from the user. These values are then poked into locations 6 and 7 and the tone routine called. The tone routine uses these values to produce the desired sound, and then returns to the calling program for another round.&lt;/p&gt;
&lt;p&gt;This technique works fine for limited applications. Having to poke all the desired parameters into various comers of memory is not flexible, and strings are nearly impossible. There must be an alternative.&lt;/p&gt;
&lt;p&gt;The Internal Structure of Applesoft. If you’ve been following this series for long, you’ve no doubt figured out by now that I’m a great believer in using routines already present in the Apple where possible, to accomplish a particular task. Since routines already exist in Applesoft for processing variables directly, why not use them?&lt;/p&gt;
&lt;p&gt;To answer this, we must take a brief detour to outline how Applesoft actually “runs” a program.&lt;/p&gt;
&lt;p&gt;Consider this simple program:&lt;/p&gt;
&lt;p&gt;10 HOME: PRINT &quot;HELLO&quot;&lt;br /&gt;
20 END&lt;/p&gt;
&lt;p&gt;After you’ve entered this into the computer, typing list should reproduce the listing given here. An interesting question arises: “How does the computer actually store, and then later execute, this program?”&lt;/p&gt;
&lt;p&gt;To answer that, we’ll have to go to the Monitor and examine the program data directly.&lt;/p&gt;
&lt;p&gt;The first question to answer is, exactly where in the computer is the program stored? This can be found by entering the Monitor and typing in: 67 68 AF B0 and pressing return.&lt;/p&gt;
&lt;p&gt;The computer should respond with:&lt;/p&gt;
&lt;p&gt;67-	01&lt;br /&gt;
68-	08&lt;br /&gt;
AF-	18&lt;br /&gt;
B0-	08&lt;/p&gt;
&lt;p&gt;The first pair of numbers is the pointer for the program beginning, bytes reversed of course. They indicate that the program starts at $801. The second pair is the program end pointer, and they show it ends at $818. Using this information let’s examine the program data by typing in:&lt;/p&gt;
&lt;p&gt;801L&lt;/p&gt;
&lt;p&gt;You should get:&lt;/p&gt;
&lt;p&gt;*801L&lt;br /&gt;
0801-	10	08	BPL	$080B&lt;br /&gt;
0803-	0A	ASL&lt;br /&gt;
0804-	00	BRK&lt;br /&gt;
0805-	97	???&lt;br /&gt;
0806-	3A	???&lt;br /&gt;
0807-	BA	TSX&lt;br /&gt;
0808-	22	???&lt;br /&gt;
0809-	48	PHA&lt;br /&gt;
080A-	45	4C	EOR	#$4C&lt;br /&gt;
080C-	4C	4F 22 JMP	$224F&lt;br /&gt;
080F-	00	BRK&lt;br /&gt;
0810-	16	08	ASL	$08,X&lt;br /&gt;
0812-	14	???&lt;br /&gt;
0813-	00	BRK&lt;br /&gt;
0814-	80	???&lt;br /&gt;
0815-	00	BRK&lt;br /&gt;
0816-	00	BRK&lt;br /&gt;
0817-	00	BRK&lt;br /&gt;
0818-	F9 A2 00 SBC $00A2,Y&lt;br /&gt;
08IB-	86	FE	STX	$FE&lt;/p&gt;
&lt;p&gt;This is obviously not directly executable code. Now type in: 801.818&lt;/p&gt;
&lt;p&gt;This will give:&lt;/p&gt;
&lt;p&gt;0801-	10	08	0A	00	97	3A	BA&lt;br /&gt;
0808-	22	48	45	4C	4C	4F	22	00&lt;br /&gt;
0810-	16	08	14	00	80	00	00	00&lt;br /&gt;
0818- 8C&lt;/p&gt;
&lt;p&gt;To understand this, let’s break it down one section at a time. When the Apple stores a line of Basic, it encodes each keyword as a single byte token. Thus the world print is stored as a $BA. This does wonders for conserving space. In addition, there is some basic overhead associated with packaging the line, namely a byte to signify the end of the line, and a few bytes at the beginning of each line to hold information related to the length of the line, and also the line number itself.&lt;/p&gt;
&lt;p&gt;To be more specific:&lt;/p&gt;
&lt;p&gt;0801- 10 08 0A 00 97 3A BA&lt;br /&gt;
0808- 22 48 45 4C 4C 4F 22 00&lt;br /&gt;
0810- 16 08 14 00 80 00 00 000&lt;br /&gt;
818- 8C&lt;/p&gt;
&lt;p&gt;The first two bytes of every line of an Applesoft program are an index to the address of the beginning of the next line. At $801,802 we find the address $810 (bytes reversed). This is where line 20 starts. At $810 we find the address $816. This is where the next line would start if there were one. The double 00 at $816 tells Applesoft that this is the end of the Basic listing. It is important to realize that the 00 00 end of the Applesoft program usually, but not always, corresponds to the contents of $AF,B0. It is possible to hide machine language code between the end of the line data and the actual end as indicated by $AF,B0—but more on that later.&lt;/p&gt;
&lt;p&gt;The next information within a line is the line number itself:&lt;/p&gt;
&lt;p&gt;0801-	10	08 0A	00 97	3A	BA&lt;br /&gt;
0808-	22	48 45	4C 4C	4F	22	00&lt;br /&gt;
0810-	16 	 08  14  00	80	00	00	00&lt;br /&gt;
0818- 8C&lt;/p&gt;
&lt;p&gt;The 0A 00 is the two-byte form of the number ten, the line number of the first line of the Applesoft program. Likewise, the 14 00 is the data for the line number twenty. The bytes are again reversed. After these four bytes, we see the actual tokens for each line.&lt;/p&gt;
&lt;p&gt;0801-	10	08 0A	00	 97 	 3A 	 BA&lt;br /&gt;
0808-	22	48 45	4C 4C	4F	22	00&lt;br /&gt;
0810-	16	08 14	00 80	00	00	00&lt;br /&gt;
0818- 8C&lt;/p&gt;
&lt;p&gt;All bytes with a value of $80 or greater are Applesoft keywords in token form. Bytes less than $80 represent normal ASCII data (letters of the alphabet, for example). Examining the data here we see a $97 followed by $3A. $97 is the token for home, and $3A the colon. Next, $BA is the token for print. This is followed by the quote ($22) and the text for HELLO (48 45 4C 4C 4F) and the closing quote ($22). Last of all, the 00 indicates the end of the line.&lt;/p&gt;
&lt;p&gt;In line number twenty, the $80 is the token for end. As before, the line is terminated with a 00.&lt;/p&gt;
&lt;p&gt;When a program is executed, the interpreter scans through the data. Each time it encounters a token, such as the print token, it looks up the value in a table to see what action should be taken. In the case of print, this would be to output the characters following the token, namely “HELLO”.&lt;/p&gt;
&lt;p&gt;This constant translation is the reason for the use of the term interpreter for Applesoft Basic.&lt;/p&gt;
&lt;p&gt;Machine code on the other hand is directly executable by the 6502 microprocessor and hence is much faster, since no table lookups are required.&lt;/p&gt;
&lt;p&gt;In Applesoft, a syntax error is generated whenever a series of tokens is encountered that is not consistent with what the interpreter expects to find.&lt;/p&gt;
&lt;p&gt;Passing Variables. So, back to the point of all this. The key to passing variables to your own machine language routines is to work with Applesoft in terms of routines already present in the machine. One of the simplest methods was described in the October 1981 issue of Softalk, wherein a given variable is the very first one defined in your program (see the input routine). This is okay, but rather restrictive. A better way is to name the variable you’re dealing with right in the call statement.&lt;/p&gt;
&lt;p&gt;The important points here are two components of the Applesoft interpreter: TXTPTR and CHRGET (and related routines).&lt;/p&gt;
&lt;p&gt;TXTPTR is the two-byte pointer ($B8, B9) that points to the next token to be analyzed. CHRGET ($B1) is a very short routine that actually resides on the zero page and that reads a given token into the accumulator. In addition to occasionally being called directly, many other routines used CHRGET to process a string of data in an Applesoft program line.&lt;/p&gt;
&lt;p&gt;Here then is the revised tone routine :&lt;/p&gt;
&lt;p&gt;1	**********************&lt;br /&gt;
2	* SOUND ROUTINE #3B *&lt;br /&gt;
3	**********************&lt;br /&gt;
4	*&lt;br /&gt;
5	*&lt;br /&gt;
6	OBJ $300&lt;br /&gt;
7	ORG $300&lt;br /&gt;
8	*&lt;br /&gt;
9 PITCH EQU $06&lt;br /&gt;
10	DURATION EQU $07&lt;br /&gt;
11	SPKR EQU $C030&lt;br /&gt;
12	*&lt;br /&gt;
13	COMBYTE EQU $E74C&lt;br /&gt;
14	*&lt;br /&gt;
15	ENTRY JSR COMBYTE&lt;br /&gt;
16	STX PITCH&lt;br /&gt;
17	JSR COMBYTE&lt;br /&gt;
18	STX DURATION&lt;br /&gt;
19	*&lt;br /&gt;
20	BEGIN LDX DURATION&lt;br /&gt;
21	LOOP LDY PITCH&lt;br /&gt;
22	LDA SPKR&lt;br /&gt;
23	DELAY DEY&lt;br /&gt;
24	BNE DELAY&lt;br /&gt;
25	DRTN DEX&lt;br /&gt;
26	BNE LOOP&lt;br /&gt;
27	EXIT RTS&lt;/p&gt;
&lt;p&gt;This would list from the Monitor as:&lt;/p&gt;
&lt;p&gt;*300L&lt;/p&gt;
&lt;p&gt;0300-	20	4C	E7	JSR	$E74C&lt;br /&gt;
0303-	86	06	STX	$06&lt;br /&gt;
0305-	20	4C	E7	JSR	$E74C&lt;br /&gt;
0308-	86	07	STX	$07&lt;br /&gt;
030A-	A6	07	LDX	$07&lt;br /&gt;
030C-	A4	06	LDY	$06&lt;br /&gt;
030E-	AD	30	CO	LDA	$C030&lt;br /&gt;
0311-	88	DEY&lt;br /&gt;
0312-	DO	FD	BNE	$0311&lt;br /&gt;
0314-	CA	DEX&lt;br /&gt;
0315-	DO	F5	BNE	$030C&lt;br /&gt;
0317-	60	RTS&lt;/p&gt;
&lt;p&gt;The Applesoft calling program would then be revised to read:&lt;/p&gt;
&lt;p&gt;10 INPUT &quot;PITCH DURATION? &quot;,P,D&lt;br /&gt;
20 CALL 768,P,D&lt;br /&gt;
30 PRINT&lt;br /&gt;
40 GOTO 10&lt;/p&gt;
&lt;p&gt;This is a much more elegant way of passing the values and also requires no miscellaneous memory locations as such (although for purposes of simplicity the tone routine itself still uses the same zero page locations.)&lt;/p&gt;
&lt;p&gt;The secret to the new technique is the use of the routine COMBYTE ($E74C). This is an Applesoft routine which checks for a comma and then returns a value between $00 and $FF (0-255) in the X register.&lt;/p&gt;
&lt;p&gt;It is normally used for evaluating pokes, hcolor=t and so forth, but does the job very nicely here. It also leaves TXTPTR pointing to the end of the line (or a colon if there was one) by using CHRGET to advance TXTPR appropriate to the number of characters following each comma. Note also that any legal expression--such as (X-5)/2--can be used to pass the data.&lt;/p&gt;
&lt;p&gt;To verify the importance of managing TXTPTR, try putting a simple RTS ($60) at $300. Calling this you will get a SYNTAX ERROR, since upon return, Applesoft’s TXTPTR will be on the first comma, and the phrase “,P,D” is not a legal Applesoft expression.&lt;/p&gt;
&lt;p&gt;Now what about two-byte quantities? To do this, a number of other routines are used. For example, this routine will do the equivalent of a two-byte pointer poke. Suppose for instance you wanted to store the bytes for the address $9600 at locations $1000, 1001. Normally in Applesoft you would do it like this:&lt;/p&gt;
&lt;p&gt;50 POKE 4096,0: POKE 4097,150&lt;/p&gt;
&lt;p&gt;Where 4096 and 4097 are the decimal equivalents of $1000 and $1001 and 0 and 150 are the low-order and high-order bytes for the address $9600 ($96 = 150, $00 = 0).&lt;/p&gt;
&lt;p&gt;A more convenient approach might be like this:&lt;/p&gt;
&lt;p&gt;50 CALL 768, 4096, 38400&lt;/p&gt;
&lt;p&gt;or perhaps:&lt;/p&gt;
&lt;p&gt;50 CALL 768, A, V&lt;/p&gt;
&lt;p&gt;The routine for this would be:&lt;/p&gt;
&lt;p&gt;1 **************************&lt;br /&gt;
2	* POINTER SET UP ROUTINE *&lt;br /&gt;
3 **************************&lt;br /&gt;
4	*&lt;br /&gt;
5	*&lt;br /&gt;
6	OBJ $300&lt;br /&gt;
7	ORG $300&lt;br /&gt;
8	*&lt;br /&gt;
9	CHKCOM EQU $DEBE&lt;br /&gt;
10	FRMNUM EQU $DD67&lt;br /&gt;
11	GETADR EQU $E752&lt;br /&gt;
12	LINNUM EQU $50 ; ($50,51)&lt;br /&gt;
13	*&lt;br /&gt;
14	PTR EQU $3C&lt;br /&gt;
15	*&lt;br /&gt;
16	ENTRY JSR CHKCOM&lt;br /&gt;
17	JSR FRMNUM;	EVAL	FORMULA&lt;br /&gt;
18	JSR GETADR ;	PUT	FAC	INTO LINNUM&lt;br /&gt;
19	LDA LINNUM&lt;br /&gt;
20	STA PTR&lt;br /&gt;
21	LDA LINNUM+1&lt;br /&gt;
22	STA PTRH-1&lt;br /&gt;
23	*&lt;br /&gt;
24	JSR CHKCOM&lt;br /&gt;
25	JSR FRMNUM&lt;br /&gt;
26	JSR GETADR&lt;br /&gt;
27	*&lt;br /&gt;
28	LDY #$00&lt;br /&gt;
29	LDA LINNUM&lt;br /&gt;
30	STA (PTR),Y&lt;br /&gt;
31	INY&lt;br /&gt;
32	LDA LINNUM+1&lt;br /&gt;
33	STA (PTR),Y&lt;br /&gt;
34	*&lt;br /&gt;
35	DONE RTS&lt;/p&gt;
&lt;p&gt;which will list from the Monitor as:&lt;/p&gt;
&lt;p&gt;*300L&lt;/p&gt;
&lt;p&gt;0300-	20	BE	DE	JSR	$DEBE&lt;br /&gt;
0303-	20	67	DD	JSR	$DD67&lt;br /&gt;
0306-	20	52	E7	JSR	$E752&lt;br /&gt;
0309-	A5	50	LDA	$50&lt;br /&gt;
030B-	85	3C	STA	$3C&lt;br /&gt;
030D-	A5	51	LDA	$51&lt;br /&gt;
030F-	85	3D	STA	$3D&lt;br /&gt;
0311-	20	BE	DE	JSR	$DEBE&lt;br /&gt;
0314-	20	67	DD	JSR	$DD67&lt;br /&gt;
0317-	20	52	E7	JSR	$E752&lt;br /&gt;
031 A-	AO	00	LDY	#$00&lt;br /&gt;
031C-	A5	50	LDA	$50&lt;br /&gt;
031E-	91	3C	STA	($3C),Y&lt;br /&gt;
0320-	C8	INY&lt;br /&gt;
0321-	A5	51	LDA	$51&lt;br /&gt;
0323-	91	3C	STA	($3C),Y&lt;br /&gt;
0325-	60	RTS&lt;/p&gt;
&lt;p&gt;The special items in this routine include CHKCOM, a syntax-checking routine that serves two purposes. First it verifies that a command follows the call address, and secondly it advances TXTPTR to point to the first byte of the expression immediately following the comma. If a comma is not found, a syntax error is generated.&lt;/p&gt;
&lt;p&gt;FRMNUM is a routine that evaluates any expression and puts the real floating-point number result into Applesoft’s floating-point accumulator, usually called FAC. This is a six-byte pseudo register ($97-9C) used to hold the floating-point representation of a number. It includes such nifties as the exponential magnitude of the number and the equivalent of the digits of the logarithm of the number stored.&lt;/p&gt;
&lt;p&gt;At this stage you’d have to be something of a masochist to want to deal with the number in its current form, so the next step is used to convert it into a two-byte integer.&lt;/p&gt;
&lt;p&gt;GETADR does this by putting the two-byte result into LINNUM, LINNUM+1 ($50,51).&lt;/p&gt;
&lt;p&gt;Even if this is not exactly an in-depth explanation of all the most precise details of the operation, the bottom line is that the three JSRs (CHKCOM, FRMNUM, and GETADR) will always end up with the low-order and high-order bytes of whatever expression follows a comma in LINNUM and LINNUM+1.&lt;/p&gt;
&lt;p&gt;These simple subroutines should be quite adequate for many applications. Next month, however, we’ll look at string passing, some of the various other routines available, and how to pass data back to the calling Applesoft program.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Wed, 14 May 2014 00:54:01 +0000</pubDate>
 <dc:creator>Chris Torrence</dc:creator>
 <guid isPermaLink="false">122 at http://www.softalkapple.com</guid>
 <comments>http://www.softalkapple.com/content/assembly-lines-roger-wagner-part-16#comments</comments>
</item>
<item>
 <title>Assembly Lines by Roger Wagner - Part 1</title>
 <link>http://www.softalkapple.com/content/assembly-lines-roger-wagner-part-1</link>
 <description>&lt;div class=&quot;field field-name-field-image field-type-image field-label-hidden view-mode-rss&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;figure class=&quot;clearfix field-item even&quot; rel=&quot;og:image rdfs:seeAlso&quot; resource=&quot;http://www.softalkapple.com/sites/default/files/styles/large/public/images/AssemblyLines_masthead.png?itok=00-q9QGP&quot;&gt;&lt;a href=&quot;http://www.softalkapple.com/sites/default/files/images/AssemblyLines_masthead.png&quot;&gt;&lt;img typeof=&quot;foaf:Image&quot; class=&quot;image-style-large&quot; src=&quot;http://www.softalkapple.com/sites/default/files/styles/large/public/images/AssemblyLines_masthead.png?itok=00-q9QGP&quot; width=&quot;420&quot; height=&quot;114&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/figure&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-tags field-type-taxonomy-term-reference field-label-hidden view-mode-rss&quot;&gt;&lt;ul class=&quot;field-items&quot;&gt;&lt;li class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/reprint&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;Reprint&lt;/a&gt;&lt;/li&gt;&lt;li class=&quot;field-item odd&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/programming&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;Programming&lt;/a&gt;&lt;/li&gt;&lt;li class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/column&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;Column&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden view-mode-rss&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; property=&quot;content:encoded&quot;&gt;&lt;h2&gt;Everyone&#039;s Machine Language Guide, Part 1&lt;/h2&gt;
&lt;blockquote&gt;&lt;p&gt;NOTE: This is the first of Roger Wagner&#039;s &lt;strong&gt;Assembly Lines&lt;/strong&gt; column which began its illustrious run in the &lt;a href=&quot;/issue_profiles/v_1_n_2_october-1980&quot;&gt;October, 1980 issue&lt;/a&gt;. &lt;strong&gt;The OCR and reprint processing of this article was made possible in part by the support of STAP Project Backer, Chris Torrence&lt;/strong&gt;. Chris is a currently working (with the support and interest of Roger) on &lt;strong&gt;&quot;Roger Wagner&#039;s Assembly Lines: The Missing Volume&quot;&lt;/strong&gt; (or whatever it will be called). This new publication will bring together the Assembly Lines columns from Softalk magazine that did not make it to book form prior to the end of Softalk Publishing.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;One often gets the impression that programming in assembly language is some very difficult and obscure technique used only by &quot;those advanced programmers.&quot; As it happens, assembly language is merely different, and if you have successfully used Integer or Applesoft Basic to do some programming, there&#039;s no reason why you can&#039;t use assembly language to your advantage in your own programs.&lt;/p&gt;
&lt;div class=&quot;image-left&quot;&gt;&lt;img src=&quot;/sites/default/files/images/RogerWagner_headshot.png&quot; width=&quot;300&quot; alt=&quot;RogerWagner_headshot.png&quot; /&gt;&lt;br /&gt;&lt;span class=&quot;caption_300&quot;&gt;Roger Wagner, president of Southwestern Data Systems, authored &lt;em&gt;Apple Doc&lt;/em&gt;, the &lt;em&gt;Programmer’s Utility Package&lt;/em&gt;, which was the first Applesoft renumber program; the &lt;em&gt;Correspondent&lt;/em&gt;; and &lt;em&gt;Roger’s Easel&lt;/em&gt;, which he refers to as “my sleeper program.” Before he discovered the Apple, Roger taught math and science at Mountain Empire High School.&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;This series will take a rather unorthodox approach to explaining assembly programming. Since you are presumably somewhat familiar with Basic, we will draw many parallels between various assembly language techniques and their Basic counterparts.&lt;/p&gt;
&lt;p&gt;An important factor in learning anything new is a familiar framework into which to fit the new information. Your knowledge of Basic will provide that framework.&lt;/p&gt;
&lt;p&gt;We will also try to describe initially only those technical details of the microprocessor operations as are needed to accomplish our immediate goals. The rest will be filled in as we move to more involved techniques.&lt;/p&gt;
&lt;p&gt;The first of the technical details is the general structure, or &lt;em&gt;architecture&lt;/em&gt;, of the Apple itself. The heart of the system is the 6502 microprocessor. This device operates by scanning through a given range of memory addresses. At each location it finds some particular value. Depending on what it finds, it executes a given operation. This operation could be adding some numbers, storing a number somewhere, or any of a variety of other tasks. These interpreted values are often called &lt;em&gt;opcodes&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;In the old days, programmers would ply their trade by loading each opcode, one at a time, into successive memory locations. After a while, someone invented an easier way, using short abbreviated words (called mnemonics) for the operations. The computer would then figure out which values to use and supervise the storing of these values in consecutive memory locations. This wonder is what is generally called an assembler. It allows us to interact with the computer in a more natural way. In fact, Basic itself can be thought of as an extreme case of the assembler. We just use words like &lt;em&gt;PRINT&lt;/em&gt; and &lt;em&gt;INPUT&lt;/em&gt; to describe a whole set of the operations needed to accomplish our desired action.&lt;/p&gt;
&lt;p&gt;In some ways, assembly language is even easier than Basic. There are only fifty-five commands to learn, as opposed to more than one hundred in Basic. Also, machine code runs very fast and generally is more compact in the amount of memory needed to carry out a given operation. This opens up many possibilities for programs that would either run too slowly or take up too much room in Basic.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How the 6502 Talks to Itself.&lt;/strong&gt; Probably the most unfamiliar part of dealing with the Apple in regard to machine level operations is the way addresses and numbers in general are treated. Unless you lead an unusually charmed life, at some point in your dealings with your Apple you have had it abruptly stop what it was doing and show you something like this:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;8BF2- A=03 X=9D Y=00 P=36 S = F2&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This occurs when some machine level process suddenly encounters a break in its operation, usually from an unwanted modification of memory. Believe it or not, the Apple is actually trying to tell us something here. Unfortunately, it&#039;s rather like being a tourist and having someone shout, &lt;em&gt;&quot;Alaete quet beideggen!&quot;&lt;/em&gt; at you.* It doesn&#039;t mean much unless you know the lingo, so to speak...&lt;/p&gt;
&lt;hr /&gt;
* &quot;Watch where you&#039;re stepping, you nerd!&quot; (in case you&#039;re not familiar with this particular dialect.)
&lt;hr /&gt;&lt;p&gt;What has happened is that the Apple has encountered the break we mentioned, and in the process of recovering, has provided us with some information as to where the break occurred and what the status of the computer was at that crucial moment. This is rather like the last cryptic words from the recently departed.&lt;/p&gt;
&lt;p&gt;The leftmost part of the message is of great importance. This is where the break in the operation occurred. Now, just what do we mean by the word &lt;em&gt;where&lt;/em&gt;? Remember all that concern about whether you have a 16K, 32K, or 48K Apple? The concern was about the number of usable memory locations in your machine. This idea becomes clearer through the use of a &lt;em&gt;memory map&lt;/em&gt;, such as the one shown in figure 1.&lt;/p&gt;
&lt;div class=&quot;image-left&quot;&gt;&lt;img src=&quot;/sites/default/files/images/AssemblyLines_fig1.png&quot; width=&quot;300&quot; height=&quot;497&quot; alt=&quot;AssemblyLines_fig1.png&quot; /&gt;&lt;/div&gt;
&lt;p&gt;Inside the Apple are many electronic units that will store number values we give them. By numbering these units, we give each one a unique &lt;em&gt;address&lt;/em&gt;. This way we can specify any particular unit or memory location, either to inquire about its contents or to alter those contents by storing a new number there.&lt;/p&gt;
&lt;p&gt;In the Apple there are a total of 65,536 of these memory locations (incidentally called &lt;em&gt;bytes&lt;/em&gt;). The chart gives us a way of graphically representing each possible spot in the computer.&lt;/p&gt;
&lt;p&gt;When the computer shows us an address, it does not do it in a way similar to the numbers on the left of the memory map, but rather in the fashion of the ones on the right. You may well remark here: &quot;I didn&#039;t know &#039;BFFF&#039; was a number; it sounds more like a wet sneaker…&quot;&lt;/p&gt;
&lt;p&gt;To understand this notation, let&#039;s see how the 6502 counts. If we place our byte at the first available location, it&#039;s address is $0. The dollar sign is used in this case to show that we are not counting in our familiar decimal notation, but rather in hexadecimal (base sixteen) notation, usually called &quot;hex,&quot; which is how the computer displays and accepts data at the monitor level.&lt;/p&gt;
&lt;p&gt;After byte $0, successive locations are labeled in the usual pattern up to $9. At this point the computer uses the characters A through F for the next six locations. The location right after $F is $10. This is not to be confused with &quot;ten.&quot; It represents the decimal number sixteen. The pattern repeats itself as in usual counting with:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;$10, 11, 12, 13... 19, 1A, 1B...1E, 1F, 20&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;This method should be accepted just as a fact of life with the Apple for the time being. If you really can&#039;t stand not knowing the details of the reasoning behind this scheme, there are quite a number of books on number theory and number bases that you might peruse. Many books on assembly language also spend a chapter or two on this. It will be sufficient for our purposes, though, just to understand that $1F is as legitimate a number as 31.&lt;/p&gt;
&lt;p&gt;The hex number $FF (255) is the largest value a single byte can hold. A block of 256 bytes (for instance $0 to $FF) is often called a page of memory. In figure 2, all the addresses from $0 to $FF are shown in block &lt;em&gt;b&lt;/em&gt;. Four of these blocks together, as in &lt;em&gt;c&lt;/em&gt;, make up 1K of memory. As you can see, there are actually 1,024 bytes in 1K. Thus a 48K machine actually has 49,050 bytes of RAM.&lt;/p&gt;
&lt;div class=&quot;image-solo&quot;&gt;&lt;img src=&quot;/sites/default/files/images/AssemblyLines_fig2.png&quot; width=&quot;800&quot; height=&quot;429&quot; alt=&quot;AssemblyLines_fig2.png&quot; /&gt;&lt;/div&gt;
&lt;p&gt;Block d of figure 2 shows the Apple&#039;s entire range again. If you do not have a full 48K of memory, then the missing range will just appear to hold a constant value (usually $FF), and you will not be able to store any particular value there.&lt;/p&gt;
&lt;p&gt;The range from $C000 to $FFFF is all reserved for hardware. This means that any data stored in this range is of a permanent nature and cannot be altered by the user. Some areas are actually a physical connection to things like the speaker or game switches. Others, like $E000 to $FFFF are filled in by the chips in the machine called ROMs.&lt;/p&gt;
&lt;p&gt;ROM stands for read only memory. These chips hold the machine language routines that make up either Applesoft or Integer, depending on whether you have an Apple Plus or the standard model. One of them is also the monitor, which is what initializes the Apple when it is first turned on so you can talk to it, and also handles your input when you&#039;re at the monitor level.&lt;/p&gt;
&lt;p&gt;Now that break message should have at least a little meaning.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;8BF2- A = 03 X = 9D Y = 00 P=36 S = F2&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;The &lt;em&gt;8BF2&lt;/em&gt; is an address in memory. Rather like a &quot;catch-22,&quot; it says that the break actually occurred at the address given minus two (8BF2 - 2 = 8BF0). For reasons that aren&#039;t worth going into here, the monitor always prints out a break address in this plus-two fashion.&lt;/p&gt;
&lt;p&gt;What about the rest of the message? Consider the next three items:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;A = 03 X = 9D Y = 00&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The 6502, in addition to being able to address the various memory locations in the Apple, has a number of internal &lt;em&gt;registers&lt;/em&gt;. These are units inside the 6502 itself that can store a given number value, and they are individually addressable in much the same way memory is. The difference is that instead of being given a hexadecimal address, they are called the x-register, the y-register, and the accumulator. In our error message, we are being told the status of these three registers at the break.&lt;/p&gt;
&lt;div class=&quot;image-left&quot;&gt;&lt;img src=&quot;/sites/default/files/images/AssemblyLines_fig3.png&quot; width=&quot;600&quot; height=&quot;380&quot; alt=&quot;AssemblyLines_fig3.png&quot; /&gt;&lt;/div&gt;
&lt;p&gt;Figure 3 summarizes what we know so far. The 6502 is a microprocessor chip that has the ability to scan through a given range of memory, which we will generally specify by using hex notation for the addresses. Depending on the values it finds in each location as it scans through, it will perform various operations. As an additional feature to its operation, it has a number of internal registers, namely the x and y registers, and the accumulator. Memory-related operations are best done by entering the monitor level of the Apple (usually with a CALL-151 or RESET) and using the various routines available to us.&lt;/p&gt;
&lt;p&gt;Next issue, we&#039;ll look at what an assembler actually does, and specifically how to use the Apple&#039;s mini-assembler. This assembler is present in any standard Apple with Integer Basic, or in an Apple II Plus with the Integer Basic firmware card. If you don&#039;t have either of these, I recommend getting one of the many assembler software packages available. If you&#039;re on a limited budget, there is a free one in many user group libraries called by a variety of names including &lt;em&gt;Randy&#039;s Weekend Assembler&lt;/em&gt;, &lt;em&gt;Ted II&lt;/em&gt;, and &lt;em&gt;Assembler 3. 2&lt;/em&gt;. Get in touch with the librarian for your local group if you don&#039;t already have a copy. Otherwise, see your local computer store and get their advice on a good assembler. There are many opinions and I won&#039;t go into a review here.&lt;/p&gt;
&lt;p&gt;In the meantime, you might also look at page 49 in the most recent Apple II Reference Manual. It has an excellent discussion of the monitor commands and also of the mini-assember.&lt;/p&gt;
&lt;p&gt;Meet you here next issue! &lt;/p&gt;
&lt;p&gt;##&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Thu, 24 Apr 2014 07:45:03 +0000</pubDate>
 <dc:creator>Chris Torrence</dc:creator>
 <guid isPermaLink="false">118 at http://www.softalkapple.com</guid>
 <comments>http://www.softalkapple.com/content/assembly-lines-roger-wagner-part-1#comments</comments>
</item>
</channel>
</rss>
