mirror of
https://github.com/michaelcmartin/Ophis.git
synced 2024-11-18 11:06:07 +00:00
665 lines
7.2 KiB
HTML
665 lines
7.2 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
>Programming with Ophis</TITLE
|
|
><META
|
|
NAME="GENERATOR"
|
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
|
REL="NEXT"
|
|
TITLE="Preface"
|
|
HREF="f10.html"></HEAD
|
|
><BODY
|
|
CLASS="BOOK"
|
|
BGCOLOR="#FFFFFF"
|
|
TEXT="#000000"
|
|
LINK="#0000FF"
|
|
VLINK="#840084"
|
|
ALINK="#0000FF"
|
|
><DIV
|
|
CLASS="BOOK"
|
|
><A
|
|
NAME="AEN1"
|
|
></A
|
|
><DIV
|
|
CLASS="TITLEPAGE"
|
|
><H1
|
|
CLASS="TITLE"
|
|
><A
|
|
NAME="AEN2"
|
|
>Programming with Ophis</A
|
|
></H1
|
|
><H3
|
|
CLASS="AUTHOR"
|
|
><A
|
|
NAME="AEN4"
|
|
></A
|
|
>Michael Martin</H3
|
|
><P
|
|
CLASS="COPYRIGHT"
|
|
>Copyright © 2006-2014 Michael Martin</P
|
|
><HR></DIV
|
|
><DIV
|
|
CLASS="TOC"
|
|
><DL
|
|
><DT
|
|
><B
|
|
>Table of Contents</B
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="f10.html"
|
|
>Preface</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
><A
|
|
HREF="f10.html#AEN15"
|
|
>History of the project</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x30.html"
|
|
>Getting a copy of Ophis</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x42.html"
|
|
>About the examples</A
|
|
></DT
|
|
></DL
|
|
></DD
|
|
><DT
|
|
>I. <A
|
|
HREF="p51.html"
|
|
>Using the Ophis Assembler</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
><A
|
|
HREF="c56.html"
|
|
>The basics</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
><A
|
|
HREF="c56.html#AEN69"
|
|
>A note on numeric notation</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x72.html"
|
|
>Producing Commodore 64 programs</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x141.html"
|
|
>Related commands and options</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x162.html"
|
|
>Writing the actual code</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x171.html"
|
|
>Assembling the code</A
|
|
></DT
|
|
></DL
|
|
></DD
|
|
><DT
|
|
><A
|
|
HREF="c236.html"
|
|
>Labels and aliases</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
><A
|
|
HREF="c236.html#AEN242"
|
|
>Temporary labels</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x251.html"
|
|
>Anonymous labels</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x262.html"
|
|
>Aliasing</A
|
|
></DT
|
|
></DL
|
|
></DD
|
|
><DT
|
|
><A
|
|
HREF="c273.html"
|
|
>Headers, Libraries, and Macros</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
><A
|
|
HREF="c273.html#AEN277"
|
|
>Header files and libraries</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x298.html"
|
|
>Macros</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x328.html"
|
|
>Example code</A
|
|
></DT
|
|
></DL
|
|
></DD
|
|
><DT
|
|
><A
|
|
HREF="c333.html"
|
|
>Character maps</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="c367.html"
|
|
>Local variables and memory segments</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="c409.html"
|
|
>Expressions</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="c460.html"
|
|
>Advanced Memory Segments</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
><A
|
|
HREF="c460.html#AEN465"
|
|
>The Problem</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x471.html"
|
|
>The Solution</A
|
|
></DT
|
|
></DL
|
|
></DD
|
|
><DT
|
|
><A
|
|
HREF="c489.html"
|
|
>Platform-Specific Techniques</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
><A
|
|
HREF="c489.html#AEN492"
|
|
>The Commodore 64 and VIC-20</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x606.html"
|
|
>The Nintendo Entertainment System</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x611.html"
|
|
>The Atari 2600 VCS</A
|
|
></DT
|
|
></DL
|
|
></DD
|
|
></DL
|
|
></DD
|
|
><DT
|
|
>II. <A
|
|
HREF="p618.html"
|
|
>To HLL and Back</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
><A
|
|
HREF="c623.html"
|
|
>The Second Step</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
><A
|
|
HREF="c623.html#AEN626"
|
|
>The problem</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x635.html"
|
|
>The solution</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x641.html"
|
|
>Unsigned arithmetic</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x664.html"
|
|
>16-bit addition and subtraction</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x674.html"
|
|
>16-bit comparisons</A
|
|
></DT
|
|
></DL
|
|
></DD
|
|
><DT
|
|
><A
|
|
HREF="c680.html"
|
|
>Structured Programming</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
><A
|
|
HREF="c680.html#AEN685"
|
|
>Control constructs</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x734.html"
|
|
>The stack</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x740.html"
|
|
>Procedures and register saving</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x758.html"
|
|
>Variables</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x803.html"
|
|
>Data structures</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x856.html"
|
|
>A modest example: Insertion sort on linked lists</A
|
|
></DT
|
|
></DL
|
|
></DD
|
|
><DT
|
|
><A
|
|
HREF="c885.html"
|
|
>Pointers and Indirection</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
><A
|
|
HREF="c885.html#AEN890"
|
|
>The absolute basics</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x919.html"
|
|
>Pointer arithmetic</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x935.html"
|
|
>What about Indexed Indirect?</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x942.html"
|
|
>Comparison with the other indexed forms</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x950.html"
|
|
>Conclusion</A
|
|
></DT
|
|
></DL
|
|
></DD
|
|
><DT
|
|
><A
|
|
HREF="c953.html"
|
|
>Functionals</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
><A
|
|
HREF="c953.html#AEN958"
|
|
>Function Pointers</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x973.html"
|
|
>A quick digression on how subroutines work</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x992.html"
|
|
>Dispatch-on-type and Data-Directed Assembler</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1008.html"
|
|
>VTables and Object-Oriented Assembler</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1029.html"
|
|
>A final reminder</A
|
|
></DT
|
|
></DL
|
|
></DD
|
|
><DT
|
|
><A
|
|
HREF="c1037.html"
|
|
>Call Stacks</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
><A
|
|
HREF="c1037.html#AEN1041"
|
|
>Recursion</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1052.html"
|
|
>Our Goals</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1104.html"
|
|
>Example: Fibonnacci Numbers</A
|
|
></DT
|
|
></DL
|
|
></DD
|
|
></DL
|
|
></DD
|
|
><DT
|
|
><A
|
|
HREF="a1112.html"
|
|
>Example Programs</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
><A
|
|
HREF="a1112.html#TUTOR1-SRC"
|
|
><TT
|
|
CLASS="FILENAME"
|
|
>hello1.oph</TT
|
|
></A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1119.html"
|
|
><TT
|
|
CLASS="FILENAME"
|
|
>hello2.oph</TT
|
|
></A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1123.html"
|
|
><TT
|
|
CLASS="FILENAME"
|
|
>c64-1.oph</TT
|
|
></A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1127.html"
|
|
><TT
|
|
CLASS="FILENAME"
|
|
>c64kernal.oph</TT
|
|
></A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1131.html"
|
|
><TT
|
|
CLASS="FILENAME"
|
|
>hello3.oph</TT
|
|
></A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1135.html"
|
|
><TT
|
|
CLASS="FILENAME"
|
|
>hello4a.oph</TT
|
|
></A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1139.html"
|
|
><TT
|
|
CLASS="FILENAME"
|
|
>hello4b.oph</TT
|
|
></A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1143.html"
|
|
><TT
|
|
CLASS="FILENAME"
|
|
>hello4c.oph</TT
|
|
></A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1147.html"
|
|
><TT
|
|
CLASS="FILENAME"
|
|
>hello5.oph</TT
|
|
></A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1151.html"
|
|
><TT
|
|
CLASS="FILENAME"
|
|
>hello6.oph</TT
|
|
></A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1155.html"
|
|
><TT
|
|
CLASS="FILENAME"
|
|
>hello7.oph</TT
|
|
></A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1159.html"
|
|
><TT
|
|
CLASS="FILENAME"
|
|
>structuredemo.oph</TT
|
|
></A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1163.html"
|
|
><TT
|
|
CLASS="FILENAME"
|
|
>fibonacci.oph</TT
|
|
></A
|
|
></DT
|
|
></DL
|
|
></DD
|
|
><DT
|
|
><A
|
|
HREF="a1167.html"
|
|
>Ophis Command Reference</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
><A
|
|
HREF="a1167.html#AEN1169"
|
|
>Command Modes</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1234.html"
|
|
>Basic arguments</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
><A
|
|
HREF="x1234.html#AEN1237"
|
|
>Numeric types</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1234.html#AEN1260"
|
|
>Label types</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1234.html#AEN1273"
|
|
>String types</A
|
|
></DT
|
|
></DL
|
|
></DD
|
|
><DT
|
|
><A
|
|
HREF="x1282.html"
|
|
>Compound Arguments</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1309.html"
|
|
>Memory Model</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
><A
|
|
HREF="x1309.html#AEN1312"
|
|
>Basic PC tracking</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1309.html#AEN1321"
|
|
>Basic Segmentation simulation</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1309.html#AEN1345"
|
|
>General Segmentation Simulation</A
|
|
></DT
|
|
></DL
|
|
></DD
|
|
><DT
|
|
><A
|
|
HREF="x1354.html"
|
|
>Macros</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
><A
|
|
HREF="x1354.html#AEN1358"
|
|
>Defining Macros</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1354.html#AEN1364"
|
|
>Invoking Macros</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1354.html#AEN1372"
|
|
>Passing Arguments to Macros</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1354.html#AEN1382"
|
|
>Features and Restrictions of the Ophis Macro Model</A
|
|
></DT
|
|
></DL
|
|
></DD
|
|
><DT
|
|
><A
|
|
HREF="x1394.html"
|
|
>Assembler directives</A
|
|
></DT
|
|
></DL
|
|
></DD
|
|
></DL
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="NAVFOOTER"
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"><TABLE
|
|
SUMMARY="Footer navigation table"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
> </TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
> </TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="f10.html"
|
|
ACCESSKEY="N"
|
|
>Next >>></A
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
> </TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
> </TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
>Preface</TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |