MASSIVE: Documentation and Disk 1: REQUIRED

- added cycle and byte count comments
- additionally added status flag clobbering comments
- wrote beginning of final documentation form in markdown for disk 1: REQUIRED
- consolidated macros and subroutines on disk 1
- created alias macros for 65C02, 8080, and Z80 architectures
- entirely rewrote and expanded documentation for disk 1
- rewrote disk 1 demo file to use fewer bytes by using comments instead of _PRN statements
- implemented a software architeture that will span across all libraries in the collection
- added .ASM extension to text sources to help with file attribution on contemporary systems
- slightly modified the naming convention for EXEC files
- fixed minor errors
This commit is contained in:
nathanriggs 2020-01-19 15:31:10 -05:00
parent 5df0d19f48
commit 4554eaf2ae
33 changed files with 1663 additions and 1965 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 840 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 840 KiB

Binary file not shown.

Binary file not shown.

View File

@ -1,113 +0,0 @@
## Preface
This is the first complete reference manual for the _AppleIIAsm_ macro and subroutine library collection. Currently, this collection is in the alpha stages of development: not all disks are complete, there may be some bugs here and there, and major workflow decisions might still be in flux. However, this version, 0.7.0, represents a major step forward in functionality, optimization and standardization, and at least for what is complete---the first eleven disks, the technical manual, AppleChop introduction as well as some demos---the collection can be reasonably considered to be stable. That does not, of course, mean that there are any guarantees.
I started this project as research into how the Apple II works as a platform for another book I am writing, and eventually became interested in the cohesive technical documentation (or sometimes lack thereof) that was available to beginning coders in the heyday of the Apple II as well as those looking to learn Apple II (6502) Assembly today. Having no prior experience with Assembly language, I began coding these libraries as part of my own learning process while trying to write subroutines that provided much of the functionality afforded by Applesoft BASIC. Eventually, this became a beast of its own, and what youre reading here is (part) of the result.
As the libraries grow and morph, so will this document. If nothing else, I hope that the collection and its accompanying documentation helps hobbyists, researchers, and otherwise self-hating hopeless nerds learn and accomplish what they want or need---at least as much as it has helped, and harmed, me.
Nathan Riggs
## Introduction
The AppleIIAsm Library Collection is an array of subroutines and macros for the Apple II line of computers, aimed at providing a stable set of assembly routines for most common tasks. Additionally, this library is meant to ease the transition between programming in Applesoft BASIC and 6502 Assembly by not only providing the basic data structures and functions found in higher-level languages but also by providing a set a macros—currently dubbed AppleChop—that simulates the design and workflow of BASIC. A companion booklet to this library, *From Applesoft to AppleChop and Assembly,* provides a framework for making that transition.
These subroutines and macros are written for the Merlin 8 Pro assembler, which should run on any Apple II with 64k of memory (programs assembled with Merlin 8 Pro will run on machines with less than 64k, however). Since we are using 6502 Assembly here, however, it should not be too difficult to port the subroutines to other assemblers and even other systems like the Commodore 64, Nintendo Entertainment System, BBC Micro, and more. For a guide on using the Merlin Pro 8 Assembler, see the other companion booklet, *The New Merlin Pro 8 User Guide*.
It should be noted that the core libraries in this collection---those on disks one to eleven---should be compatible with every iteration of the Apple II family, from the original Apple II in 1977 to the Apple IIGS in 1986. Disks beyond that core collection are considered bonus disks, and are dedicated to either creating libraries for specialized hardware (such as much of the IIGS, or the Mockingboard) or are there to serve as more complicated and integrated demos for the user to peruse.
**Who is this manual for?**
The primary audience for this manual is someone who is already familiar with 6502 Assembly or is at least trying to learn it; that is, novices. Like all manuals, this is primarily a reference: beyond this introduction and early sections of Part I, this manual is not meant to be read straight through. Feel free to flip back and forth as you wish!
**Who is this manual NOT for?**
This manual is definitely not for someone completely unexposed to Assembly language,, but nor is it really aimed at 6502 experts. The collection itself can be used by beginner and expert alike, but whereas this manual would likely confuse the absolute beginner, an expert interested in optimizing their work (and these subroutines) will not find much help here. For those well-versed in 6502 Assembly, this collection might better serve as a prototyping system that then gets torn apart and optimized; for those barely versed in 6502 Assembly, this collection, and especially the AppleChop library, this collection will best serve to ease the transition between a standard knowedge of BASIC and the quirks of Assembly language (commenting is excessive in the libraries for this very reason). Both extremes may find this collection useful, but for wildly different reasons.
As someone who spends a *lot* of time thinking about, writing about, and teaching different facets of technical writing (in its broadest sense), I can confirm the following: there are thousands of books written about the 6502 architecture and Assembly programming. I can also confirm that these books---as well as most websites---tend to approach the subject from a "writerly" position rather than a reader-centered one; that is, written for engineers and computer scientists who have already spent a lot of time and money understanding the theory, learning the jargon, and training themselves to be able to do things by muscle memory. That's great for established engineers, mathematicians, computer scientists and the like, as well as those who can afford to dedicate years of their lives (and again, gobs of $$$) to obtain a degree that qualifies them as entry level in the field. It is not so great, however, for beginners, hobbyists, or those trying to study it from a non-engineering theoretical perspective. That is, at least, part of the gap I am hoping to fill; after all, this book is part of my research for writing another book aimed at a non-technical audience.
That said, I myself would have failed quite readily without at least a few key texts and websites, and it would be remiss to not list them here. And if you're committed to learning this, know that there is no good replacement to sitting down, typing out a listing from a book, assembling it and then trying to figure out what the hell you just did---or what you did wrong! There is no doing without learning, and there is no learning without doing. At risk of pontificting, I believe many of us have forgotten this mantra, and the internet has not helped matters.
**Why Merlin Pro 8? Why not something...modern?**
Understanding how coding for a specific platform and a specific era works is not merely a matter of knowledge, but a matter of practice. Much of the way development happens, in computer software or not, is predicated on the apparatus in place that allows for it. Changing that apparatus, whether it be adding modern components like multiple open files, faster assembly, easier access and legibility and so on changes your understanding of how everything worked (and works). Especially with an ancient (and largely obsolete) language like 6502 assembly, few people are learning it to accomplish a practical task. Instead, we are approaching the topic more like an archaeologist or historical reenactor: going through the same motions to understand the topic cohesively. This is explained more thoroughly in the Preface.
That said, there is nothing inherently wrong with using modern tools—it just does not fit the goals for writing this library. Brutal Deluxe software has rewritten a more modern version of Merlin 16, and the CC65 compiler/assembler makes contemporary 6502 development far more efficient and less frustrating overall. If Merlin 8 Pro feels too dated—and to many, it will feel hopelessly so—by all means use these modern software packages. Just be aware that some substantial effort may be involved in rewriting the code here for different assemblers. If you must, I would suggest using an Apple II emulator like _AppleWin_ with a high speed setting for compile time---though be careful if so, as it is easy to miss error interruptions.
**Further Resources**
While beginners are welcome to use this library, and it is partially aimed at those who are trying to learn 6502 Assembly on the Apple II, a cohesive and thorough guide to 6502 programming is beyond the scope of this manual. For a better understanding of the hardware, programming, and culture surrounding the Apple II, I would suggest consulting the following sources.
__*6502 Programming Books*__
- Roger Wagner, Chris Torrence. [*Assembly Lines: The Complete Book*](https://www.amazon.com/Assembly-Lines-Complete-Roger-Wagner/dp/1312089407/). May 10, 2017. <https://www.amazon.com/Assembly-Lines-Complete-Roger-Wagner/dp/1312089407/>
- Lance A. Leventhal, Winthrop Saville. *6502 Assembly Language Subroutines*. 1982.
- Don Lancaster. *Assembly Cookbook for the Apple II, IIe*. 1984, 2011.
- Mark Andrews. _Apple Roots: Assembly Language Programming for the Apple IIe and IIc_. 1986.
- CW Finley, Jr., Roy E. Meyers. *Assembly Language for the Applesoft Programmer*. 1984.
- Randy Hyde. *Using 6502 Assembly Language*. 1981.
- Glen Bredon. *Merlin Pro Instruction Manual*. 1984.
- JS Anderson. *Microprocessor Technology*. 1994. (also covers z80 architecture)
__*6502 Programming Websites*__
- [CodeBase64](http://codebase64.org/doku.php). <http://codebase64.org/doku.php>
- [6502.org](http://www.6502.org/). <http://www.6502.org/>
- [Easy6502](http://skilldrick.github.io/easy6502/). <http://skilldrick.github.io/easy6502/>
__*Apple II Books*__
- Bill Martens, Brian Wiser, William F. Luebbert, Phil Daley. [*What's Where in the Apple, Enhanced Edition: A Complete Guide to the Apple \]\[ Computer*.](https://www.amazon.com/gp/product/136517364X/) October 11, 2016. <https://www.amazon.com/gp/product/136517364X/>
- David Flannigan. [*The New Apple II Users' Guide*](https://www.amazon.com/gp/product/0615639879/). June 6, 2012. https://www.amazon.com/gp/product/0615639879/
- David L. Craddock. [*Break Out: How the Apple II Launched the PC Gaming Revolution*](https://www.amazon.com/gp/product/0764353225/). September 28, 2017. https://www.amazon.com/gp/product/0764353225/
- Steven Weyhrich. [*Sophistication ;&amp; Simplicity: The Life and Times of the Apple II Computer*](https://www.amazon.com/gp/product/0986832278/). December 1, 2013. https://www.amazon.com/gp/product/0986832278/
- Ken Williams, Bob Kernagham, Lisa Kernagham. [*Apple II Computer Graphics*](https://www.amazon.com/gp/product/B01FIXG7ZK/). November 3, 1983. <https://www.amazon.com/gp/product/B01FIXG7ZK/>
- Lon Poole. [*Apple II Users' Guide*.](https://www.amazon.com/gp/product/0931988462/). 1981. <https://www.amazon.com/gp/product/0931988462/>
- Jeffrey Stanton. *Apple Graphics and Arcade Game Design*. 1982.
- Apple. *Apple Monitors Peeled*. 1981.
- Apple. _Apple II/IIe/IIc/IIgs Technical Reference Manual._
*__Apple II Websites__*
- [Apple II Text Files](http://textfiles.com/apple/.windex.html). <http://textfiles.com/apple/.windex.html>
- [Apple II Programming](http://apple2.org.za/gswv/a2zine/faqs/csa2pfaq.html). <http://apple2.org.za/gswv/a2zine/faqs/csa2pfaq.html>
- [The Asimov Software Archive](https://ftp.apple.asimov.net/). <https://ftp.apple.asimov.net/>
- [Apple II Online](https://apple2online.com/index.php). <https://apple2online.com/index.php>
- [Juiced.GS: A Quarterly Apple II Journal](https://juiced.gs/). <https://juiced.gs/>
_**Related GitHub Projects**_
A number of folk are doing work on 6502 or the Apple II on GitHub. While I cannot possibly list each and every one (that's what the search function is for!), these are projects I have found particularly useful, informative, entertaining, or inspiring.
- [Prince of Persia Apple II Source Code](https://github.com/fabiensanglard/Prince-of-Persia-Apple-II), by Jordan Mechner. <https://github.com/fabiensanglard/Prince-of-Persia-Apple-II>
- [WeeGUI, a small gui for the Apple II](https://github.com/blondie7575/WeeGUI). <https://github.com/blondie7575/WeeGUI>
- [Two-lines or less Applesoft programs](https://github.com/thelbane/Apple-II-Programs) --- a lot can be accomplished! <https://github.com/thelbane/Apple-II-Programs>
- [Doss33FSProgs](https://github.com/deater/dos33fsprogs), programs for manipulating the DOS 3.3 filesystem. <https://github.com/deater/dos33fsprogs>
- [ADTPro](https://github.com/ADTPro/adtpro), a requirement for anyone working with real Apple II hardware today. <https://github.com/ADTPro/adtpro>
- [CC65](https://github.com/cc65), a modern cross-compiling C compiler and assembler for 6502 systems. <https://github.com/cc65>
- [PLASMA: The Proto-Language Assembler for All](https://github.com/dschmenk/PLASMA) --- this was originally written for the Apple II alone, but has recently expanded to other systems. <https://github.com/dschmenk/PLASMA>

View File

@ -1,59 +0,0 @@
# Quick Reference: Macros
## Disk 1: MAC.REQUIRED
| MACRO | DEPEND | PARAMETERS | RETURNS |
| --- | --- | --- | --- |
| `_AXLIT` | none | ]1 = memory address | .A = address low byte<br />.X = address high byte |
| `_AXSTR` | `_AXLIT` | ]1 = memory address | .A = address low byte<br />.X = address high byte |
| `_ISLIT` | none | ]1 = memory address | .A = address low byte<br />.X = address high byte |
| `_ISSTR` | `_ISLIT` | ]1 = memory address | .A = address low byte<br />.X = address high byte |
| `_MLIT` | none | ]1 = memory address<br />]2 = destination ZP address | .A = address low byte <br />.X = address high byte |
| `_MSTR` | `_ISLIT` | ]1 = memory address<br />]2 = destination ZP address | .A address low byte <br />.X = address high byte |
| `_PRN` | `__P` | ]1 = string to print | none |
| `_WAIT` | `__w` | ]1 = none | .A = keypress value |
| `BCCL` | x | x | x |
| `BCSL` | x | x | x |
| `BEQL` | x | x | x |
| `BMIL` | x | x | x |
| `BNEL` | x | x | x |
| `BPLL` | X | x | x |
| `BVCL` | x | x | x |
| `BVSL` | x | x | x |
| `CLRLO` | `__CLRLO` | ]1 = byte to clear high nibble of | .A = cleared byte |
| `CLRHI` | `__CLRHI` | ]1 = byte to clear the high nibble of | .A = cleared byte |
| `CPHX` | x | x | x |
| `CPHY` | x | x | x |
| `CPLX` | x | x | x |
| `CPLY` | x | x | x |
| `CSTZ` | x | x | x |
| `DUMP` | `_AXLIT`;<br />`__DUMP` | ]1 = memory address<br />]2 = number of bytes to dump | .A = number of bytes displayed |
| `ERRH` | `_AXLIT`;<br />`__ERRH` | ]1 = memory address | none |
| `GRET` | `_AXLIT`;<br />`__GETRET` | ]1 = destination address | .A = return value length |
| `PEEK` | x | x | x |
| `POKE` | x | x | x |
| `TXY` | x | x | x |
| `TYX` | x | x | x |
| `ZPC` | x | x | x |

View File

@ -1,46 +0,0 @@
# AppleIIAsm Library { - }
## Technical Reference Manual { - }
### Version 0.5.1 { - }
by Nathan Riggs
Apache 2.0 License
---
# TABLE OF CONTENTS { - }
- Preface
- Introduction
- PART I
- Package Overview
- Standard Practices / Procedures
- Naming Conventions
- Commenting Conventions
- Parameter Passing
- Main Source Sequencing
- Quick Reference: Macros
- Quick Reference: Subroutines
- PART II
- Detailed Descriptions and Listings
- Library Disks
- Disk 1: REQCOM (Required & Common Libraries)
- Required Library
- HEAD.REQUIRED
- MAC.REQUIRED
- LIB.REQUIRED
- Common Library
- HOOKS.COMMON
- MAC.COMMON
- DEMO.COMMON
## Appendix A: Companion Books { - }
- The New Merlin 8 Pro User Guide
- Learning 6502 Assembly with AppleIIAsmLib and AppleChop
- Forever Machine: The Past and Future on the Apple II Platform

View File

@ -1,377 +0,0 @@
/* ---------------------------------------------------
Various settings to display madoko elements correctly.
For example, lines in tables or a table of contents.
All rules use specific madoko classes and never just
a generic element. This means one can safely include
this CSS into any web page without affecting non-madoko
content.
----------------------------------------------------*/
/* The table of contents */
.madoko .toc>.tocblock .tocblock .tocblock {
margin-left: 2.25em;
}
.madoko .toc>.tocblock .tocblock {
margin-left: 1.5em;
}
.madoko .toc-contents>.tocblock>.tocitem {
font-weight: bold;
}
.madoko .toc {
margin-top: 1em;
}
/* Paragraphs */
.madoko p.para-continue {
margin-bottom: 0pt;
}
.madoko .para-block+p {
margin-top: 0pt;
}
.madoko ul.para-block, .madoko ol.para-block {
margin-top: 0pt;
margin-bottom: 0pt;
}
.madoko ul.para-end, .madoko ol.para-end {
margin-bottom: 1em;
}
.madoko dl {
margin-left: 0em;
}
.madoko blockquote {
font-style: italic;
}
/* Local page links do not get an underline unless hovering */
.madoko a.localref {
text-decoration: none;
}
.madoko a.localref:hover {
text-decoration: underline;
}
/* Footnotes */
.madoko .footnotes {
font-size: smaller;
margin-top: 2em;
}
.madoko .footnotes hr {
width: 50%;
text-align: left;
}
.madoko .footnote {
margin-left: 1em;
}
.madoko .footnote-before {
margin-left: -1em;
width: 1em;
display: inline-block;
}
/* Alignment */
.madoko .align-center, .madoko .align-center>p {
text-align: center !important;
}
.madoko .align-center pre {
text-align: left;
}
.madoko .align-center>* {
margin-left: auto !important;
margin-right: auto !important;
}
.madoko .align-left, .madoko .align-left>p {
text-align: left !important;
}
.madoko .align-left>* {
margin-left: 0pt !important;
margin-right: auto !important;
}
.madoko .align-right, .madoko .align-right>p {
text-align: right !important;
}
.madoko .align-right>* {
margin-left: auto !important;
margin-right: 0pt !important;
}
.madoko .align-center>table,
.madoko .align-left>table,
.madoko .align-right>table {
text-align: left !important;
}
/* Equations, Figure's etc. */
.madoko .equation-before {
float: right;
}
/* Bibliography */
.madoko .bibitem {
font-size: smaller;
}
.madoko .bibsearch {
font-size: x-small;
text-decoration:none;
color: black;
font-family: "Segoe UI Symbol", Symbola, serif;
}
/* General */
.madoko .block, .madoko .figure, .madoko .bibitem, .madoko .equation, .madoko div.math {
margin-top: 1ex;
margin-bottom: 1ex;
}
.madoko .figure {
padding: 0.5em;
margin-left: 0pt;
margin-right: 0pt;
}
.madoko .hidden {
display: none;
}
.madoko .invisible {
visibility: hidden;
}
.madoko.preview .invisible {
visibility: visible;
opacity: 0.5;
}
.madoko code.code, .madoko span.code {
white-space: pre-wrap;
}
.madoko hr, hr.madoko {
border: none;
border-bottom: black solid 1px;
margin-bottom: 0.5ex;
}
.madoko .framed>*:first-child {
margin-top: 0pt;
}
.madoko .framed>*:last-child {
margin-bottom: 0pt;
}
/* Lists */
.madoko ul.list-style-type-dash {
list-style-type: none !important;
}
.madoko ul.list-style-type-dash > li:before {
content: "\2013";
position: absolute;
margin-left: -1em;
}
/* Tables */
.madoko table.madoko {
border-collapse: collapse;
}
.madoko td, .madoko th {
padding: 0ex 0.5ex;
margin: 0pt;
vertical-align: top;
}
.madoko .cell-border-left {
border-left: 1px solid black;
}
.madoko .cell-border-right {
border-right: 1px solid black;
}
.madoko thead>tr:first-child>.cell-line,
.madoko tbody:first-child>tr:first-child>.cell-line {
border-top: 1px solid black;
border-bottom: none;
}
.madoko .cell-line, .madoko .cell-double-line {
border-bottom: 1px solid black;
border-top: none;
}
.madoko .cell-double-line {
border-top: 1px solid black;
padding-top: 1.5px !important;
}
/* Math Pre */
.madoko .input-mathpre .MathJax_Display {
text-align: left !important;
}
.madoko div.input-mathpre {
text-align: left;
margin-top: 1.5ex;
margin-bottom: 1ex;
}
.madoko .math-rendering {
text-align: left;
white-space: pre;
color: gray;
}
.madoko .mathdisplay {
text-align: center;
}
/*---------------------------------------------------------------------------
Default style for syntax highlighting
---------------------------------------------------------------------------*/
.madoko .pretty table {
border-collapse: collapse;
}
.madoko .pretty td {
padding: 0em;
}
.madoko .pretty td.empty {
min-width: 1.5ex;
}
.madoko .pretty td.expander {
width: 100em;
}
/* ---------------------------------------------------
Styling for full documents
----------------------------------------------------*/
body.madoko, .madoko .serif {
font-family: Cambria,"Times New Roman","Liberation Serif","Times",serif;
}
.madoko .sans-serif {
font-family: "Calibri", "Optima", sans-serif;
}
.madoko .symbol {
font-family: "Segoe UI Symbol", Symbola, serif;
}
body.madoko {
-webkit-text-size-adjust: 100%; /* so math displays well on mobile devices */
text-rendering: optimizeLegibility;
}
body.madoko {
max-width: 88ex; /* about 88 characters */
margin: 1em auto;
padding: 0em 2em;
}
body.preview.madoko {
padding: 0em 1em;
}
.madoko p {
text-align: justify;
}
/* style headings nicer, especially h5 and h6 */
.madoko h1, .madoko h2, .madoko h3, .madoko h4 {
margin-top: 1.22em;
margin-bottom: 1ex;
}
.madoko h1+p, .madoko h2+p, .madoko h3+p, .madoko h4+p, .madoko h5+p {
margin-top: 1ex;
}
.madoko h5, .madoko h6 {
margin-top: 1ex;
font-size: 1em;
}
.madoko h5 {
margin-bottom: 0.5ex;
}
.madoko h5 + p {
margin-top: 0.5ex;
}
.madoko h6 {
margin-bottom: 0pt;
}
.madoko h6 + p {
margin-top: 0pt;
}
/* Fix monospace display (see http://code.stephenmorley.org/html-and-css/fixing-browsers-broken-monospace-font-handling/) */
.madoko pre, .madoko code, .madoko kbd, .madoko samp, .madoko tt,
.madoko .monospace, .madoko .token-indent, .madoko .reveal pre, .madoko .reveal code, .madoko .email {
font-family: Consolas,"Andale Mono WT","Andale Mono",Lucida Console,Monaco,monospace,monospace;
font-size: 0.85em;
}
.madoko pre code, .madoko .token-indent {
font-size: 0.95em;
}
.madoko pre code {
font-family: inherit !important;
}
/* Code prettify */
.madoko ol.linenums li {
background-color: white;
list-style-type: decimal;
}
/* Merging */
.madoko .remote {
background-color: #F0FFF0;
}
.madoko .remote + * {
margin-top: 0pt;
}
/* ---------------------------------------------------
Print settings
----------------------------------------------------*/
@media print {
body.madoko {
font-size: 10pt;
}
@page {
margin: 1in 1.5in;
}
}
/* ---------------------------------------------------
Mobile device settings
----------------------------------------------------*/
@media only screen and (max-device-width:1024px) {
body.madoko {
padding: 0em 0.5em;
}
.madoko li {
text-align: left;
}
}

View File

@ -1,652 +0,0 @@
Package : [heading-base={&heading-base;},section-num={&tex-section-num;},bib-label={&bib-label;},fontspec={&font-spec;}]madoko2
Logo : False
Tex2 : True
Maketitle : False
Heading Depth : 3
Toc Depth : 3
Heading Base : 2
Tex Section Num : False
Bib Label : True
Math Mode : static
Font Spec : True
Title Running :
Author Running :
Bib Search Url :
Csl Style :
<!-- standard elements -->
Article { html-elem:article }
Section { html-elem:section }
Aside { html-elem:aside }
Nav,.Toc { html-elem:nav }
.Framed { border: solid black 1px }
Center { .align-center }
Remote { tight:true; margin-bottom: 0pt }
Pre { input: pre; .para-block; display:block }
Code { input: pre }
Hr { .madoko }
Table { .madoko }
Dd { html-elem: dd; margin-left: 1.5em }
Dt { html-elem: dt; font-weight: bold }
FlushLeft { .align-left }
FlushRight { .align-right }
Comment { display: none }
Snippet { input: math; display:block; math-full: true }
Footnote { label: "[@footnote]{.footnote-label}"; line-adjust: 0 }
@if html {
Footnote {
before: "[\/^&label;.^]{.footnote-before}";
after : "&nl;&&;null;[&#8617;](#back-&id;){.footnote-backref}";
}
}
@if html && (not full) {
math svg share paths: false
.body.madoko { tag: false; }
}
<!-- lists -->
.Ul-Li { @ul-li; label: "[(@ul-li)]{.ul-li-label}" }
.Ol-Li { @ol-li; label: "[(@ol-li)]{.ol-li-label}" }
.Dl-Li { @dl-li; label: "[(@dl-li)]{.dl-li-label}" }
Ol { @ol-li: decimal }
Ul { @ul-li: decimal }
Dl { @dl-li: decimal }
.li-label { display: inline-block; width: 2.5em; margin-left: -3em; margin-right: 0.5em; text-align: right }
<!-- special input -->
.TexRaw { input: texraw }
.HtmlRaw { input: htmlraw }
.MathInline { input: math }
MathDisplay { input: math; .para-block }
MathPre { input: mathpre; .para-block }
MathDefs { input: mathdefs; }
HtmlOnly { input: htmlonly; tag: false }
Tex { input: tex; tag: false }
TexOnly { input: texonly; tag: false }
Bib { input: tex }
math-inline { input: math }
math-display { input: math }
.hidden { display: none }
.noindent { text-indent: 0em }
.align-center { text-align: center }
.texturl { .monospace }
.booktable {
rule-top-width : 2px;
rule-bottom-width : 2px
rule-mid-width : 1.35px;
thead-tr-font-weight : normal;
rule-top-sep : 4pt;
rule-bottom-sep : 4pt;
rule-mid-sep : 3pt;
thead-tr-1-padding-top : 3pt;
thead-tr-padding-bottom : 3pt;
}
<!-- heading elements -->
h0 { label: "[@h0]{.heading-label}"; @h0:upper-roman }
h1 { label: "[@h1]{.heading-label}" }
h2 { @h1-h2; label: "[@h1.@h1-h2]{.heading-label}" }
h3 { @h1-h2-h3; label: "[@h1.@h1-h2.@h1-h2-h3]{.heading-label}" }
h4 { @h1-h2-h3-h4; label: "[@h1.@h1-h2.@h1-h2-h3.@h1-h2-h3-h4]{.heading-label}" }
heading-endperiod: .
heading-format : &label;&heading-endperiod;&ensp;
@if heading-depth>=1 {
h1 { before: "[&heading-format;]{.heading-before}" }
}
@if heading-depth>=2 {
h2 { before: "[&heading-format;]{.heading-before}" }
}
@if heading-depth>=3 {
h3 { before: "[&heading-format;]{.heading-before}" }
}
@if heading-depth>=4 {
h4 { before: "[&heading-format;]{.heading-before}" }
}
@if toc-depth>=0 {
h0 { toc; toc-depth:1 }
}
@if toc-depth>=1 {
h1 { toc }
}
@if toc-depth>=2 {
h2 { toc }
}
@if toc-depth>=3 {
h3 { toc }
}
@if toc-depth>=4 {
h4 { toc }
}
h1,h2,h3,h4 {
toc-line: "&heading-format;&source;";
}
.tocblock,.tocitem { tight:true }
<!-- entities -->
Defaults : True
lowline : &#x5F;
qed : [&box;]{float: right}
vfill : \/
@if tex {
vfill : [\vfill{}]{input: texraw}
lowline : &#0818;
qed : [\qed{}]{input: texraw}
}
eg : e.g.
ie : i.e.
etal : et al.
LogoLatex : $\mbox{\LaTeX}$
LogoTex : $\mbox{\TeX}$
LogoLatexe : $\mbox{\LaTeXe}$
LogoBibtex : $\mbox{\sc{Bib}\TeX}$
LogoAmstex : $\mbox{\AmSTeX}$
LogoMadoko : Created with [Madoko.net](https://www.madoko.net).
.LogoMadoko { display:block; text-align: right; font-size: xx-small; margin-top: 4em; tight: true }
smallskip : []{display: block; margin-bottom: 0.5em }
medskip : []{display: block; margin-bottom: 1em }
bigskip : []{display: block; margin-bottom: 2em }
@if tex {
smallskip : [\smallskip]{input:texraw}
medskip : [\medskip]{input:texraw}
bigskip : [\bigskip]{input:texraw}
}
<!-- notes -->
note-endperiod : &heading-endperiod;
note-format : **[&caption;]{.note-caption}**&note-endperiod;&nl;
.Note { display: block; before: "[&note-format;]{.note-before}"; caption:"&name-note;" }
.Remark { .Note; caption: "&name-remark;" }
.Todo { .Note; caption: "&name-todo;" }
<!-- equations and math -->
Equation {
label: "[(@equation)]{.equation-label}";
replace: '[&label;]{.equation-before}&nl;~ Begin MathDisplay { color: "&color;"; math-full: "&math-full;"; line-adjust:0}&nl;&source;&nl;~ End MathDisplay&nl;';
tight: true;
line-adjust: 0;
.para-block;
tex-label-before: "&id;";
}
Math {
replace: '~ Begin MathDisplay { color:"&color;"; math-full:"&math-full;"; line-adjust:0}&nl;&source;&nl;~ End MathDisplay&nl;';
tight: true;
.para-block
}
MathPreCenter {
tex-env:mdmathprecenter;
text-align:center;
}
theorem-caption-end : &&;br;
theorem-caption-format: ([&source;]{font-style:italic})
.theorem-caption { replace: '@if source != "" @then "&theorem-caption-format;"' }
theorem-caption : [&caption;]{.theorem-caption}&theorem-caption-end;
theorem-endperiod : &heading-endperiod;
theorem-format : **&name-theorem;\ &label;&theorem-endperiod;** &theorem-caption;
lemma-format : **&name-lemma;\ &label;&theorem-endperiod;** &theorem-caption;
proposition-format : **&name-proposition;\ &label;&theorem-endperiod;** &theorem-caption;
corollary-format : **&name-corollary;\ &label;&theorem-endperiod;** &theorem-caption;
example-format : **&name-example;\ &label;&theorem-endperiod;** &theorem-caption;
definition-format : **&name-definition;\ &label;&theorem-endperiod;** &theorem-caption;
proof-format : **&name-proof;**&theorem-endperiod; &theorem-caption;
Theorem {
label: '[@theorem]{.theorem-label}';
before: '[&theorem-format;]{.theorem-before}';
}
Lemma {
label: '[@lemma]{.lemma-label}';
before: '[&lemma-format;]{.lemma-before}'
}
Proof {
before: "[&proof-format;]{.proof-before}";
theorem-caption-end: " "
}
Proposition {
label: '[@proposition]{.proposition-label}';
before: '[&proposition-format;]{.proposition-before}';
}
Corollary {
label: '[@corollary]{.corollary-label}';
before: '[&corollary-format;]{.corollary-before}';
}
Example {
label: '[@example]{.example-label}';
before: '[&example-format;]{.example-before}';
}
Definition {
label: '[@definition]{.definition-label}';
before: '[&definition-format;]{.definition-before}';
}
Theorem,Lemma,Proof,Corollary,Proposition,Example,Definition {
display: block;
margin: 1ex 0pt;
}
<!-- figures -->
TableFigure {
label: '[@tablefigure]{.table-label}';
toc:"tables"; .floating ; float-env: table; float-name: "&name-table;";
}
Figure {
label: '[@figure]{.figure-label}';
toc:"figures"; .floating ; float-env: figure; float-name: "&name-figure;";
}
WrapFigure {
label: '[@wrapfigure]{.wrapfigure-label}';
html-elem: figure;
.float;
float: right;
tex-float: outside;
width: 40%;
}
floating-endperiod: .
floating-format : **&float-name;\ &label;&floating-endperiod;**&nbsp;
.Floating {
.align-center;
.float;
elem : floating;
html-elem : figure;
toc-line : '&label;. &caption;';
after: '&nl;********* {.figureline}&nl;[[&floating-format;]{.caption-before}[&caption;]{.caption-text}]{.figure-caption; html-elem:fig-caption}&nl;{tag:false}&nl;';
}
SubFigureRow { .columns; .align-center }
SubFigure {
@Figure-SubFigure;
@Figure-SubFigure: lower-alpha;
label : '@Figure@Figure-SubFigure';
fig-label : '(@Figure-SubFigure)';
caption : '';
after : "&nl;~ Begin SubFigureCaption&nl;&toc-line;&nl;~End SubFigureCaption&nl;";
vertical-align: bottom;
padding : 0.5ex;
tight : true;
text-align: center;
.column;
toc-line : '[&fig-label; ]{.caption-before} &caption;';
toc : "figures";
toc-depth : 2;
}
SubFigureCaption {
tight: true;
margin-top: 1ex;
}
toc.toc-contents { before: "# &name-contents; { -; toc:clear; .heading-contents }&nl;" }
toc.toc-figures { before: "# &name-figures; { -; toc:clear; .heading-figures }&nl;" }
toc.toc-tables { before: "# &name-tables; { -; toc:clear; .heading-tables }&nl;" }
<!-------------------------------------------------------------------
Bibliography
--------------------------------------------------------------------->
Bibl {
@bib;
}
.bibitem-label {
display: none;
}
Bibitem {
@bib-bibitem;
label : '@bib-bibitem';
cite-label: '&label;';
bibitem-label: '';
tight : true;
replace : '@if (bib-search-url!="") and (searchterm!="") @then "&source; [&mglass;](http://&bib-search-url;/search?q=&searchterm;){.bibsearch}"';
}
@if not (tex) {
Bib Search Url: www.bing.com
Bibl { before: "# &name-references; { -; .heading-references }&nl;" }
}
@if not(tex) or (csl-style!="False") {
Bibitem { before: '[&bibitem-label;]{.bibitem-before}' }
}
@if not(tex) and (csl-style=="False") {
Bibitem { bibitem-label:"[&cite-label;]" }
}
@if tex and (csl-style!="False") {
Bib Label: hide
.bibitem-before { tex-cmd:\mdbibitemlabel }
}
@if tex {
bibliography { #sec-bibliography; toc; toc-line: "&name-references;"; tex-label-inner-before:"&id;" }
}
<!-------------------------------------------------------------------
Bibliography styling in HTML
--------------------------------------------------------------------->
Html Bib Label Width: 2rem
@if html and not(cite-style~~/^(numeric|super|False)\b/i) {
.bibitem-before {
display: none;
}
bibitem {
text-indent: -1em;
margin-left: 1em;
}
}
@if html and (cite-style~~/^(numeric|super|False)\b/i) {
.bibitem-before {
padding-right: 0.5em;
width : calc(&html-bib-label-width; - 0.5em);
text-align : right;
font-size : 90%;
}
bibitem {
text-indent: -&html-bib-label-width;;
margin-left: &html-bib-label-width;;
}
}
@if html {
.bib-doi { font-size: smaller; }
}
<!-------------------------------------------------------------------
Internationalization
--------------------------------------------------------------------->
name-references : References
name-contents : Contents
name-figures : Figures
name-tables : Tables
name-abstract : Abstract
name-figure : Figure
name-table : Table
name-note : Note
name-remark : Remark
name-todo : Todo
name-theorem : Theorem
name-lemma : Lemma
name-proof : Proof
name-proposition : Proposition
name-corollary : Corollary
name-example : Example
name-definition : Definition
seealso : see also
sseealso : See also
<!-- names to support babel bibliographies generated by `custom-bib` (with the `merlin.mbs` package) -->
name-and : and
name-etal : et\ al
name-editors : editors
name-eds : eds.
name-editor : editor
name-ed : ed.
name-edby : edited by
name-edition : edition
name-edn : edn.
name-volume : volume
name-vol : vol.
name-of : of
name-number : number
name-no : no.
name-in : in
name-pages : pages
name-pp : pp.
name-page : page
name-p : p.
name-chapter : chapter
name-chap : chap.
name-techreport : Technical Report
name-techrep : Tech. Rep.
name-mthesis : Master's thesis
name-phdthesis : Ph.D. thesis
name-first : first
name-firsto : 1st
name-second : second
name-secondo : 2nd
name-third : third
name-thirdo : 3rd
name-fourth : fourth
name-fourtho : 4th
name-fifth : fifth
name-fiftho : 5th
name-st : st
name-nd : nd
name-rd : rd
name-th : th
name-jan : January
name-feb : February
name-mar : March
name-apr : April
name-may : May
name-jun : June
name-jul : July
name-aug : August
name-sep : September
name-oct : October
name-nov : November
name-dec : December
name-ins : in
name-inj : in
<!-------------------------------------------------------------------
Syntax highlighting
--------------------------------------------------------------------->
.token.keyword { color: blue }
.token.string.escape { color: gray }
.token.comment { color: darkgreen }
.token.constant { color: purple }
.token.constructor { color: purple }
.token.type { color: teal }
.token.type.delimiter { color: teal }
.token.special { color: navy }
.token.doc { color: gray }
.token.meta { color: gray }
.token.tag { color: navy }
.token.attribute { color: purple }
.token.namespace { color: navy }
.token.title { font-weight: bold }
.token.string,.token.regexp { color: maroon }
.token.error,.token.invalid { color: red }
.token.number, .token.literal { .constant }
.token.emphasis,.token.italic { font-style: italic }
.token.strong,.token.bold { font-weight: bold }
pre.pretty, code.pretty { .serif }
.ptoken.identifier { font-style: italic }
.ptoken.constructor { font-style: italic }
.ptoken.operator { tex-cmd: "\ppreop" }
.ptoken.comment { color: gray }
.ptoken.keyword { .sans-serif }
@if not tex {
pre.pretty, code.pretty { font-size: 100% }
}
@if tex {
.token.keyword { color: navy }
}
<!-------------------------------------------------------------------
HTML commands
--------------------------------------------------------------------->
@if html {
abstract {
before:"**&name-abstract;.** ";
margin-left: 3em;
margin-right: 3em;
font-size: small;
}
}
<!-------------------------------------------------------------------
Tex commands
--------------------------------------------------------------------->
HR { tex-cmd: "\mdhr"; display: block }
Pre { tex-env-outer: mdpre }
Pre.pretty { tex-env-outer-postfix: pretty }
Abstract { tex-env: abstract }
H0,H1,H2,H3,H4,H5,H6 { display: block; }
H0.clearnum,H1.clearnum,H2.clearnum,H3.clearnum,H4.clearnum,H5.clearnum,H6.clearnum {
tex-cmd-postfix:"*";
toc-line: "&source;";
}
@if heading-base<=0 {
H0 { tex-cmd:"\part" }
H1 { tex-cmd:"\part" }
H2 { tex-cmd:"\chapter" }
H3 { tex-cmd:"\section" }
H4 { tex-cmd:"\subsection" }
H5 { tex-cmd:"\subsubsection" }
H6 { tex-cmd:"\paragraph" }
}
@if heading-base==1 {
H0 { tex-cmd:"\part" }
H1 { tex-cmd:"\chapter" }
H2 { tex-cmd:"\section" }
H3 { tex-cmd:"\subsection" }
H4 { tex-cmd:"\subsubsection" }
H5,H6 { tex-cmd:"\paragraph" }
}
@if heading-base==2 {
H0 { tex-cmd:"\chapter" }
H1 { tex-cmd:"\section" }
H2 { tex-cmd:"\subsection" }
H3 { tex-cmd:"\subsubsection" }
H4,H5,H6 { tex-cmd:"\paragraph" }
}
@if heading-base>=3 {
H0 { tex-cmd:"\section" }
H1 { tex-cmd:"\subsection" }
H2 { tex-cmd:"\subsubsection" }
H3,H4,H5,H6 { tex-cmd:"\paragraph" }
}
Figure { tex-env-outer: "figure[&tex-float-placement;]"; tex-float-placement: "tbp" }
TableFigure { tex-env-outer: "table[&tex-float-placement;]"; tex-float-placement: "tbp" }
.figure-caption { tex-cmd: "\mdcaption" }
.caption-text { tex-cmd: "\mdcaptiontext" }
.wide { tex-env-outer-postfix: "*" }
.figure-label { tex-cmd: "\mdcaptionlabel" }
.table-label { tex-cmd: "\mdcaptionlabel" }
Li { tex-cmd-before: "\item" }
Ul { tex-env: "itemize" }
Ol { tex-env: "enumerate" }
Dl { tex-env: "mddefinitions" }
Dt { tex-cmd: "\mddefterm"; .noindent }
Dd { tex-env: "mddefdata" }
Code { tex-cmd: "\mdcode" }
Strong { tex-cmd: "\textbf" }
Em { tex-cmd: "\emph" }
Sup { tex-cmd: "\mdsup" }
Sub { tex-cmd: "\mdsub" }
Del { tex-cmd: "\mddel" }
BlockQuote{ tex-env: "quote" }
.Columns { tex-tabcolsep: "0pt" }
.Column { tex-env-outer: "mdcolumn" }
.inst { tex-cmd: "\mdinst" }
.equation-before { tex-cmd: "\mdmathtag" }
Bibliography { tex-env: "thebibliography{&caption;}"; tex-cmd-after: "\par"; tex-cmd-outer-before: "\mdsetrefname{&name-references;}%mdk&nl;" }
BibItem { tex-cmd-before:"\bibitem&tex-bibitem-args;"; tex-bibitem-args:"&tex-bibitem-label;{&id;}"; tex-bibitem-label:"" }
.Newblock { tex-cmd-before="\newblock " }
toc { tex-env:mdtoc }
tocblock { tex-env:mdtocblock }
tocitem { tex-cmd:"\mdtocitemx{&data-toc-target;}" }
bibliography { data-hanging-indent:0 }
bibliography { tex-cmd-outer: "{\mdbibindent{&data-hanging-indent;}%mdk&nl;" }
bibliography.bib-natural, bibliography.bib-textual {
tex-cmd-outer: "{\mdsupressbiblabel\mdbibindent{&data-hanging-indent;}";
}
@if tex2 {
Th { font-weight: "bold" }
}
@if tex and tex-section-num {
.heading-before { display: none }
}
<!-- tex author block -->
TitleBlock,TitleHeader,Title,Subtitle { tight: true }
TitleNote,TitleFooter,Authors,AuthorRow,Author { tight: true }
AuthorName,AuthorAddress,AuthorEmail,AuthorNote { tight: true }
@if tex {
Maketitle: True
.serif { font-family: serif; }
.sans-serif { font-family: sans-serif }
.monospace { font-family: monospace }
}
@if Maketitle {
Author { display: inline-block }
TitleBlock { display: inline-block;
tex-cmd-inner-after: "\mdtitleauthorrunning{&title-running;}{&author-running;}";
}
TitleHeader,Authors,AuthorRow { tag: false }
Author { tex-cmd-before:"\mdxauthorstart"; tex-cmd-after:"\mdxauthorend"; display:table-cell }
TitleBlock { tex-cmd-before:"\mdxtitleblockstart"; tex-cmd-after:"\mdxtitleblockend"; display:block }
Title { tex-cmd:"\mdxtitle" }
Subtitle { tex-cmd:"\mdxsubtitle" }
TitleNote { tex-cmd:"\mdxtitlenote" }
TitleFooter { tex-cmd:"\mdxtitlefooter" }
AuthorName { tex-cmd:"\mdxauthorname" }
AuthorAddress { tex-cmd:"\mdxauthoraddress" }
AuthorNote { tex-cmd:"\mdxauthornote" }
AuthorEmail { tex-cmd:"\mdxauthoremail" }
}
@if not Maketitle {
TitleBlock,TitleHeader,Authors,TitleFooter { .align-center }
TitleBlock,Title,Subtitle,TitleNote { .para-block }
Authors { width: 80% }
AuthorRow { .columns; margin-top: 2ex; width: 100% }
Author { .column; text-align: center }
.AuthorEmail { .email }
Title { font-size: xx-large; font-weight: bold; margin-bottom: 0.5ex }
Subtitle { font-size: x-large; margin-bottom: 0.5ex }
AuthorName { font-size: large }
TitleFooter { margin-top: 0.5ex }
}

View File

@ -26,6 +26,8 @@ Written and edited by Nathan Riggs (so far), 2020.
---
### License
Copyright 2020 Nathan Riggs
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
@ -59,16 +61,17 @@ limitations under the License.
## Table of Contents
1. [License](0_1_License.md)
2. [Preface](1_Preface.md)
3. [Introduction](1_5_Introduction.md)
4. [Package Overiew](2_Package_Overview.md)
5. [Software Architecture](2_5_Software_Architecture.md)
6. Macro/Subroutine Quick References
- [Disk 1 -- REQUIRED Macros and Subroutines](3_Quick_Reference_D1_REQUIRED.md)
- Disk 2 --
1. [License](#license)
2. [Preface](1.0 Preface.md)
3. [Introduction](2.0 Introduction.md)
4. [Package Overiew](3.0 Package_Overview.md)
5. [Software Architecture](4.0 Software_Architecture.md)
6. [Macro/Subroutine Quick References](5.0 Quick_Reference_TOC.md)
7. - [Quick Reference Introduction](5.0 Quick_Reference_TOC.md)
- [Disk 1 -- REQUIRED Macros and Subroutines](6.0 Quick_Reference_D1_MACREQUIRED.md)
- [Disk 2 -- STDIO Macros and Subroutines](7.0 Quick_Reference_D2_MACSTDIO.md)
7. Detailed References and Source Code Listings
- [Disk 1: Required Library and Aliases](30_Detailed_Reference_D1_REQUIRED.md)
- [Disk 1: Required Library and Aliases](30.0 Detailed_Reference_D1_REQUIRED.md)
8. Appendices
- Supplemental Texts
- Further Reference

View File

@ -0,0 +1,27 @@
## Preface
This is the first complete reference manual for the _AppleIIAsm_ macro and subroutine library collection. Currently, this collection is in the alpha stages of development: not all disks are complete, there may be some bugs here and there, and major workflow decisions might still be in flux. However, this version, 0.7.0, represents a major step forward in functionality, optimization and standardization, and at least for what is complete---the first eleven disks, the technical manual, AppleChop introduction as well as some demos---the collection can be reasonably considered to be stable. That does not, of course, mean that there are any guarantees.
I started this project as research into how the Apple II works as a platform for another book I am writing, and eventually became interested in the cohesive technical documentation (or sometimes lack thereof) that was available to beginning coders in the heyday of the Apple II as well as those looking to learn Apple II (6502) Assembly today. Having no prior experience with Assembly language, I began coding these libraries as part of my own learning process while trying to write subroutines that provided much of the functionality afforded by Applesoft BASIC. Eventually, this became a beast of its own, and what youre reading here is (part) of the result.
As the libraries grow and morph, so will this document. If nothing else, I hope that the collection and its accompanying documentation helps hobbyists, researchers, and otherwise self-hating hopeless nerds learn and accomplish what they want or need---at least as much as it has helped, and harmed, me.
Nathan Riggs

View File

@ -1,42 +1,10 @@
## Preface
This is the first complete reference manual for the _AppleIIAsm_ macro and subroutine library collection. Currently, this collection is in the alpha stages of development: not all disks are complete, there may be some bugs here and there, and major workflow decisions might still be in flux. However, this version, 0.7.0, represents a major step forward in functionality, optimization and standardization, and at least for what is complete---the first eleven disks, the technical manual, AppleChop introduction as well as some demos---the collection can be reasonably considered to be stable. That does not, of course, mean that there are any guarantees.
I started this project as research into how the Apple II works as a platform for another book I am writing, and eventually became interested in the cohesive technical documentation (or sometimes lack thereof) that was available to beginning coders in the heyday of the Apple II as well as those looking to learn Apple II (6502) Assembly today. Having no prior experience with Assembly language, I began coding these libraries as part of my own learning process while trying to write subroutines that provided much of the functionality afforded by Applesoft BASIC. Eventually, this became a beast of its own, and what youre reading here is (part) of the result.
As the libraries grow and morph, so will this document. If nothing else, I hope that the collection and its accompanying documentation helps hobbyists, researchers, and otherwise self-hating hopeless nerds learn and accomplish what they want or need---at least as much as it has helped, and harmed, me.
Nathan Riggs
## Introduction
The AppleIIAsm Library Collection is an array of subroutines and macros for the Apple II line of computers, aimed at providing a stable set of assembly routines for most common tasks. Additionally, this library is meant to ease the transition between programming in Applesoft BASIC and 6502 Assembly by not only providing the basic data structures and functions found in higher-level languages but also by providing a set a macros—currently dubbed AppleChop—that simulates the design and workflow of BASIC. A companion booklet to this library, *From Applesoft to AppleChop and Assembly,* provides a framework for making that transition.
The AppleIIAsm Library Collection is an array of subroutines and macros for the Apple II line of computers, aimed at providing a stable set of assembly routines for most common tasks. Additionally, this library is meant to ease the transition between programming in Applesoft BASIC and 6502 Assembly by not only providing the basic data structures and functions found in higher-level languages but also by providing a set a macros—currently dubbed AppleChop—that simulates the design and workflow of BASIC. A companion booklet to this library, *From Applesoft to AppleChop to Assembly,* provides a framework for making that transition.
These subroutines and macros are written for the Merlin 8 Pro assembler, which should run on any Apple II with 64k of memory (programs assembled with Merlin 8 Pro will run on machines with less than 64k, however). Since we are using 6502 Assembly here, however, it should not be too difficult to port the subroutines to other assemblers and even other systems like the Commodore 64, Nintendo Entertainment System, BBC Micro, and more. For a guide on using the Merlin Pro 8 Assembler, see the other companion booklet, *The New Merlin Pro 8 User Guide*.
These subroutines and macros are written for the Merlin 8 Pro assembler, which should run on any Apple II with 64k of memory (programs assembled with Merlin 8 Pro will run on machines with less than 64k, however). Since we are using 6502 Assembly here, however, it should not be too difficult to port the subroutines to other assemblers and even other systems like the Commodore 64, Nintendo Entertainment System, BBC Micro, and more. For a guide on using the Merlin Pro 8 Assembler, see the other companion booklet, *The New Merlin Pro 8 Quick Start User Guide*.
It should be noted that the core libraries in this collection---those on disks one to eleven---should be compatible with every iteration of the Apple II family, from the original Apple II in 1977 to the Apple IIGS in 1986. Disks beyond that core collection are considered bonus disks, and are dedicated to either creating libraries for specialized hardware (such as much of the IIGS, or the Mockingboard) or are there to serve as more complicated and integrated demos for the user to peruse.

View File

@ -2,14 +2,16 @@
The **AppleIIAsm** package consists of 25 disks that contain thematically related subroutines, demos and utilities, as well as extra disks that hold minified versions of every subroutine for convenience. The contents of each disk and library are covered in Part II: Detailed Descriptions and Listings. The disks are ordered as follows:
- **Disk 0** BOOT (for setting up own environment)
### CORE LIBRARIES
- **Disk 1** REQCOM (Required and Common Libraries)
- **Disk 1** REQUIRED (Required and Common Libraries)
- **Disk 2** STDIO (Standard Input and Output Library)
- **Disk 3** ARRAYS (Array Library)
- **Disk 4** MATH (Math Library)
- **Disk 5** STRINGS (String Library)
- **Disk 6** FILEIO (DOS 3.3 File Input and Output Library)
- **Disk 6** DOSFILE (DOS 3.3 File Input and Output Library)
- **Disk 7** CONVERT (Data Type Conversion Library)
- **Disk 8** LORES (Low Resolution Graphics Library)
- **Disk 9** SPEAKER (Mono Speaker Library)
@ -31,8 +33,8 @@ The **AppleIIAsm** package consists of 25 disks that contain thematically relate
- **Disk 19** MOCKINGBOARD (Mockingboard Sound Card Library)
- **Disk 20** DBLLORES (Double Low Resolution Graphics Library)
- **Disk 21** DBLHIRES (Double High Resolution Graphics Lib)
- **Disk 22** //c Subroutines
- **Disk 23** IIe Subroutines
- **Disk 22** MISC (Miscellaneous subroutine library)
- **Disk 23** IIGS GS/OS 6.04 Library (3.5" diskette)
- **Disk 24** IIGSAUDIO (IIGS AUDIO library) (3.5" diskette)
- **Disk 25** IIGSGRAPHICS (IIGS Additional Graphics Mode Libraries) (3.5" diskette)

View File

@ -114,3 +114,6 @@ Beyond needing the core required library files as well as the hook files for the
While a number of helpful, higher-level control structures are included as part of the core required library, subroutines in the library itself should refrain from using this shorthand. Control Structure Macros are preceded with a '@' sign to signify their classification as such. Exceptions can be given to control structures that merely extend existing directives for better use, such as BEQW being used to branch beyond the normal byte limit; such macros forego the preceding @-sign.
**_ASM Suffix_**
The .ASM suffix on most files in the collection are mainly used for GitHub and modern operating systems to associate the dumped text version of the source with a filetype.

View File

@ -0,0 +1,5 @@
# Quick Reference: Macros
- [Disk 1: REQUIRED Library Macros](./6.0 Quick_Reference_D1_MAC.REQUIRED)
- [Disk 2: STDIO Library Macros](./7.0 Quick_Reference_D2_MAC.STDIO)
- [Disk 3: Arrays Library Macros](./8.0 Quick_Reference_D3_MAC.ARRAYS)

View File

@ -0,0 +1,113 @@
## Disk 1 Macros: The Required Library
Disk 1: REQUIRED contains three main macro files, unlike most disks which only contain a single macro file. They are as follows:
- [MAC.REQUIRED.ASM](#macrequiredasm)
- Contains all of the Macros required by the rest of the library collection. This must always be included in the main program. This also contains emulation macros for a select number of 65C02 instructions, if limited to a 6502 instruction set.
- [MAC.ALIAS.8080.ASM](#macalias8080asm)
- These are aliases for some instructions in the 8080 instruction set. Note that these may not work exactly like the 8080 versions, and are considered works-in-progress.
- [MAC.ALIAS.Z80.ASM](#macaliasz80asm)
- These are aliases for some instructions in the Z80 instruction set. Like with the previous alias file, these are works-in-progress.
Be sure to consult the detailed reference for Disk 1: The Required Library for further explanation of how the macros work, their source code, and an explanation of the source code of any subroutines the macros may rely upon.
### MAC.REQUIRED.ASM
| MACRO | DEPENDENCY | PARAMETERS | ACTION | DESTROYS | CYCLES | BYTES |
| --- | --- | --- | --- | --- | --- | --- |
| `_AXLIT` | none | **\]1** = memory address | Determine if address sent is direct or indirect and parse accordingly in registers.<br /><br /> **.A** = address low byte<br />**.X** = address high byte |NZ|8|6|
| `_AXSTR` | `_AXLIT` | **\]1** = memory address | Determine if literal string or address is sent and parse accordingly.<br /><br />.**A** = address low byte<br />.**X** = address high byte |NZ|11|9+|
| `_ISLIT` | none | **\]1** = memory address | Determine if address sent is direct or indirect and parse accordingly onto the stack<br /><br />.**A** = address low byte<br />.**X** = address high byte |NZ|14|8|
| `_ISSTR` | `_ISLIT` | **\]1** = memory address | Determine if parameter is a literal string or address and parse address accordingly to the stack.<br /><br />.**A** = address low byte<br />.**X** = address high byte |NZ|13 or 8|10+ or 6|
| `_MLIT` | none | **\]1** = memory address<br />**\]2** = destination ZP address | Determine if address sent is direct or indirect and parse accordingly to zero page<br /><br />.**A** = address low byte <br />.**X** = address high byte |NZ|16|12|
| `_MSTR` | `_ISLIT` | **\]1** = memory address<br />**\]2** = destination ZP address | Determine if parameter passed is a literal string and parse address accordingly to the zero page<br /><br />.**A** address low byte <br />.**X** = address high byte |NZ|15 or 8|14+ or 6|
| `_PRN` | `__P` | **\]1** = string to print | Print a literal string to the screen. |NZCV|161+|9+|
| `_WAIT` | `__w` | none | Loop until a button is pressed.<br /><br />.**A** = keypress value |NZ|14+|10|
| `BEEP` | none | **\]1** = length of beep | Make beeping sound | NZC | 108+ | 15 |
| `BCCL` | none | **\]1** = address to jump to if true | Long Branch if Carry is Clear |none|7|8|
| `BCSL` | none | **\]1** = address to jump to if true | Long Branch if Carry is Set |none|7|8|
| `BEQL` | none | **\]1** = address to jump to if true | Long Branch if Equal |none|7|8|
| `BMIL` | none | **\]1** = address to jump to if true | Long Branch if Negative |none|7|8|
| `BNEL` | none | **\]1** = address to jump to if true | Loong Branch if Not Equal |none|7|8|
| `BPLL` | none | **\]1** = address to jump to if true | Long Branch if Positive |none|7|8|
| `BVCL` | none | **\]1** = address to jump to if true | Long Branch if Overflow Clear |none|7|8|
| `BVSL` | none | **\]1** = address to jump to if true | Long Branch if Overflow Set |none|7|8|
| `CBRA` | none | **\]1** = address to jump to if true | Long Branch Always (65C02 emulation) |none|4|4|
| `CPHX` | none | none | .**X** pushed to stack (65C02 Emulation) |NZ|11|6|
| `CPHY` | none | none | .**Y** pushed to stack (65C02 Emulation) |NZ|12|6|
| `CPLX` | none | none | top of stack in .**X** (65C02 Emulation) |NZ|11|6|
| `CPLY` | none | none | top of stack in .**Y** (65C02 Emulation) |NZ|11|7|
| `CTXY` | none | none | .**X** copied to .**Y** (65C02 Emulation) |NZ|10|6|
| `CTYX` | none | none | .**Y** copied to .**X** (65C02 Emulation) |NZ|10|6|
| `CLRHI` | none | none | high nibble of .**A** cleared | NZC | 10 | 6 |
| `DELAY` | `DELAYMS` | **\]1** = number of milliseconds (0..255) | Delay for a given number of milliseconds (byte) | NZC | 58+ |10|
| `DUMP` | `_AXLIT`;<br />`__DUMP` | **\]1** = memory address<br />**\]2** = number of bytes to dump | Dump a region of memory to the screen<br /><br />.**A** = number of bytes displayed |NZCV|811+|16|
| `ERRH` | `_AXLIT`;<br />`__ERRH` | **\]1** = memory address | sets handle for Applesoft Error Handling |NZC|73|7|
| `GBIT` | none | **\]1** = byte to check<br />**\]2** = bit mask | Get bit from .**A** at specified location in byte.<br /><br />.**A** = 0 or 1 | NZ | 14 | 15 |
| `GRET` | `_AXLIT`;<br />`__GETRET` | **\]1** = destination address | Get RETURN value and copy it to specified address.<br /><br />.**A** = return value length |NZC|43+|27|
| `PEEK` |`_AXLIT`| **\]1** = address to peek |Load an address value into .**A**.<br /><br />.**A** holds address value|NZC|28|18|
| `POKE` |`_AXLIT`|**\]1** = poke value<br />**\]2** = address to poke|load a value into given address.|NZC|32|20|
| `MFILL` | `_MLIT` <br />`MEMFILL` | **\]1** = starting address<br />**\]2** = length<br />**\]3** = fill value | Fill a block of memory with a single value. | none | NZ | 110+ |
| `MOVB` | `_MLIT`<br />`MEMMOVE` | **\]1** = source address<br />**\]2** = destination address <br />**\]3** = length in bytes | Move a block of memory at one address to another address. | NZCV | 267+ | 48 |
| `MSWAP` | `_MLIT`<br />`MEMSWAP` | **\]1** = first address<br />**\]2** = second address <br />**\]3** = length in bytes | Swap the values held in two different locks of memory. | NZC | 98+ | 36 |
### MAC.ALIAS.8080.ASM
| MACRO | DEPENDENCIES | PARAMETERS | ACTION | CYCLES | BYTE |
| ----- | ------------ | ---------- | ------ | ------ | ---- |
| `CALL` |none|label to `JSR` to| mimics `JSR` instruction | 6 | 3 |
|`RET`|none|none| mimics `RTS` instruction|6|1|
|`JA`|none|label to `JMP` to| `JMP` if .**A** > `CMP`|14|9|
|`JAE`|none|label to `JMP` to| `JMP` if .**A** >= `CMP`|8|4|
|`JB`|none|label to `JMP` to| `JMP` if .**A** < `CMP`|8|4|
|`JBE`|none|label to `JMP` to| `JMP` if .**A** <= `CMP`|1|6|
|`JC`|none|label to `JMP` to| `JMP` if .**C** = 1|8|4|
|`JE`|none|label to `JMP` to| `JMP` if **EQUAL**|8|4|
|`JG`|none|label to `JMP` to| `JA`|11|9|
|`JGE`|none|label to `JMP` to| `JAE`|8|4|
|`JL`|none|label to `JMP` to| `JB`|8|4|
|`JLE`|none|label to `JMP` to| `JBE`|11|6|
|`JNC`|none|label to `JMP` to| `JMP` if .**C** = 0|8|4|
|`JNE`|none|label to `JMP` to| `JMP` if **NOT EQUAL**|8|4|
|`JZ`|none|label to `JMP` to| `JMP` if .**Z** = 1|8|4|
|`JNZ`|none|label to `JMP` to| `JMP` if .**Z** = 0|8|4|
|`JS`|none|label to `JMP` to| `JMP` if **SIGNED**|8|4|
|`JNS`|none|label to `JMP` to| `JMP` if **NOT SIGNED**|8|4|
|`JO`|none|label to `JMP` to| `JMP` if **OVERFLOW** = 1|8|4|
|`JNO`|none|label to `JMP` to| `JMP` if **OVERFLOW** = 0|8|4|
|`ANC`|none|**\]1** = first addend<br />**\]2** = second addend| Add No Carry (ADD in 8080)|12|8|
|`SNC`|none|**\]1** = Minuend<br />**\]2** = Subtrahend| Subtract No Carry (SUB in 8080)|12|8|
|`PUSHA`|none|none| Push All Registers|30|14|
|`PULLA`|none|none| Pull All Registers|19|24|
|`POPA`|none|none| `PULLA`|19|24|
### MAC.ALIAS.Z80.ASM
| MACRO | DEPENDENCIES | PARAMETERS | ACTION | CYCLES | BYTE |
| ----- | ------------ | ---------- | ------ | ------ | ---- |
| `CALL` |none|label to `JSR` to| `JSR` equivalent | 6 | 3 |
|`CPL`|none|none| Invert bits in .**A**|2|2|
|`JP`|none|label to `JMP` to| `JMP` equivalent|5|1|
|`LD`|none|????| move value from source to destination (non-operational)|?|?|
|`POP`|none|none| `PLA` equivalent|4|1|
|`RET`|none|none| `RTS` equivalent|6|1|
|`SCF`|none|none| `SEC` equivalent|2|1|