mirror of
https://github.com/michaelcmartin/Ophis.git
synced 2025-03-17 22:29:31 +00:00
Remove outdated website data
This commit is contained in:
parent
5362a635c8
commit
ae59cbf3c4
@ -1,32 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html
|
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<head><title>The Ophis Assembler</title></head>
|
||||
<body>
|
||||
<h1>The Ophis Assembler</h1>
|
||||
|
||||
<p>Ophis is a cross-assembler for the 65xx series of chips. It supports the stock 6502 opcodes, the 65c02 extensions, and syntax for the "undocumented opcodes" in the 6510 chip used on the Commodore 64. (Syntax for these opcodes matches those given in the <a href="http://www.viceteam.org">VICE team's documentation</a>.)</p>
|
||||
|
||||
<p>Ophis is written in pure Python and should be highly portable.</p>
|
||||
|
||||
<p>If you have questions or comments, email me at <i>mcmartin AT gmail DOT com</i>.</p>
|
||||
|
||||
<h2>Downloads</h2>
|
||||
<ul>
|
||||
<li><a href="Ophis-1.0.tar.gz">Source distribution</a>. For Unix and Mac. Untar, then run "python setup.py install" as root to install. Documentation and sample code is in the tarball but won't be placed anywhere special.</li>
|
||||
<li><a href="http://hkn.eecs.berkeley.edu/~mcmartin/ophis/Ophis-1.0-win32-installer.exe">Win32 installer</a>. Installs a standalone executable and support libraries. You will need to put the install directory into your PATH to run it conveniently, as it is a commandline program.</li>
|
||||
</ul>
|
||||
|
||||
<h2>Documentation</h2>
|
||||
|
||||
<p>The manual <i>Programming with Ophis</i> is distributed with each download. You can also get it alone.</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="ophismanual.pdf">Download the PDF version of <i>Programming with Ophis</i></a></li>
|
||||
<li><a href="manual/book1.html">Browse <i>Programming with Ophis</i> online</a></li>
|
||||
</ul>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,184 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>Example Programs</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="Where to go from here"
|
||||
HREF="x449.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="tutor2.oph"
|
||||
HREF="x461.html"></HEAD
|
||||
><BODY
|
||||
CLASS="APPENDIX"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x449.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x461.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="APPENDIX"
|
||||
><H1
|
||||
><A
|
||||
NAME="AEN454"
|
||||
></A
|
||||
>Example Programs</H1
|
||||
><P
|
||||
> This Appendix collects all the programs referred to in the course
|
||||
of this manual.
|
||||
</P
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="TUTOR1-SRC"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor1.oph</TT
|
||||
></A
|
||||
></H1
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.word $0801
|
||||
.org $0801
|
||||
|
||||
.word next, 10 ; Next line and current line number
|
||||
.byte $9e," 2064",0 ; SYS 2064
|
||||
next: .word 0 ; End of program
|
||||
|
||||
.advance 2064
|
||||
|
||||
ldx #0
|
||||
loop: lda hello, x
|
||||
beq done
|
||||
jsr $ffd2
|
||||
inx
|
||||
bne loop
|
||||
done: rts
|
||||
|
||||
hello: .byte "HELLO, WORLD!", 0</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></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"
|
||||
><A
|
||||
HREF="x449.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="x461.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
>Where to go from here</TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
> </TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor2.oph</TT
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,311 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>Ophis Command Reference</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="tutor7.oph"
|
||||
HREF="x501.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="Basic arguments"
|
||||
HREF="x572.html"></HEAD
|
||||
><BODY
|
||||
CLASS="APPENDIX"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x501.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x572.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="APPENDIX"
|
||||
><H1
|
||||
><A
|
||||
NAME="REF-LINK"
|
||||
></A
|
||||
>Ophis Command Reference</H1
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN507"
|
||||
>Command Modes</A
|
||||
></H1
|
||||
><P
|
||||
> These mostly follow the <I
|
||||
CLASS="EMPHASIS"
|
||||
>MOS Technology 6500
|
||||
Microprocessor Family Programming Manual</I
|
||||
>, except
|
||||
for the Accumulator mode. Accumulator instructions are written
|
||||
and interpreted identically to Implied mode instructions.
|
||||
</P
|
||||
><P
|
||||
></P
|
||||
><UL
|
||||
><LI
|
||||
><P
|
||||
><I
|
||||
CLASS="EMPHASIS"
|
||||
>Implied:</I
|
||||
> <TT
|
||||
CLASS="LITERAL"
|
||||
>RTS</TT
|
||||
></P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
><I
|
||||
CLASS="EMPHASIS"
|
||||
>Accumulator:</I
|
||||
> <TT
|
||||
CLASS="LITERAL"
|
||||
>LSR</TT
|
||||
></P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
><I
|
||||
CLASS="EMPHASIS"
|
||||
>Immediate:</I
|
||||
> <TT
|
||||
CLASS="LITERAL"
|
||||
>LDA #$06</TT
|
||||
></P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
><I
|
||||
CLASS="EMPHASIS"
|
||||
>Zero Page:</I
|
||||
> <TT
|
||||
CLASS="LITERAL"
|
||||
>LDA $7C</TT
|
||||
></P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
><I
|
||||
CLASS="EMPHASIS"
|
||||
>Zero Page, X:</I
|
||||
> <TT
|
||||
CLASS="LITERAL"
|
||||
>LDA $7C,X</TT
|
||||
></P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
><I
|
||||
CLASS="EMPHASIS"
|
||||
>Zero Page, Y:</I
|
||||
> <TT
|
||||
CLASS="LITERAL"
|
||||
>LDA $7C,Y</TT
|
||||
></P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
><I
|
||||
CLASS="EMPHASIS"
|
||||
>Absolute:</I
|
||||
> <TT
|
||||
CLASS="LITERAL"
|
||||
>LDA $D020</TT
|
||||
></P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
><I
|
||||
CLASS="EMPHASIS"
|
||||
>Absolute, X:</I
|
||||
> <TT
|
||||
CLASS="LITERAL"
|
||||
>LDA $D000,X</TT
|
||||
></P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
><I
|
||||
CLASS="EMPHASIS"
|
||||
>Absolute, Y:</I
|
||||
> <TT
|
||||
CLASS="LITERAL"
|
||||
>LDA $D000,Y</TT
|
||||
></P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
><I
|
||||
CLASS="EMPHASIS"
|
||||
>(Zero Page Indirect, X):</I
|
||||
> <TT
|
||||
CLASS="LITERAL"
|
||||
>LDA ($80, X)</TT
|
||||
></P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
><I
|
||||
CLASS="EMPHASIS"
|
||||
>(Zero Page Indirect), Y:</I
|
||||
> <TT
|
||||
CLASS="LITERAL"
|
||||
>LDA ($80), Y</TT
|
||||
></P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
><I
|
||||
CLASS="EMPHASIS"
|
||||
>(Absolute Indirect):</I
|
||||
> <TT
|
||||
CLASS="LITERAL"
|
||||
>JMP ($A000)</TT
|
||||
></P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
><I
|
||||
CLASS="EMPHASIS"
|
||||
>Relative:</I
|
||||
> <TT
|
||||
CLASS="LITERAL"
|
||||
>BNE loop</TT
|
||||
></P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
><I
|
||||
CLASS="EMPHASIS"
|
||||
>(Absolute Indirect, X):</I
|
||||
> <TT
|
||||
CLASS="LITERAL"
|
||||
>JMP ($A000, X)</TT
|
||||
> — Only available with 65C02 extensions</P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
><I
|
||||
CLASS="EMPHASIS"
|
||||
>(Zero Page Indirect):</I
|
||||
> <TT
|
||||
CLASS="LITERAL"
|
||||
>LDX ($80)</TT
|
||||
> — Only available with 65C02 extensions</P
|
||||
></LI
|
||||
></UL
|
||||
></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"
|
||||
><A
|
||||
HREF="x501.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="x572.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor7.oph</TT
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
> </TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
>Basic arguments</TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,467 +0,0 @@
|
||||
<!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-7 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"
|
||||
>Why <SPAN
|
||||
CLASS="QUOTE"
|
||||
>"Ophis"</SPAN
|
||||
>?</A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x22.html"
|
||||
>Getting a copy of Ophis</A
|
||||
></DT
|
||||
></DL
|
||||
></DD
|
||||
><DT
|
||||
><A
|
||||
HREF="c35.html"
|
||||
>The basics</A
|
||||
></DT
|
||||
><DD
|
||||
><DL
|
||||
><DT
|
||||
><A
|
||||
HREF="c35.html#AEN48"
|
||||
>A note on numeric notation</A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x51.html"
|
||||
>Producing Commodore 64 programs</A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x119.html"
|
||||
>Related commands and options</A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x140.html"
|
||||
>Writing the actual code</A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x149.html"
|
||||
>Assembling the code</A
|
||||
></DT
|
||||
></DL
|
||||
></DD
|
||||
><DT
|
||||
><A
|
||||
HREF="c200.html"
|
||||
>Labels and aliases</A
|
||||
></DT
|
||||
><DD
|
||||
><DL
|
||||
><DT
|
||||
><A
|
||||
HREF="c200.html#AEN206"
|
||||
>Temporary labels</A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x214.html"
|
||||
>Anonymous labels</A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x225.html"
|
||||
>Aliasing</A
|
||||
></DT
|
||||
></DL
|
||||
></DD
|
||||
><DT
|
||||
><A
|
||||
HREF="c236.html"
|
||||
>Headers, Libraries, and Macros</A
|
||||
></DT
|
||||
><DD
|
||||
><DL
|
||||
><DT
|
||||
><A
|
||||
HREF="c236.html#AEN240"
|
||||
>Header files and libraries</A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x257.html"
|
||||
>Macros</A
|
||||
></DT
|
||||
><DD
|
||||
><DL
|
||||
><DT
|
||||
><A
|
||||
HREF="x257.html#AEN265"
|
||||
>Macro definitions</A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x257.html#AEN278"
|
||||
>Macro invocations</A
|
||||
></DT
|
||||
></DL
|
||||
></DD
|
||||
><DT
|
||||
><A
|
||||
HREF="x287.html"
|
||||
>Example code</A
|
||||
></DT
|
||||
></DL
|
||||
></DD
|
||||
><DT
|
||||
><A
|
||||
HREF="c292.html"
|
||||
>Character maps</A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="c329.html"
|
||||
>Local variables and memory segments</A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="c371.html"
|
||||
>Expressions</A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="c419.html"
|
||||
>Advanced Memory Segments</A
|
||||
></DT
|
||||
><DD
|
||||
><DL
|
||||
><DT
|
||||
><A
|
||||
HREF="c419.html#AEN424"
|
||||
>The Problem</A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x430.html"
|
||||
>The Solution</A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x449.html"
|
||||
>Where to go from here</A
|
||||
></DT
|
||||
></DL
|
||||
></DD
|
||||
><DT
|
||||
><A
|
||||
HREF="a454.html"
|
||||
>Example Programs</A
|
||||
></DT
|
||||
><DD
|
||||
><DL
|
||||
><DT
|
||||
><A
|
||||
HREF="a454.html#TUTOR1-SRC"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor1.oph</TT
|
||||
></A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x461.html"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor2.oph</TT
|
||||
></A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x465.html"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>c64-1.oph</TT
|
||||
></A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x469.html"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>kernal.oph</TT
|
||||
></A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x473.html"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor3.oph</TT
|
||||
></A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x477.html"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor4a.oph</TT
|
||||
></A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x481.html"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor4b.oph</TT
|
||||
></A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x485.html"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor4c.oph</TT
|
||||
></A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x489.html"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor5.oph</TT
|
||||
></A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x493.html"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor6.oph</TT
|
||||
></A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x497.html"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>c64-2.oph</TT
|
||||
></A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x501.html"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor7.oph</TT
|
||||
></A
|
||||
></DT
|
||||
></DL
|
||||
></DD
|
||||
><DT
|
||||
><A
|
||||
HREF="a505.html"
|
||||
>Ophis Command Reference</A
|
||||
></DT
|
||||
><DD
|
||||
><DL
|
||||
><DT
|
||||
><A
|
||||
HREF="a505.html#AEN507"
|
||||
>Command Modes</A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x572.html"
|
||||
>Basic arguments</A
|
||||
></DT
|
||||
><DD
|
||||
><DL
|
||||
><DT
|
||||
><A
|
||||
HREF="x572.html#AEN575"
|
||||
>Numeric types</A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x572.html#AEN598"
|
||||
>Label types</A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x572.html#AEN611"
|
||||
>String types</A
|
||||
></DT
|
||||
></DL
|
||||
></DD
|
||||
><DT
|
||||
><A
|
||||
HREF="x620.html"
|
||||
>Compound Arguments</A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x647.html"
|
||||
>Memory Model</A
|
||||
></DT
|
||||
><DD
|
||||
><DL
|
||||
><DT
|
||||
><A
|
||||
HREF="x647.html#AEN650"
|
||||
>Basic PC tracking</A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x647.html#AEN659"
|
||||
>Basic Segmentation simulation</A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x647.html#AEN683"
|
||||
>General Segmentation Simulation</A
|
||||
></DT
|
||||
></DL
|
||||
></DD
|
||||
><DT
|
||||
><A
|
||||
HREF="x692.html"
|
||||
>Macros</A
|
||||
></DT
|
||||
><DD
|
||||
><DL
|
||||
><DT
|
||||
><A
|
||||
HREF="x692.html#AEN696"
|
||||
>Defining Macros</A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x692.html#AEN702"
|
||||
>Invoking Macros</A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x692.html#AEN710"
|
||||
>Passing Arguments to Macros</A
|
||||
></DT
|
||||
><DT
|
||||
><A
|
||||
HREF="x692.html#AEN720"
|
||||
>Features and Restrictions of the Ophis Macro Model</A
|
||||
></DT
|
||||
></DL
|
||||
></DD
|
||||
><DT
|
||||
><A
|
||||
HREF="x732.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
|
||||
>
|
@ -1,208 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>Labels and aliases</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="Assembling the code"
|
||||
HREF="x149.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="Anonymous labels"
|
||||
HREF="x214.html"></HEAD
|
||||
><BODY
|
||||
CLASS="CHAPTER"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x149.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x214.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="CHAPTER"
|
||||
><H1
|
||||
><A
|
||||
NAME="AEN200"
|
||||
></A
|
||||
>Labels and aliases</H1
|
||||
><P
|
||||
> Labels are an important part of your code. However, since each
|
||||
label must normally be unique, this can lead to <SPAN
|
||||
CLASS="QUOTE"
|
||||
>"namespace
|
||||
pollution,"</SPAN
|
||||
> and you'll find yourself going through ever
|
||||
more contorted constructions to generate unique label names.
|
||||
Ophis offers two solutions to this: <I
|
||||
CLASS="EMPHASIS"
|
||||
>anonymous
|
||||
labels</I
|
||||
> and <I
|
||||
CLASS="EMPHASIS"
|
||||
>temporary labels</I
|
||||
>. This
|
||||
tutorial will cover both of these facilities, and also introduce
|
||||
the aliasing mechanism.
|
||||
</P
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN206"
|
||||
>Temporary labels</A
|
||||
></H1
|
||||
><P
|
||||
> Temporary labels are the easiest to use. If a label begins with
|
||||
an underscore, it will only be reachable from inside the
|
||||
innermost enclosing scope. Scopes begin when
|
||||
a <TT
|
||||
CLASS="LITERAL"
|
||||
>.scope</TT
|
||||
> statement is encountered. This
|
||||
produces a new, inner scope if there is another scope in use.
|
||||
The <TT
|
||||
CLASS="LITERAL"
|
||||
>.scend</TT
|
||||
> command ends the innermost
|
||||
currently active scope.
|
||||
</P
|
||||
><P
|
||||
> We can thus rewrite our header data using temporary labels, thus
|
||||
allowing the main program to have a label
|
||||
named <TT
|
||||
CLASS="LITERAL"
|
||||
>next</TT
|
||||
> if it wants.
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.word $0801
|
||||
.org $0801
|
||||
|
||||
.scope
|
||||
.word _next, 10 ; Next line and current line number
|
||||
.byte $9e," 2064",0 ; SYS 2064
|
||||
_next: .word 0 ; End of program
|
||||
.scend
|
||||
|
||||
.advance 2064</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></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"
|
||||
><A
|
||||
HREF="x149.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="x214.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
>Assembling the code</TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
> </TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
>Anonymous labels</TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,226 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>Headers, Libraries, and Macros</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="Aliasing"
|
||||
HREF="x225.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="Macros"
|
||||
HREF="x257.html"></HEAD
|
||||
><BODY
|
||||
CLASS="CHAPTER"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x225.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x257.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="CHAPTER"
|
||||
><H1
|
||||
><A
|
||||
NAME="CH3-LINK"
|
||||
></A
|
||||
>Headers, Libraries, and Macros</H1
|
||||
><P
|
||||
> In this chapter we will split away parts of our <SPAN
|
||||
CLASS="QUOTE"
|
||||
>"Hello
|
||||
World"</SPAN
|
||||
> program into reusable header files and libraries.
|
||||
We will also abstract away our string printing technique into a
|
||||
macro which may be invoked at will, on arbitrary strings. We will
|
||||
then multiply the output of our program tenfold.
|
||||
</P
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN240"
|
||||
>Header files and libraries</A
|
||||
></H1
|
||||
><P
|
||||
> The prelude to our program—the <TT
|
||||
CLASS="FILENAME"
|
||||
>PRG</TT
|
||||
>
|
||||
information and the BASIC program—are going to be the same
|
||||
in many, many programs. Thus, we should put them into a header
|
||||
file to be included later. The <TT
|
||||
CLASS="LITERAL"
|
||||
>.include</TT
|
||||
>
|
||||
directive will load a file and insert it as source at the
|
||||
designated point.
|
||||
</P
|
||||
><P
|
||||
> A related directive, <TT
|
||||
CLASS="LITERAL"
|
||||
>.require</TT
|
||||
>, will include
|
||||
the file as long as it hasn't been included yet elsewhere. It
|
||||
is useful for ensuring a library is linked in.
|
||||
</P
|
||||
><P
|
||||
> For pre-assembled code or raw binary data,
|
||||
the <TT
|
||||
CLASS="LITERAL"
|
||||
>.incbin</TT
|
||||
> directive lets you include the
|
||||
contents of a binary file directly in the output. This is handy
|
||||
for linking in pre-created graphics or sound data.
|
||||
</P
|
||||
><P
|
||||
> As a sample library, we will expand the definition of
|
||||
the <TT
|
||||
CLASS="LITERAL"
|
||||
>chrout</TT
|
||||
> routine to include the standard
|
||||
names for every KERNAL routine. Our header file will
|
||||
then <TT
|
||||
CLASS="LITERAL"
|
||||
>.require</TT
|
||||
> it.
|
||||
</P
|
||||
><P
|
||||
> We'll also add some convenience aliases for things like reverse
|
||||
video, color changes, and shifting between upper case/graphics
|
||||
and mixed case text. We'd feed those to
|
||||
the <TT
|
||||
CLASS="LITERAL"
|
||||
>chrout</TT
|
||||
> routine to get their effects.
|
||||
</P
|
||||
><P
|
||||
> Since there have been no interesting changes to the prelude, and
|
||||
the KERNAL values are standard, we do not reproduce them here.
|
||||
(The files in question are <A
|
||||
HREF="x465.html"
|
||||
><I
|
||||
><I
|
||||
>c64-1.oph</I
|
||||
></I
|
||||
></A
|
||||
> and <A
|
||||
HREF="x469.html"
|
||||
><I
|
||||
><I
|
||||
>kernal.oph</I
|
||||
></I
|
||||
></A
|
||||
>.)
|
||||
</P
|
||||
></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"
|
||||
><A
|
||||
HREF="x225.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="x257.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
>Aliasing</TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
> </TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
>Macros</TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,344 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>Character maps</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="Example code"
|
||||
HREF="x287.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="Local variables and memory segments"
|
||||
HREF="c329.html"></HEAD
|
||||
><BODY
|
||||
CLASS="CHAPTER"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x287.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="c329.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="CHAPTER"
|
||||
><H1
|
||||
><A
|
||||
NAME="CH4-LINK"
|
||||
></A
|
||||
>Character maps</H1
|
||||
><P
|
||||
> Now we will close the gap between the Commodore's
|
||||
version of ASCII and the real one. We'll also add a time-delay
|
||||
routine to slow down the output. This routine isn't really of
|
||||
interest to us right now, so we'll add a subroutine
|
||||
called <TT
|
||||
CLASS="LITERAL"
|
||||
>delay</TT
|
||||
> that executes 2,560*(accumulator)
|
||||
<KBD
|
||||
CLASS="USERINPUT"
|
||||
>NOP</KBD
|
||||
>s. By the time the program is finished,
|
||||
we'll have executed 768,000 no-ops.
|
||||
</P
|
||||
><P
|
||||
> There actually are better ways of getting a time-delay on the
|
||||
Commodore 64; we'll deal with those in <A
|
||||
HREF="c329.html"
|
||||
>the Chapter called <I
|
||||
>Local variables and memory segments</I
|
||||
></A
|
||||
>.
|
||||
As a result, there isn't really a lot to discuss here. The later
|
||||
tutorials will be building off of <A
|
||||
HREF="x477.html"
|
||||
><I
|
||||
><I
|
||||
>tutor4a.oph</I
|
||||
></I
|
||||
></A
|
||||
>, so you may want to get familiar with
|
||||
that. Note also the change to the body of
|
||||
the <TT
|
||||
CLASS="LITERAL"
|
||||
>greet</TT
|
||||
> macro.
|
||||
</P
|
||||
><P
|
||||
> On to the topic at hand. Let's change the code to use mixed case.
|
||||
We defined the <TT
|
||||
CLASS="LITERAL"
|
||||
>upper'case</TT
|
||||
>
|
||||
and <TT
|
||||
CLASS="LITERAL"
|
||||
>lower'case</TT
|
||||
> aliases back
|
||||
in <A
|
||||
HREF="c236.html"
|
||||
>the Chapter called <I
|
||||
>Headers, Libraries, and Macros</I
|
||||
></A
|
||||
> as part of the
|
||||
standard <A
|
||||
HREF="x469.html"
|
||||
><I
|
||||
><I
|
||||
>kernal.oph</I
|
||||
></I
|
||||
></A
|
||||
>
|
||||
header, so we can add this before our invocations of
|
||||
the <TT
|
||||
CLASS="LITERAL"
|
||||
>greet</TT
|
||||
> macro:
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
> lda #lower'case
|
||||
jsr chrout</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
> And that will put us into mixed case mode. So, now we just need
|
||||
to redefine the data so that it uses the mixed-case:
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>hello1: .byte "Hello, ",0
|
||||
hello2: .byte "!", 13, 0
|
||||
|
||||
target1: .byte "programmer", 0
|
||||
target2: .byte "room", 0
|
||||
target3: .byte "building", 0
|
||||
target4: .byte "neighborhood", 0
|
||||
target5: .byte "city", 0
|
||||
target6: .byte "nation", 0
|
||||
target7: .byte "world", 0
|
||||
target8: .byte "Solar System", 0
|
||||
target9: .byte "Galaxy", 0
|
||||
target10: .byte "Universe", 0</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
> The code that does this is in <A
|
||||
HREF="x481.html"
|
||||
><I
|
||||
><I
|
||||
>tutor4b.oph</I
|
||||
></I
|
||||
></A
|
||||
>. If you assemble and run it, you will
|
||||
notice that the output is not what we want. In particular, upper
|
||||
and lowercase are reversed, so we have messages
|
||||
like <SAMP
|
||||
CLASS="COMPUTEROUTPUT"
|
||||
>hELLO, sOLAR sYSTEM!</SAMP
|
||||
>. For
|
||||
the specific case of PETSCII, we can just fix our strings, but
|
||||
that's less of an option if we're writing for the Apple II's
|
||||
character set, or targeting a game console that puts its letters
|
||||
in arbitrary locations. We need to remap how strings are turned
|
||||
into byte values. The <TT
|
||||
CLASS="LITERAL"
|
||||
>.charmap</TT
|
||||
>
|
||||
and <TT
|
||||
CLASS="LITERAL"
|
||||
>.charmapbin</TT
|
||||
> directives do what we need.
|
||||
</P
|
||||
><P
|
||||
> The <TT
|
||||
CLASS="LITERAL"
|
||||
>.charmap</TT
|
||||
> directive usually takes two
|
||||
arguments; a byte (usually in character form) indicating the ASCII
|
||||
value to start remapping from, and then a string giving the new
|
||||
values. To do our case-swapping, we write two directives before
|
||||
defining any string constants:
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.charmap 'A, "abcdefghijklmnopqrstuvwxyz"
|
||||
.charmap 'a, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
> Note that the <TT
|
||||
CLASS="LITERAL"
|
||||
>'a</TT
|
||||
> constant in the second
|
||||
directive refers to the <SPAN
|
||||
CLASS="QUOTE"
|
||||
>"a"</SPAN
|
||||
> character in the source,
|
||||
not in the current map.
|
||||
</P
|
||||
><P
|
||||
> The fixed code is in <A
|
||||
HREF="x485.html"
|
||||
><I
|
||||
><I
|
||||
>tutor4c.oph</I
|
||||
></I
|
||||
></A
|
||||
>, and will produce the expected results
|
||||
when run.
|
||||
</P
|
||||
><P
|
||||
> An alternative is to use a <TT
|
||||
CLASS="LITERAL"
|
||||
>.charmapbin</TT
|
||||
>
|
||||
directive to replace the entire character map directly. This
|
||||
specifies an external file, 256 bytes long, that is loaded in at
|
||||
that point. A binary character map for the Commodore 64 is
|
||||
provided with the sample programs
|
||||
as <TT
|
||||
CLASS="FILENAME"
|
||||
>petscii.map</TT
|
||||
>. There are also three
|
||||
files, <TT
|
||||
CLASS="FILENAME"
|
||||
>a2normal.map</TT
|
||||
>, <TT
|
||||
CLASS="FILENAME"
|
||||
>a2inverse.map</TT
|
||||
>,
|
||||
and <TT
|
||||
CLASS="FILENAME"
|
||||
>a2blink.map</TT
|
||||
> that handle the Apple II's
|
||||
very nonstandard character encodings.
|
||||
</P
|
||||
></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"
|
||||
><A
|
||||
HREF="x287.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="c329.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
>Example code</TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
> </TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
>Local variables and memory segments</TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,402 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>Local variables and memory segments</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="Character maps"
|
||||
HREF="c292.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="Expressions"
|
||||
HREF="c371.html"></HEAD
|
||||
><BODY
|
||||
CLASS="CHAPTER"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="c292.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="c371.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="CHAPTER"
|
||||
><H1
|
||||
><A
|
||||
NAME="CH5-LINK"
|
||||
></A
|
||||
>Local variables and memory segments</H1
|
||||
><P
|
||||
> As mentioned in <A
|
||||
HREF="c292.html"
|
||||
>the Chapter called <I
|
||||
>Character maps</I
|
||||
></A
|
||||
>, there are better ways
|
||||
to handle waiting than just executing vast numbers of NOPs. The
|
||||
Commodore 64 KERNAL library includes a <TT
|
||||
CLASS="LITERAL"
|
||||
>rdtim</TT
|
||||
>
|
||||
routine that returns the uptime of the machine, in
|
||||
60<SUP
|
||||
>th</SUP
|
||||
>s of a second, as a 24-bit integer.
|
||||
The Commodore 64 programmer's guide available online actually has
|
||||
a bug in it, reversing the significance of the A and Y registers.
|
||||
The accumulator holds the <I
|
||||
CLASS="EMPHASIS"
|
||||
>least</I
|
||||
> significant
|
||||
byte, not the most.
|
||||
</P
|
||||
><P
|
||||
> Here's a first shot at a better delay routine:
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.scope
|
||||
; data used by the delay routine
|
||||
_tmp: .byte 0
|
||||
_target: .byte 0
|
||||
|
||||
delay: sta _tmp ; save argument (rdtim destroys it)
|
||||
jsr rdtim
|
||||
clc
|
||||
adc _tmp ; add current time to get target
|
||||
sta _target
|
||||
* jsr rdtim
|
||||
cmp _target
|
||||
bmi - ; Buzz until target reached
|
||||
rts
|
||||
.scend</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
> This works, but it eats up two bytes of file space that don't
|
||||
really need to be specified. Also, it's modifying data inside a
|
||||
program text area, which isn't good if you're assembling to a ROM
|
||||
chip. (Since the Commodore 64 stores its programs in RAM, it's
|
||||
not an issue for us here.) A slightly better solution is to
|
||||
use <TT
|
||||
CLASS="LITERAL"
|
||||
>.alias</TT
|
||||
> to assign the names to chunks of RAM
|
||||
somewhere. There's a 4K chunk of RAM from $C000 through $CFFF
|
||||
between the BASIC ROM and the I/O ROM that should serve our
|
||||
purposes nicely. We can replace the definitions
|
||||
of <TT
|
||||
CLASS="LITERAL"
|
||||
>_tmp</TT
|
||||
> and <TT
|
||||
CLASS="LITERAL"
|
||||
>_target</TT
|
||||
> with:
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
> ; data used by the delay routine
|
||||
.alias _tmp $C000
|
||||
.alias _target $C001</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
> This works better, but now we've just added a major bookkeeping
|
||||
burden upon ourselves—we must ensure that no routines step on
|
||||
each other. What we'd really like are two separate program
|
||||
counters—one for the program text, and one for our variable
|
||||
space.
|
||||
</P
|
||||
><P
|
||||
> Ophis lets us do this with the <TT
|
||||
CLASS="LITERAL"
|
||||
>.text</TT
|
||||
>
|
||||
and <TT
|
||||
CLASS="LITERAL"
|
||||
>.data</TT
|
||||
> commands.
|
||||
The <TT
|
||||
CLASS="LITERAL"
|
||||
>.text</TT
|
||||
> command switches to the program-text
|
||||
counter, and the <TT
|
||||
CLASS="LITERAL"
|
||||
>.data</TT
|
||||
> command switches to the
|
||||
variable-data counter. When Ophis first starts assembling a file,
|
||||
it starts in <TT
|
||||
CLASS="LITERAL"
|
||||
>.text</TT
|
||||
> mode.
|
||||
</P
|
||||
><P
|
||||
> To reserve space for a variable, use the .space command. This
|
||||
takes the form:
|
||||
|
||||
<TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.space varname size</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
>
|
||||
|
||||
which assigns the name <TT
|
||||
CLASS="LITERAL"
|
||||
>varname</TT
|
||||
> to the current
|
||||
program counter, then advances the program counter by the amount
|
||||
specified in <TT
|
||||
CLASS="LITERAL"
|
||||
>size</TT
|
||||
>. Nothing is output to the
|
||||
final binary as a result of the <TT
|
||||
CLASS="LITERAL"
|
||||
>.space</TT
|
||||
> command.
|
||||
</P
|
||||
><P
|
||||
> You may not put in any commands that produce output into
|
||||
a <TT
|
||||
CLASS="LITERAL"
|
||||
>.data</TT
|
||||
> segment. Generally, all you will be
|
||||
using are <TT
|
||||
CLASS="LITERAL"
|
||||
>.org</TT
|
||||
> and <TT
|
||||
CLASS="LITERAL"
|
||||
>.space</TT
|
||||
>
|
||||
commands. Ophis will not complain if you
|
||||
use <TT
|
||||
CLASS="LITERAL"
|
||||
>.space</TT
|
||||
> inside a <TT
|
||||
CLASS="LITERAL"
|
||||
>.text</TT
|
||||
>
|
||||
segment, but this is nearly always wrong.
|
||||
</P
|
||||
><P
|
||||
> The final version of <TT
|
||||
CLASS="LITERAL"
|
||||
>delay</TT
|
||||
> looks like this:
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>; DELAY routine. Takes values from the Accumulator and pauses
|
||||
; for that many jiffies (1/60th of a second).
|
||||
.scope
|
||||
.data
|
||||
.space _tmp 1
|
||||
.space _target 1
|
||||
|
||||
.text
|
||||
|
||||
delay: sta _tmp ; save argument (rdtim destroys it)
|
||||
jsr rdtim
|
||||
clc
|
||||
adc _tmp ; add current time to get target
|
||||
sta _target
|
||||
* jsr rdtim
|
||||
cmp _target
|
||||
bmi - ; Buzz until target reached
|
||||
rts
|
||||
.scend</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
> We're not quite done yet, however, because we have to tell the
|
||||
data segment where to begin. (If we don't, it starts at 0, which
|
||||
is usually wrong.) We add a very brief data segment to the top of
|
||||
our code:
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.data
|
||||
.org $C000
|
||||
.text</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
> This will run. However, we also ought to make sure that we aren't
|
||||
overstepping any boundaries. Our program text shouldn't run into
|
||||
the BASIC chip at $A000, and our data shouldn't run into the I/O
|
||||
region at $D000. The <TT
|
||||
CLASS="LITERAL"
|
||||
>.checkpc</TT
|
||||
> command lets us
|
||||
assert that the program counter hasn't reached a specific point
|
||||
yet. We put, at the end of our code:
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.checkpc $A000
|
||||
.data
|
||||
.checkpc $D000</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
> The final program is available as <A
|
||||
HREF="x489.html"
|
||||
><I
|
||||
><I
|
||||
>tutor5.oph</I
|
||||
></I
|
||||
></A
|
||||
>. Note that we based this on the
|
||||
all-uppercase version from the last section, not any of the
|
||||
charmapped versions.
|
||||
</P
|
||||
></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"
|
||||
><A
|
||||
HREF="c292.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="c371.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
>Character maps</TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
> </TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
>Expressions</TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,180 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>The basics</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="Getting a copy of Ophis"
|
||||
HREF="x22.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="Producing Commodore 64 programs"
|
||||
HREF="x51.html"></HEAD
|
||||
><BODY
|
||||
CLASS="CHAPTER"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x22.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x51.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="CHAPTER"
|
||||
><H1
|
||||
><A
|
||||
NAME="PART1"
|
||||
></A
|
||||
>The basics</H1
|
||||
><P
|
||||
> In this first part of the tutorial we will create a
|
||||
simple <SPAN
|
||||
CLASS="QUOTE"
|
||||
>"Hello World"</SPAN
|
||||
> program to run on the Commodore
|
||||
64. This will cover:
|
||||
|
||||
<P
|
||||
></P
|
||||
><UL
|
||||
><LI
|
||||
><P
|
||||
>How to make programs run on a Commodore 64</P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
>Writing simple code with labels</P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
>Numeric and string data</P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
>Invoking the assembler</P
|
||||
></LI
|
||||
></UL
|
||||
>
|
||||
</P
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN48"
|
||||
>A note on numeric notation</A
|
||||
></H1
|
||||
><P
|
||||
> Throughout these tutorials, I will be using a lot of both
|
||||
decimal and hexadecimal notation. Hex numbers will have a
|
||||
dollar sign in front of them. Thus, 100 = $64, and $100 = 256.
|
||||
</P
|
||||
></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"
|
||||
><A
|
||||
HREF="x22.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="x51.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
>Getting a copy of Ophis</TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
> </TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
>Producing Commodore 64 programs</TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,348 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>Expressions</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="Local variables and memory segments"
|
||||
HREF="c329.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="Advanced Memory Segments"
|
||||
HREF="c419.html"></HEAD
|
||||
><BODY
|
||||
CLASS="CHAPTER"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="c329.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="c419.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="CHAPTER"
|
||||
><H1
|
||||
><A
|
||||
NAME="AEN371"
|
||||
></A
|
||||
>Expressions</H1
|
||||
><P
|
||||
> Ophis permits a reasonably rich set of arithmetic operations to be
|
||||
done at assemble time. So far, all of our arguments and values
|
||||
have either been constants or label names. In this chapter, we
|
||||
will modify the <TT
|
||||
CLASS="LITERAL"
|
||||
>print</TT
|
||||
> macro so that it calls a
|
||||
subroutine to do the actual printing. This will shrink the final
|
||||
code size a fair bit.
|
||||
</P
|
||||
><P
|
||||
> Here's our printing routine. It's fairly straightforward.
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>; PRINTSTR routine. Accumulator stores the low byte of the address,
|
||||
; X register stores the high byte. Destroys the values of $10 and
|
||||
; $11.
|
||||
|
||||
.scope
|
||||
printstr:
|
||||
sta $10
|
||||
stx $11
|
||||
ldy #$00
|
||||
_lp: lda ($10), y
|
||||
beq _done
|
||||
jsr chrout
|
||||
iny
|
||||
bne _lp
|
||||
_done: rts
|
||||
.scend</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
> However, now we are faced with the problem of what to do with
|
||||
the <TT
|
||||
CLASS="LITERAL"
|
||||
>print</TT
|
||||
> macro. We need to take a 16-bit
|
||||
value and store it in two 8-bit registers. We can use
|
||||
the <TT
|
||||
CLASS="LITERAL"
|
||||
><</TT
|
||||
> and <TT
|
||||
CLASS="LITERAL"
|
||||
>></TT
|
||||
> operators
|
||||
to take the low or high byte of a word, respectively.
|
||||
The <TT
|
||||
CLASS="LITERAL"
|
||||
>print</TT
|
||||
> macro becomes:
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.macro print
|
||||
lda #<_1
|
||||
ldx #>_1
|
||||
jsr printstr
|
||||
.macend</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
> Also, since BASIC uses the locations $10 and $11, we should really
|
||||
cache them at the start of the program and restore them at the
|
||||
end:
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.data
|
||||
.org $C000
|
||||
.space cache 2
|
||||
.text
|
||||
|
||||
; Save the zero page locations that printstr uses.
|
||||
lda $10
|
||||
sta cache
|
||||
lda $11
|
||||
sta cache+1
|
||||
|
||||
; ... main program goes here ...
|
||||
|
||||
; Restore the zero page values printstr uses.
|
||||
lda cache
|
||||
sta $10
|
||||
lda cache+1
|
||||
sta $11</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
> Note that we only have to name <TT
|
||||
CLASS="LITERAL"
|
||||
>cache</TT
|
||||
> once, but
|
||||
can use addition to refer to any offset from it.
|
||||
</P
|
||||
><P
|
||||
> Ophis supports following operations, with the following precedence
|
||||
levels (higher entries bind more tightly):
|
||||
</P
|
||||
><DIV
|
||||
CLASS="TABLE"
|
||||
><A
|
||||
NAME="AEN388"
|
||||
></A
|
||||
><P
|
||||
><B
|
||||
>Table 1. Ophis Operators</B
|
||||
></P
|
||||
><TABLE
|
||||
BORDER="1"
|
||||
BGCOLOR="#E0E0E0"
|
||||
CELLSPACING="0"
|
||||
CELLPADDING="4"
|
||||
CLASS="CALSTABLE"
|
||||
><THEAD
|
||||
><TR
|
||||
><TH
|
||||
ALIGN="CENTER"
|
||||
>Operators</TH
|
||||
><TH
|
||||
ALIGN="CENTER"
|
||||
>Description</TH
|
||||
></TR
|
||||
></THEAD
|
||||
><TBODY
|
||||
><TR
|
||||
><TD
|
||||
><TT
|
||||
CLASS="LITERAL"
|
||||
>[ ]</TT
|
||||
></TD
|
||||
><TD
|
||||
>Parenthesized expressions</TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
><TT
|
||||
CLASS="LITERAL"
|
||||
>< ></TT
|
||||
></TD
|
||||
><TD
|
||||
>Byte selection (low, high)</TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
><TT
|
||||
CLASS="LITERAL"
|
||||
>* /</TT
|
||||
></TD
|
||||
><TD
|
||||
>Multiply, divide</TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
><TT
|
||||
CLASS="LITERAL"
|
||||
>+ -</TT
|
||||
></TD
|
||||
><TD
|
||||
>Add, subtract</TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
><TT
|
||||
CLASS="LITERAL"
|
||||
>| & ^</TT
|
||||
></TD
|
||||
><TD
|
||||
>Bitwise OR, AND, XOR</TD
|
||||
></TR
|
||||
></TBODY
|
||||
></TABLE
|
||||
></DIV
|
||||
><P
|
||||
> Note that brackets, not parentheses, are used to group arithmetic
|
||||
operations. This is because parentheses are used for the indirect
|
||||
addressing modes, and it makes parsing much easier.
|
||||
</P
|
||||
><P
|
||||
> The code for this version of the code is
|
||||
in <A
|
||||
HREF="x493.html"
|
||||
><I
|
||||
><I
|
||||
>tutor6.oph</I
|
||||
></I
|
||||
></A
|
||||
>.
|
||||
</P
|
||||
></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"
|
||||
><A
|
||||
HREF="c329.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="c419.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
>Local variables and memory segments</TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
> </TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
>Advanced Memory Segments</TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,184 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>Advanced Memory Segments</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="Expressions"
|
||||
HREF="c371.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="The Solution"
|
||||
HREF="x430.html"></HEAD
|
||||
><BODY
|
||||
CLASS="CHAPTER"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="c371.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x430.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="CHAPTER"
|
||||
><H1
|
||||
><A
|
||||
NAME="AEN419"
|
||||
></A
|
||||
>Advanced Memory Segments</H1
|
||||
><P
|
||||
> This is the last section of the Ophis tutorial. By now we've
|
||||
covered the basics of every command in the assembler; in this
|
||||
final installment we show the full capabilities of
|
||||
the <TT
|
||||
CLASS="LITERAL"
|
||||
>.text</TT
|
||||
> and <TT
|
||||
CLASS="LITERAL"
|
||||
>.data</TT
|
||||
> commands
|
||||
as we produce a final set of Commodore 64 header files.
|
||||
</P
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN424"
|
||||
>The Problem</A
|
||||
></H1
|
||||
><P
|
||||
> Our <TT
|
||||
CLASS="LITERAL"
|
||||
>print'str</TT
|
||||
> routine
|
||||
in <A
|
||||
HREF="x493.html"
|
||||
><I
|
||||
><I
|
||||
>tutor6.oph</I
|
||||
></I
|
||||
></A
|
||||
> accesses
|
||||
memory locations $10 and $11 directly. We'd prefer to have
|
||||
symbolic names for them. This reprises our concerns back in
|
||||
<A
|
||||
HREF="c329.html"
|
||||
>the Chapter called <I
|
||||
>Local variables and memory segments</I
|
||||
></A
|
||||
> when we concluded that we wanted two
|
||||
separate program counters. Now we realize that we really need
|
||||
three; one for the text, one for the data, and one for the zero
|
||||
page data. And if we're going to allow three, we really should
|
||||
allow any number.
|
||||
</P
|
||||
></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"
|
||||
><A
|
||||
HREF="c371.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="x430.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
>Expressions</TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
> </TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
>The Solution</TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,186 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>Preface</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="Getting a copy of Ophis"
|
||||
HREF="x22.html"></HEAD
|
||||
><BODY
|
||||
CLASS="PREFACE"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x22.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="PREFACE"
|
||||
><H1
|
||||
><A
|
||||
NAME="AEN10"
|
||||
></A
|
||||
>Preface</H1
|
||||
><P
|
||||
> The Ophis project started on a lark back in 2001. My graduate
|
||||
studies required me to learn Perl and Python, and I'd been playing
|
||||
around with Commodore 64 emulators in my spare time, so I decided
|
||||
to learn both languages by writing a simple cross-assembler for
|
||||
the 6502 chip the C-64 used in both.
|
||||
</P
|
||||
><P
|
||||
> The Perl version was quickly abandoned, but the Python one slowly
|
||||
grew in scope and power over the years, and by 2005 was a very
|
||||
powerful, flexible macro assembler that saw more use than I'd
|
||||
expect. In 2007 I finally got around to implementing the last few
|
||||
features I really wanted and polishing it up for general release.
|
||||
</P
|
||||
><P
|
||||
> Part of that process has been formatting the various little
|
||||
tutorials and references I'd created into a single, unified
|
||||
document—the one you are now reading.
|
||||
</P
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN15"
|
||||
>Why <SPAN
|
||||
CLASS="QUOTE"
|
||||
>"Ophis"</SPAN
|
||||
>?</A
|
||||
></H1
|
||||
><P
|
||||
> It's actually a kind of a horrific pun. See, I was using Python
|
||||
at the time, and one of the things I had been hoping to do with
|
||||
the assembler was to produce working Apple II
|
||||
programs. <SPAN
|
||||
CLASS="QUOTE"
|
||||
>"Ophis"</SPAN
|
||||
> is Greek
|
||||
for <SPAN
|
||||
CLASS="QUOTE"
|
||||
>"snake"</SPAN
|
||||
>, and a number of traditions also use it
|
||||
as the actual <I
|
||||
CLASS="EMPHASIS"
|
||||
>name</I
|
||||
> of the serpent in the
|
||||
Garden of Eden. So, Pythons, snakes, and stories involving
|
||||
really old Apples all combined to name the assembler.
|
||||
</P
|
||||
></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"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="x22.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
>Programming with Ophis</TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
> </TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
>Getting a copy of Ophis</TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,206 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>Related commands and options</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="UP"
|
||||
TITLE="The basics"
|
||||
HREF="c35.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="Producing Commodore 64 programs"
|
||||
HREF="x51.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="Writing the actual code"
|
||||
HREF="x140.html"></HEAD
|
||||
><BODY
|
||||
CLASS="SECTION"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x51.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
>The basics</TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x140.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN119"
|
||||
>Related commands and options</A
|
||||
></H1
|
||||
><P
|
||||
> This code includes constants that are both in decimal and in
|
||||
hex. It is also possible to specify constants in octal, binary,
|
||||
or with an ASCII character.
|
||||
|
||||
<P
|
||||
></P
|
||||
><UL
|
||||
><LI
|
||||
><P
|
||||
>To specify decimal constants, simply write the number.</P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
>To specify hexadecimal constants, put a $ in front.</P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
>To specify octal constants, put a 0 (zero) in front.</P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
>To specify binary constants, put a % in front.</P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
>To specify ASCII constants, put an apostrophe in front.</P
|
||||
></LI
|
||||
></UL
|
||||
>
|
||||
|
||||
Example: 65 = $41 = 0101 = %1000001 = 'A
|
||||
</P
|
||||
><P
|
||||
> There are other commands besides <TT
|
||||
CLASS="LITERAL"
|
||||
>.byte</TT
|
||||
>
|
||||
and <TT
|
||||
CLASS="LITERAL"
|
||||
>.word</TT
|
||||
> to specify data. In particular,
|
||||
the <TT
|
||||
CLASS="LITERAL"
|
||||
>.dword</TT
|
||||
> command specifies four-byte values
|
||||
which some applications will find useful. Also, some linking
|
||||
formats (such as the <TT
|
||||
CLASS="FILENAME"
|
||||
>SID</TT
|
||||
> format) have
|
||||
header data in big-endian (high byte first) format.
|
||||
The <TT
|
||||
CLASS="LITERAL"
|
||||
>.wordbe</TT
|
||||
> and <TT
|
||||
CLASS="LITERAL"
|
||||
>.dwordbe</TT
|
||||
>
|
||||
directives provide a way to specify multibyte constants in
|
||||
big-endian formats cleanly.
|
||||
</P
|
||||
></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"
|
||||
><A
|
||||
HREF="x51.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="x140.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
>Producing Commodore 64 programs</TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="c35.html"
|
||||
ACCESSKEY="U"
|
||||
>Up</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
>Writing the actual code</TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,197 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>Writing the actual code</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="UP"
|
||||
TITLE="The basics"
|
||||
HREF="c35.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="Related commands and options"
|
||||
HREF="x119.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="Assembling the code"
|
||||
HREF="x149.html"></HEAD
|
||||
><BODY
|
||||
CLASS="SECTION"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x119.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
>The basics</TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x149.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN140"
|
||||
>Writing the actual code</A
|
||||
></H1
|
||||
><P
|
||||
> Now that we have our header information, let's actually write
|
||||
the <SPAN
|
||||
CLASS="QUOTE"
|
||||
>"Hello world"</SPAN
|
||||
> program. It's pretty
|
||||
short—a simple loop that steps through a hardcoded array
|
||||
until it reaches a 0 or outputs 256 characters. It then returns
|
||||
control to BASIC with an <TT
|
||||
CLASS="LITERAL"
|
||||
>RTS</TT
|
||||
> statement.
|
||||
</P
|
||||
><P
|
||||
> Each character in the array is passed as an argument to a
|
||||
subroutine at memory location $FFD2. This is part of the
|
||||
Commodore 64's BIOS software, which its development
|
||||
documentation calls the KERNAL. Location $FFD2 prints out the
|
||||
character corresponding to the character code in the
|
||||
accumulator.
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
> ldx #0
|
||||
loop: lda hello, x
|
||||
beq done
|
||||
jsr $ffd2
|
||||
inx
|
||||
bne loop
|
||||
done: rts
|
||||
|
||||
hello: .byte "HELLO, WORLD!", 0
|
||||
</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
> The complete, final source is available in
|
||||
the <A
|
||||
HREF="a454.html#TUTOR1-SRC"
|
||||
><I
|
||||
><I
|
||||
>tutor1.oph</I
|
||||
></I
|
||||
></A
|
||||
> file.
|
||||
</P
|
||||
></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"
|
||||
><A
|
||||
HREF="x119.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="x149.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
>Related commands and options</TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="c35.html"
|
||||
ACCESSKEY="U"
|
||||
>Up</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
>Assembling the code</TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,317 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>Assembling the code</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="UP"
|
||||
TITLE="The basics"
|
||||
HREF="c35.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="Writing the actual code"
|
||||
HREF="x140.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="Labels and aliases"
|
||||
HREF="c200.html"></HEAD
|
||||
><BODY
|
||||
CLASS="SECTION"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x140.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
>The basics</TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="c200.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN149"
|
||||
>Assembling the code</A
|
||||
></H1
|
||||
><P
|
||||
> The Ophis assembler is a collection of Python modules,
|
||||
controlled by a master script. On Windows, this should all
|
||||
have been combined into an executable
|
||||
file <B
|
||||
CLASS="COMMAND"
|
||||
>ophis.exe</B
|
||||
>; on other platforms, the
|
||||
Ophis modules should be in the library and
|
||||
the <B
|
||||
CLASS="COMMAND"
|
||||
>ophis</B
|
||||
> script should be in your path.
|
||||
Typing <B
|
||||
CLASS="COMMAND"
|
||||
>ophis</B
|
||||
> with no arguments should give a
|
||||
summary of available command line options.
|
||||
</P
|
||||
><DIV
|
||||
CLASS="TABLE"
|
||||
><A
|
||||
NAME="AEN155"
|
||||
></A
|
||||
><P
|
||||
><B
|
||||
>Table 2. Ophis Options</B
|
||||
></P
|
||||
><TABLE
|
||||
BORDER="1"
|
||||
BGCOLOR="#E0E0E0"
|
||||
CELLSPACING="0"
|
||||
CELLPADDING="4"
|
||||
CLASS="CALSTABLE"
|
||||
><THEAD
|
||||
><TR
|
||||
><TH
|
||||
ALIGN="CENTER"
|
||||
>Option</TH
|
||||
><TH
|
||||
ALIGN="CENTER"
|
||||
>Effect</TH
|
||||
></TR
|
||||
></THEAD
|
||||
><TBODY
|
||||
><TR
|
||||
><TD
|
||||
><CODE
|
||||
CLASS="OPTION"
|
||||
>-6510</CODE
|
||||
></TD
|
||||
><TD
|
||||
>Allows the 6510 undocumented opcodes as listed in the VICE documentation.</TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
><CODE
|
||||
CLASS="OPTION"
|
||||
>-65c02</CODE
|
||||
></TD
|
||||
><TD
|
||||
>Allows opcodes and addressing modes added by the 65C02.</TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
><CODE
|
||||
CLASS="OPTION"
|
||||
>-v 0</CODE
|
||||
></TD
|
||||
><TD
|
||||
>Quiet operation. Only reports errors.</TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
><CODE
|
||||
CLASS="OPTION"
|
||||
>-v 1</CODE
|
||||
></TD
|
||||
><TD
|
||||
>Default operation. Reports files as they are loaded, and gives statistics on the final output.</TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
><CODE
|
||||
CLASS="OPTION"
|
||||
>-v 2</CODE
|
||||
></TD
|
||||
><TD
|
||||
>Verbose operation. Names each assembler pass as it runs.</TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
><CODE
|
||||
CLASS="OPTION"
|
||||
>-v 3</CODE
|
||||
></TD
|
||||
><TD
|
||||
>Debug operation: Dumps the entire IR after each pass.</TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
><CODE
|
||||
CLASS="OPTION"
|
||||
>-v 4</CODE
|
||||
></TD
|
||||
><TD
|
||||
>Full debug operation: Dumps the entire IR and symbol table after each pass.</TD
|
||||
></TR
|
||||
></TBODY
|
||||
></TABLE
|
||||
></DIV
|
||||
><P
|
||||
> The only options Ophis demands are an input file and an output
|
||||
file. Here's a sample session, assembling the tutorial file
|
||||
here:
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="SCREEN"
|
||||
>localhost$ ophis tutor1.oph tutor1.prg -v 2
|
||||
Loading tutor1.oph
|
||||
Running: Macro definition pass
|
||||
Running: Macro expansion pass
|
||||
Running: Label initialization pass
|
||||
Fixpoint failed, looping back
|
||||
Running: Label initialization pass
|
||||
Running: Circularity check pass
|
||||
Running: Expression checking pass
|
||||
Running: Easy addressing modes pass
|
||||
Running: Label Update Pass
|
||||
Fixpoint failed, looping back
|
||||
Running: Label Update Pass
|
||||
Running: Instruction Collapse Pass
|
||||
Running: Mode Normalization pass
|
||||
Running: Label Update Pass
|
||||
Running: Assembler
|
||||
Assembly complete: 45 bytes output (14 code, 29 data, 2 filler)
|
||||
</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
> If your emulator can run <TT
|
||||
CLASS="FILENAME"
|
||||
>PRG</TT
|
||||
> files
|
||||
directly, this file will now run (and
|
||||
print <SAMP
|
||||
CLASS="COMPUTEROUTPUT"
|
||||
>HELLO, WORLD!</SAMP
|
||||
>) as many
|
||||
times as you type <KBD
|
||||
CLASS="USERINPUT"
|
||||
>RUN</KBD
|
||||
>. Otherwise, use
|
||||
a <TT
|
||||
CLASS="FILENAME"
|
||||
>D64</TT
|
||||
> management utility to put
|
||||
the <TT
|
||||
CLASS="FILENAME"
|
||||
>PRG</TT
|
||||
> on a <TT
|
||||
CLASS="FILENAME"
|
||||
>D64</TT
|
||||
>, then
|
||||
load and run the file off that.
|
||||
</P
|
||||
></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"
|
||||
><A
|
||||
HREF="x140.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="c200.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
>Writing the actual code</TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="c35.html"
|
||||
ACCESSKEY="U"
|
||||
>Up</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
>Labels and aliases</TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,198 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>Anonymous labels</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="UP"
|
||||
TITLE="Labels and aliases"
|
||||
HREF="c200.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="Labels and aliases"
|
||||
HREF="c200.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="Aliasing"
|
||||
HREF="x225.html"></HEAD
|
||||
><BODY
|
||||
CLASS="SECTION"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="c200.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
>Labels and aliases</TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x225.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN214"
|
||||
>Anonymous labels</A
|
||||
></H1
|
||||
><P
|
||||
> Anonymous labels are a way to handle short-ranged branches
|
||||
without having to come up with names for the then and else
|
||||
branches, for brief loops, and other such purposes. To define
|
||||
an anonymous label, use an asterisk. To refer to an anonymous
|
||||
label, use a series of <TT
|
||||
CLASS="LITERAL"
|
||||
>+</TT
|
||||
>
|
||||
or <TT
|
||||
CLASS="LITERAL"
|
||||
>-</TT
|
||||
> signs. <TT
|
||||
CLASS="LITERAL"
|
||||
>+</TT
|
||||
> refers to
|
||||
the next anonymous label, <TT
|
||||
CLASS="LITERAL"
|
||||
>++</TT
|
||||
> the label
|
||||
after that, etc. Likewise, <TT
|
||||
CLASS="LITERAL"
|
||||
>-</TT
|
||||
> is the most
|
||||
recently defined label, <TT
|
||||
CLASS="LITERAL"
|
||||
>--</TT
|
||||
> the one before
|
||||
that, and so on. The main body of the Hello World program
|
||||
with anonymous labels would be:
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
> ldx #0
|
||||
* lda hello, x
|
||||
beq +
|
||||
jsr $ffd2
|
||||
inx
|
||||
bne -
|
||||
* rts</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
> It is worth noting that anonymous labels are globally available.
|
||||
They are not temporary labels, and they ignore scoping
|
||||
restrictions.
|
||||
</P
|
||||
></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"
|
||||
><A
|
||||
HREF="c200.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="x225.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
>Labels and aliases</TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="c200.html"
|
||||
ACCESSKEY="U"
|
||||
>Up</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
>Aliasing</TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,197 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>Getting a copy of Ophis</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="UP"
|
||||
TITLE="Preface"
|
||||
HREF="f10.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="Preface"
|
||||
HREF="f10.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="The basics"
|
||||
HREF="c35.html"></HEAD
|
||||
><BODY
|
||||
CLASS="SECTION"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="f10.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
>Preface</TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="c35.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN22"
|
||||
>Getting a copy of Ophis</A
|
||||
></H1
|
||||
><P
|
||||
> If you're reading this as part of the Ophis install, you clearly
|
||||
already have it. If not, as of this writing the homepage for
|
||||
the Ophis assembler
|
||||
is <A
|
||||
HREF="http://hkn.eecs.berkeley.edu/~mcmartin/ophis/"
|
||||
TARGET="_top"
|
||||
>http://hkn.eecs.berkeley.edu/~mcmartin/ophis/</A
|
||||
>. If
|
||||
this is out-of-date, a Web search on <SPAN
|
||||
CLASS="QUOTE"
|
||||
>"Ophis 6502
|
||||
assembler"</SPAN
|
||||
> (without the quotation marks) should yield its
|
||||
page.
|
||||
</P
|
||||
><P
|
||||
> Ophis is written entirely in Python and packaged using the
|
||||
distutils. The default installation script on Unix and Mac OS X
|
||||
systems should put the files where they need to go. If you are
|
||||
running it locally, you will need to install
|
||||
the <TT
|
||||
CLASS="LITERAL"
|
||||
>Ophis</TT
|
||||
> package somewhere in your Python
|
||||
package path, and then put the <B
|
||||
CLASS="COMMAND"
|
||||
>ophis</B
|
||||
> script
|
||||
somewhere in your path.
|
||||
</P
|
||||
><P
|
||||
> Windows users that have Python installed can use the same source
|
||||
distributions that the other operating systems
|
||||
use; <B
|
||||
CLASS="COMMAND"
|
||||
>ophis.bat</B
|
||||
> will arrange the environment
|
||||
variables accordingly and invoke the main script.
|
||||
</P
|
||||
><P
|
||||
> If you are on Windows and do not have Python installed, a
|
||||
prepackaged system made with <B
|
||||
CLASS="COMMAND"
|
||||
>py2exe</B
|
||||
> is also
|
||||
available. The default Windows installer will use this. In
|
||||
this case, all you need to do is
|
||||
have <B
|
||||
CLASS="COMMAND"
|
||||
>ophis.exe</B
|
||||
> in your path.
|
||||
</P
|
||||
></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"
|
||||
><A
|
||||
HREF="f10.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="c35.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
>Preface</TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="f10.html"
|
||||
ACCESSKEY="U"
|
||||
>Up</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
>The basics</TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,203 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>Aliasing</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="UP"
|
||||
TITLE="Labels and aliases"
|
||||
HREF="c200.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="Anonymous labels"
|
||||
HREF="x214.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="Headers, Libraries, and Macros"
|
||||
HREF="c236.html"></HEAD
|
||||
><BODY
|
||||
CLASS="SECTION"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x214.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
>Labels and aliases</TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="c236.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN225"
|
||||
>Aliasing</A
|
||||
></H1
|
||||
><P
|
||||
> Rather the reverse of anonymous labels, aliases are names
|
||||
given to specific memory locations. These make it easier to
|
||||
keep track of important constants or locations. The KERNAL
|
||||
routines are a good example of constants that deserve names.
|
||||
To assign the traditional name <TT
|
||||
CLASS="LITERAL"
|
||||
>chrout</TT
|
||||
> to
|
||||
the routine at $FFD2, simply give the directive:
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.alias chrout $ffd2</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
>And change the <KBD
|
||||
CLASS="USERINPUT"
|
||||
>jsr</KBD
|
||||
> command
|
||||
to:</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
> jsr chrout</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
> The final version of the code is in <A
|
||||
HREF="x461.html"
|
||||
><I
|
||||
><I
|
||||
>tutor2.oph</I
|
||||
></I
|
||||
></A
|
||||
>. It should
|
||||
assemble to exactly the same program as <A
|
||||
HREF="a454.html#TUTOR1-SRC"
|
||||
><I
|
||||
><I
|
||||
>tutor1.oph</I
|
||||
></I
|
||||
></A
|
||||
>.
|
||||
</P
|
||||
></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"
|
||||
><A
|
||||
HREF="x214.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="c236.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
>Anonymous labels</TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="c200.html"
|
||||
ACCESSKEY="U"
|
||||
>Up</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
>Headers, Libraries, and Macros</TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,289 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>Macros</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="UP"
|
||||
TITLE="Headers, Libraries, and Macros"
|
||||
HREF="c236.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="Headers, Libraries, and Macros"
|
||||
HREF="c236.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="Example code"
|
||||
HREF="x287.html"></HEAD
|
||||
><BODY
|
||||
CLASS="SECTION"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="c236.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
>Headers, Libraries, and Macros</TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x287.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN257"
|
||||
>Macros</A
|
||||
></H1
|
||||
><P
|
||||
> A macro is a way of expressing a lot of code or data with a
|
||||
simple shorthand. It's also usually configurable. Traditional
|
||||
macro systems such as C's <TT
|
||||
CLASS="LITERAL"
|
||||
>#define</TT
|
||||
> mechanic
|
||||
use <I
|
||||
CLASS="EMPHASIS"
|
||||
>textual replacement</I
|
||||
>: a macro is
|
||||
expanded before any evaluation or even parsing occurs.
|
||||
</P
|
||||
><P
|
||||
> In contrast, Ophis's macro system uses a <I
|
||||
CLASS="EMPHASIS"
|
||||
>call by
|
||||
value</I
|
||||
> approach where the arguments to macros are
|
||||
evaluated to bytes or words before being inserted into the macro
|
||||
body. This produces effects much closer to those of a
|
||||
traditional function call. A more detailed discussion of the
|
||||
tradeoffs may be found in <A
|
||||
HREF="a505.html"
|
||||
>the Appendix called <I
|
||||
>Ophis Command Reference</I
|
||||
></A
|
||||
>.
|
||||
</P
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H2
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN265"
|
||||
>Macro definitions</A
|
||||
></H2
|
||||
><P
|
||||
> A macro definition is a set of statements between
|
||||
a <TT
|
||||
CLASS="LITERAL"
|
||||
>.macro</TT
|
||||
> statement and
|
||||
a <TT
|
||||
CLASS="LITERAL"
|
||||
>.macend</TT
|
||||
> statement.
|
||||
The <TT
|
||||
CLASS="LITERAL"
|
||||
>.macro</TT
|
||||
> statement also names the macro
|
||||
being defined.
|
||||
</P
|
||||
><P
|
||||
> No global or anonymous labels may be defined inside a macro:
|
||||
temporary labels only persist in the macro expansion itself.
|
||||
(Each macro body has its own scope.)
|
||||
</P
|
||||
><P
|
||||
> Arguments to macros are referred to by number: the first is
|
||||
<TT
|
||||
CLASS="LITERAL"
|
||||
>_1</TT
|
||||
>, the second <TT
|
||||
CLASS="LITERAL"
|
||||
>_2</TT
|
||||
>, and so on.
|
||||
</P
|
||||
><P
|
||||
> Here's a macro that encapsulates the printing routine in our
|
||||
<SPAN
|
||||
CLASS="QUOTE"
|
||||
>"Hello World"</SPAN
|
||||
> program, with an argument being the
|
||||
address of the string to print:
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.macro print
|
||||
ldx #0
|
||||
_loop: lda _1, x
|
||||
beq _done
|
||||
jsr chrout
|
||||
inx
|
||||
bne _loop
|
||||
_done:
|
||||
.macend</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H2
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN278"
|
||||
>Macro invocations</A
|
||||
></H2
|
||||
><P
|
||||
> Macros may be invoked in two ways: one that looks like a
|
||||
directive, and one that looks like an instruction.
|
||||
</P
|
||||
><P
|
||||
> The most common way to invoke a macro is to backquote the name
|
||||
of the macro. It is also possible to use
|
||||
the <TT
|
||||
CLASS="LITERAL"
|
||||
>.invoke</TT
|
||||
> command. These commands look
|
||||
like this:
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>`print msg
|
||||
.invoke print msg</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
> Arguments are passed to the macro as a comma-separated list.
|
||||
They must all be expressions that evaluate to byte or word
|
||||
values—a mechanism similar to <TT
|
||||
CLASS="LITERAL"
|
||||
>.alias</TT
|
||||
>
|
||||
is used to assign their values to the <TT
|
||||
CLASS="LITERAL"
|
||||
>_n</TT
|
||||
>
|
||||
names.
|
||||
</P
|
||||
></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"
|
||||
><A
|
||||
HREF="c236.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="x287.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
>Headers, Libraries, and Macros</TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="c236.html"
|
||||
ACCESSKEY="U"
|
||||
>Up</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
>Example code</TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,161 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>Example code</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="UP"
|
||||
TITLE="Headers, Libraries, and Macros"
|
||||
HREF="c236.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="Macros"
|
||||
HREF="x257.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="Character maps"
|
||||
HREF="c292.html"></HEAD
|
||||
><BODY
|
||||
CLASS="SECTION"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x257.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
>Headers, Libraries, and Macros</TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="c292.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN287"
|
||||
>Example code</A
|
||||
></H1
|
||||
><P
|
||||
> <A
|
||||
HREF="x473.html"
|
||||
><I
|
||||
><I
|
||||
>tutor3.oph</I
|
||||
></I
|
||||
></A
|
||||
> expands our
|
||||
running example, including the code above and also defining a
|
||||
new macro <TT
|
||||
CLASS="LITERAL"
|
||||
>greet</TT
|
||||
> that takes a string argument
|
||||
and prints a greeting to it. It then greets far too many
|
||||
targets.
|
||||
</P
|
||||
></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"
|
||||
><A
|
||||
HREF="x257.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="c292.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
>Macros</TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="c236.html"
|
||||
ACCESSKEY="U"
|
||||
>Up</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
>Character maps</TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,295 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>The Solution</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="UP"
|
||||
TITLE="Advanced Memory Segments"
|
||||
HREF="c419.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="Advanced Memory Segments"
|
||||
HREF="c419.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="Where to go from here"
|
||||
HREF="x449.html"></HEAD
|
||||
><BODY
|
||||
CLASS="SECTION"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="c419.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
>Advanced Memory Segments</TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x449.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN430"
|
||||
>The Solution</A
|
||||
></H1
|
||||
><P
|
||||
> The <TT
|
||||
CLASS="LITERAL"
|
||||
>.data</TT
|
||||
> and <TT
|
||||
CLASS="LITERAL"
|
||||
>.text</TT
|
||||
>
|
||||
commands can take a label name after them—this names a new
|
||||
segment. We'll define a new segment
|
||||
called <TT
|
||||
CLASS="LITERAL"
|
||||
>zp</TT
|
||||
> (for <SPAN
|
||||
CLASS="QUOTE"
|
||||
>"zero page"</SPAN
|
||||
>) and
|
||||
have our zero-page variables be placed there. We can't actually
|
||||
use the default origin of $0000 here either, though, because the
|
||||
Commodore 64 reserves memory locations 0 and 1 to control its
|
||||
memory mappers:
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.data zp
|
||||
.org $0002</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
> Now, actually, the rest of the zero page is reserved too:
|
||||
locations $02-$7F are used by the BASIC interpreter, and
|
||||
locations $80-$FF are used by the KERNAL. We don't need the
|
||||
BASIC interpreter, though, so we can back up all of $02-$7F at
|
||||
the start of our program and restore it all when we're done:
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.scope
|
||||
; Cache BASIC's zero page at top of available RAM.
|
||||
ldx #$7E
|
||||
* lda $01, x
|
||||
sta $CF81, x
|
||||
dex
|
||||
bne -
|
||||
|
||||
jsr _main
|
||||
|
||||
; Restore BASIC's zero page and return control.
|
||||
|
||||
ldx #$7E
|
||||
* lda $CF81, x
|
||||
sta $01, x
|
||||
dex
|
||||
bne -
|
||||
rts
|
||||
|
||||
_main:
|
||||
; _main points at the start of the real program,
|
||||
; which is actually outside of this scope
|
||||
.scend</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
> The new, improved header file is <A
|
||||
HREF="x497.html"
|
||||
><I
|
||||
><I
|
||||
>c64-2.oph</I
|
||||
></I
|
||||
></A
|
||||
>.
|
||||
</P
|
||||
><P
|
||||
> Our <TT
|
||||
CLASS="LITERAL"
|
||||
>print'str</TT
|
||||
> routine is then rewritten to
|
||||
declare and use a zero-page variable, like so:
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>; PRINTSTR routine. Accumulator stores the low byte of the address,
|
||||
; X register stores the high byte. Destroys the values of $10 and
|
||||
; $11.
|
||||
|
||||
.scope
|
||||
.data zp
|
||||
.space _ptr 2
|
||||
.text
|
||||
printstr:
|
||||
sta _ptr
|
||||
stx _ptr+1
|
||||
ldy #$00
|
||||
_lp: lda (_ptr),y
|
||||
beq _done
|
||||
jsr chrout
|
||||
iny
|
||||
bne _lp
|
||||
_done: rts
|
||||
.scend</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
> Also, we ought to put in an extra check to make sure our
|
||||
zero-page allocations don't overflow, either:
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.data zp
|
||||
.checkpc $80</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
> That concludes our tour. The final source file
|
||||
is <A
|
||||
HREF="x501.html"
|
||||
><I
|
||||
><I
|
||||
>tutor7.oph</I
|
||||
></I
|
||||
></A
|
||||
>.
|
||||
</P
|
||||
></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"
|
||||
><A
|
||||
HREF="c419.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="x449.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
>Advanced Memory Segments</TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="c419.html"
|
||||
ACCESSKEY="U"
|
||||
>Up</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
>Where to go from here</TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,162 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>Where to go from here</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="UP"
|
||||
TITLE="Advanced Memory Segments"
|
||||
HREF="c419.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="The Solution"
|
||||
HREF="x430.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="Example Programs"
|
||||
HREF="a454.html"></HEAD
|
||||
><BODY
|
||||
CLASS="SECTION"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x430.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
>Advanced Memory Segments</TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="a454.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN449"
|
||||
>Where to go from here</A
|
||||
></H1
|
||||
><P
|
||||
> This tutorial has touched on everything that the assembler can
|
||||
do, but it's not really well organized as a
|
||||
reference. <A
|
||||
HREF="a505.html"
|
||||
>the Appendix called <I
|
||||
>Ophis Command Reference</I
|
||||
></A
|
||||
> is a better place to look
|
||||
up matters of syntax or consult lists of available commands.
|
||||
</P
|
||||
><P
|
||||
> If you're looking for projects to undertake, the Commodore 64
|
||||
and Atari 2600 development communities are both very strong, and
|
||||
the Apple II and NES development communities are still alive and
|
||||
well as well. There's an annual Minigame Competition that's
|
||||
always looking for new entries.
|
||||
</P
|
||||
></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"
|
||||
><A
|
||||
HREF="x430.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="a454.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
>The Solution</TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="c419.html"
|
||||
ACCESSKEY="U"
|
||||
>Up</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
>Example Programs</TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,183 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>tutor2.oph</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="UP"
|
||||
TITLE="Example Programs"
|
||||
HREF="a454.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="Example Programs"
|
||||
HREF="a454.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="c64-1.oph"
|
||||
HREF="x465.html"></HEAD
|
||||
><BODY
|
||||
CLASS="SECTION"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="a454.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
>Example Programs</TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x465.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="TUTOR2-SRC"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor2.oph</TT
|
||||
></A
|
||||
></H1
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.word $0801
|
||||
.org $0801
|
||||
|
||||
.scope
|
||||
.word _next, 10 ; Next line and current line number
|
||||
.byte $9e," 2064",0 ; SYS 2064
|
||||
_next: .word 0 ; End of program
|
||||
.scend
|
||||
|
||||
.advance 2064
|
||||
|
||||
.alias chrout $ffd2
|
||||
|
||||
ldx #0
|
||||
* lda hello, x
|
||||
beq +
|
||||
jsr chrout
|
||||
inx
|
||||
bne -
|
||||
* rts
|
||||
|
||||
hello: .byte "HELLO, WORLD!", 0</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></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"
|
||||
><A
|
||||
HREF="a454.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="x465.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
>Example Programs</TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="a454.html"
|
||||
ACCESSKEY="U"
|
||||
>Up</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>c64-1.oph</TT
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,176 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>c64-1.oph</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="UP"
|
||||
TITLE="Example Programs"
|
||||
HREF="a454.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="tutor2.oph"
|
||||
HREF="x461.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="kernal.oph"
|
||||
HREF="x469.html"></HEAD
|
||||
><BODY
|
||||
CLASS="SECTION"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x461.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
>Example Programs</TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x469.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="C64-1-SRC"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>c64-1.oph</TT
|
||||
></A
|
||||
></H1
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.word $0801
|
||||
.org $0801
|
||||
|
||||
.scope
|
||||
.word _next, 10 ; Next line and current line number
|
||||
.byte $9e," 2064",0 ; SYS 2064
|
||||
_next: .word 0 ; End of program
|
||||
.scend
|
||||
|
||||
.advance 2064
|
||||
|
||||
.require "kernal.oph"</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></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"
|
||||
><A
|
||||
HREF="x461.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="x469.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor2.oph</TT
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="a454.html"
|
||||
ACCESSKEY="U"
|
||||
>Up</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>kernal.oph</TT
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,231 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>kernal.oph</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="UP"
|
||||
TITLE="Example Programs"
|
||||
HREF="a454.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="c64-1.oph"
|
||||
HREF="x465.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="tutor3.oph"
|
||||
HREF="x473.html"></HEAD
|
||||
><BODY
|
||||
CLASS="SECTION"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x465.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
>Example Programs</TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x473.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="KERNAL-SRC"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>kernal.oph</TT
|
||||
></A
|
||||
></H1
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>; KERNAL routine aliases (C64)
|
||||
|
||||
.alias acptr $ffa5
|
||||
.alias chkin $ffc6
|
||||
.alias chkout $ffc9
|
||||
.alias chrin $ffcf
|
||||
.alias chrout $ffd2
|
||||
.alias ciout $ffa8
|
||||
.alias cint $ff81
|
||||
.alias clall $ffe7
|
||||
.alias close $ffc3
|
||||
.alias clrchn $ffcc
|
||||
.alias getin $ffe4
|
||||
.alias iobase $fff3
|
||||
.alias ioinit $ff84
|
||||
.alias listen $ffb1
|
||||
.alias load $ffd5
|
||||
.alias membot $ff9c
|
||||
.alias memtop $ff99
|
||||
.alias open $ffc0
|
||||
.alias plot $fff0
|
||||
.alias ramtas $ff87
|
||||
.alias rdtim $ffde
|
||||
.alias readst $ffb7
|
||||
.alias restor $ff8a
|
||||
.alias save $ffd8
|
||||
.alias scnkey $ff9f
|
||||
.alias screen $ffed
|
||||
.alias second $ff93
|
||||
.alias setlfs $ffba
|
||||
.alias setmsg $ff90
|
||||
.alias setnam $ffbd
|
||||
.alias settim $ffdb
|
||||
.alias settmo $ffa2
|
||||
.alias stop $ffe1
|
||||
.alias talk $ffb4
|
||||
.alias tksa $ff96
|
||||
.alias udtim $ffea
|
||||
.alias unlsn $ffae
|
||||
.alias untlk $ffab
|
||||
.alias vector $ff8d
|
||||
|
||||
; Character codes for the colors.
|
||||
.alias color'0 144
|
||||
.alias color'1 5
|
||||
.alias color'2 28
|
||||
.alias color'3 159
|
||||
.alias color'4 156
|
||||
.alias color'5 30
|
||||
.alias color'6 31
|
||||
.alias color'7 158
|
||||
.alias color'8 129
|
||||
.alias color'9 149
|
||||
.alias color'10 150
|
||||
.alias color'11 151
|
||||
.alias color'12 152
|
||||
.alias color'13 153
|
||||
.alias color'14 154
|
||||
.alias color'15 155
|
||||
|
||||
; ...and reverse video
|
||||
.alias reverse'on 18
|
||||
.alias reverse'off 146
|
||||
|
||||
; ...and character set
|
||||
.alias upper'case 142
|
||||
.alias lower'case 14</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></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"
|
||||
><A
|
||||
HREF="x465.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="x473.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>c64-1.oph</TT
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="a454.html"
|
||||
ACCESSKEY="U"
|
||||
>Up</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor3.oph</TT
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,209 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>tutor3.oph</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="UP"
|
||||
TITLE="Example Programs"
|
||||
HREF="a454.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="kernal.oph"
|
||||
HREF="x469.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="tutor4a.oph"
|
||||
HREF="x477.html"></HEAD
|
||||
><BODY
|
||||
CLASS="SECTION"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x469.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
>Example Programs</TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x477.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="TUTOR3-SRC"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor3.oph</TT
|
||||
></A
|
||||
></H1
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.include "c64-1.oph"
|
||||
|
||||
.macro print
|
||||
ldx #0
|
||||
_loop: lda _1, x
|
||||
beq _done
|
||||
jsr chrout
|
||||
inx
|
||||
bne _loop
|
||||
_done:
|
||||
.macend
|
||||
|
||||
.macro greet
|
||||
`print hello1
|
||||
`print _1
|
||||
`print hello2
|
||||
.macend
|
||||
|
||||
lda #147
|
||||
jsr chrout
|
||||
`greet target1
|
||||
`greet target2
|
||||
`greet target3
|
||||
`greet target4
|
||||
`greet target5
|
||||
`greet target6
|
||||
`greet target7
|
||||
`greet target8
|
||||
`greet target9
|
||||
`greet target10
|
||||
rts
|
||||
|
||||
hello1: .byte "HELLO, ",0
|
||||
hello2: .byte "!", 13, 0
|
||||
|
||||
target1: .byte "PROGRAMMER", 0
|
||||
target2: .byte "ROOM", 0
|
||||
target3: .byte "BUILDING", 0
|
||||
target4: .byte "NEIGHBORHOOD", 0
|
||||
target5: .byte "CITY", 0
|
||||
target6: .byte "NATION", 0
|
||||
target7: .byte "WORLD", 0
|
||||
target8: .byte "SOLAR SYSTEM", 0
|
||||
target9: .byte "GALAXY", 0
|
||||
target10: .byte "UNIVERSE", 0</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></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"
|
||||
><A
|
||||
HREF="x469.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="x477.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>kernal.oph</TT
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="a454.html"
|
||||
ACCESSKEY="U"
|
||||
>Up</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor4a.oph</TT
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,230 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>tutor4a.oph</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="UP"
|
||||
TITLE="Example Programs"
|
||||
HREF="a454.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="tutor3.oph"
|
||||
HREF="x473.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="tutor4b.oph"
|
||||
HREF="x481.html"></HEAD
|
||||
><BODY
|
||||
CLASS="SECTION"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x473.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
>Example Programs</TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x481.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="TUTOR4A-SRC"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor4a.oph</TT
|
||||
></A
|
||||
></H1
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.include "c64-1.oph"
|
||||
|
||||
.macro print
|
||||
ldx #0
|
||||
_loop: lda _1, x
|
||||
beq _done
|
||||
jsr chrout
|
||||
inx
|
||||
bne _loop
|
||||
_done:
|
||||
.macend
|
||||
|
||||
.macro greet
|
||||
lda #30
|
||||
jsr delay
|
||||
`print hello1
|
||||
`print _1
|
||||
`print hello2
|
||||
.macend
|
||||
|
||||
lda #147
|
||||
jsr chrout
|
||||
`greet target1
|
||||
`greet target2
|
||||
`greet target3
|
||||
`greet target4
|
||||
`greet target5
|
||||
`greet target6
|
||||
`greet target7
|
||||
`greet target8
|
||||
`greet target9
|
||||
`greet target10
|
||||
rts
|
||||
|
||||
hello1: .byte "HELLO, ",0
|
||||
hello2: .byte "!", 13, 0
|
||||
|
||||
target1: .byte "PROGRAMMER", 0
|
||||
target2: .byte "ROOM", 0
|
||||
target3: .byte "BUILDING", 0
|
||||
target4: .byte "NEIGHBORHOOD", 0
|
||||
target5: .byte "CITY", 0
|
||||
target6: .byte "NATION", 0
|
||||
target7: .byte "WORLD", 0
|
||||
target8: .byte "SOLAR SYSTEM", 0
|
||||
target9: .byte "GALAXY", 0
|
||||
target10: .byte "UNIVERSE", 0
|
||||
|
||||
; DELAY routine. Executes 2,560*(A) NOP statements.
|
||||
delay: tax
|
||||
ldy #00
|
||||
* nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
iny
|
||||
bne -
|
||||
dex
|
||||
bne -
|
||||
rts</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></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"
|
||||
><A
|
||||
HREF="x473.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="x481.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor3.oph</TT
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="a454.html"
|
||||
ACCESSKEY="U"
|
||||
>Up</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor4b.oph</TT
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,232 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>tutor4b.oph</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="UP"
|
||||
TITLE="Example Programs"
|
||||
HREF="a454.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="tutor4a.oph"
|
||||
HREF="x477.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="tutor4c.oph"
|
||||
HREF="x485.html"></HEAD
|
||||
><BODY
|
||||
CLASS="SECTION"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x477.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
>Example Programs</TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x485.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="TUTOR4B-SRC"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor4b.oph</TT
|
||||
></A
|
||||
></H1
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.include "c64-1.oph"
|
||||
|
||||
.macro print
|
||||
ldx #0
|
||||
_loop: lda _1, x
|
||||
beq _done
|
||||
jsr chrout
|
||||
inx
|
||||
bne _loop
|
||||
_done:
|
||||
.macend
|
||||
|
||||
.macro greet
|
||||
lda #30
|
||||
jsr delay
|
||||
`print hello1
|
||||
`print _1
|
||||
`print hello2
|
||||
.macend
|
||||
|
||||
lda #147
|
||||
jsr chrout
|
||||
lda #lower'case
|
||||
jsr chrout
|
||||
`greet target1
|
||||
`greet target2
|
||||
`greet target3
|
||||
`greet target4
|
||||
`greet target5
|
||||
`greet target6
|
||||
`greet target7
|
||||
`greet target8
|
||||
`greet target9
|
||||
`greet target10
|
||||
rts
|
||||
|
||||
hello1: .byte "Hello, ",0
|
||||
hello2: .byte "!", 13, 0
|
||||
|
||||
target1: .byte "programmer", 0
|
||||
target2: .byte "room", 0
|
||||
target3: .byte "building", 0
|
||||
target4: .byte "neighborhood", 0
|
||||
target5: .byte "city", 0
|
||||
target6: .byte "nation", 0
|
||||
target7: .byte "world", 0
|
||||
target8: .byte "Solar System", 0
|
||||
target9: .byte "Galaxy", 0
|
||||
target10: .byte "Universe", 0
|
||||
|
||||
; DELAY routine. Executes 2,560*(A) NOP statements.
|
||||
delay: tax
|
||||
ldy #00
|
||||
* nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
iny
|
||||
bne -
|
||||
dex
|
||||
bne -
|
||||
rts</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></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"
|
||||
><A
|
||||
HREF="x477.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="x485.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor4a.oph</TT
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="a454.html"
|
||||
ACCESSKEY="U"
|
||||
>Up</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor4c.oph</TT
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,235 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>tutor4c.oph</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="UP"
|
||||
TITLE="Example Programs"
|
||||
HREF="a454.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="tutor4b.oph"
|
||||
HREF="x481.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="tutor5.oph"
|
||||
HREF="x489.html"></HEAD
|
||||
><BODY
|
||||
CLASS="SECTION"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x481.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
>Example Programs</TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x489.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="TUTOR4C-SRC"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor4c.oph</TT
|
||||
></A
|
||||
></H1
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.include "c64-1.oph"
|
||||
|
||||
.macro print
|
||||
ldx #0
|
||||
_loop: lda _1, x
|
||||
beq _done
|
||||
jsr chrout
|
||||
inx
|
||||
bne _loop
|
||||
_done:
|
||||
.macend
|
||||
|
||||
.macro greet
|
||||
lda #30
|
||||
jsr delay
|
||||
`print hello1
|
||||
`print _1
|
||||
`print hello2
|
||||
.macend
|
||||
|
||||
lda #147
|
||||
jsr chrout
|
||||
lda #lower'case
|
||||
jsr chrout
|
||||
`greet target1
|
||||
`greet target2
|
||||
`greet target3
|
||||
`greet target4
|
||||
`greet target5
|
||||
`greet target6
|
||||
`greet target7
|
||||
`greet target8
|
||||
`greet target9
|
||||
`greet target10
|
||||
rts
|
||||
|
||||
.charmap 'A, "abcdefghijklmnopqrstuvwxyz"
|
||||
.charmap 'a, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
||||
hello1: .byte "Hello, ",0
|
||||
hello2: .byte "!", 13, 0
|
||||
|
||||
target1: .byte "programmer", 0
|
||||
target2: .byte "room", 0
|
||||
target3: .byte "building", 0
|
||||
target4: .byte "neighborhood", 0
|
||||
target5: .byte "city", 0
|
||||
target6: .byte "nation", 0
|
||||
target7: .byte "world", 0
|
||||
target8: .byte "Solar System", 0
|
||||
target9: .byte "Galaxy", 0
|
||||
target10: .byte "Universe", 0
|
||||
|
||||
; DELAY routine. Executes 2,560*(A) NOP statements.
|
||||
delay: tax
|
||||
ldy #00
|
||||
* nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
iny
|
||||
bne -
|
||||
dex
|
||||
bne -
|
||||
rts</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></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"
|
||||
><A
|
||||
HREF="x481.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="x489.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor4b.oph</TT
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="a454.html"
|
||||
ACCESSKEY="U"
|
||||
>Up</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor5.oph</TT
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,239 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>tutor5.oph</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="UP"
|
||||
TITLE="Example Programs"
|
||||
HREF="a454.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="tutor4c.oph"
|
||||
HREF="x485.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="tutor6.oph"
|
||||
HREF="x493.html"></HEAD
|
||||
><BODY
|
||||
CLASS="SECTION"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x485.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
>Example Programs</TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x493.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="TUTOR5-SRC"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor5.oph</TT
|
||||
></A
|
||||
></H1
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.include "c64-1.oph"
|
||||
|
||||
.data
|
||||
.org $C000
|
||||
.text
|
||||
|
||||
.macro print
|
||||
ldx #0
|
||||
_loop: lda _1, x
|
||||
beq _done
|
||||
jsr chrout
|
||||
inx
|
||||
bne _loop
|
||||
_done:
|
||||
.macend
|
||||
|
||||
.macro greet
|
||||
lda #30
|
||||
jsr delay
|
||||
`print hello1
|
||||
`print _1
|
||||
`print hello2
|
||||
.macend
|
||||
|
||||
lda #147
|
||||
jsr chrout
|
||||
`greet target1
|
||||
`greet target2
|
||||
`greet target3
|
||||
`greet target4
|
||||
`greet target5
|
||||
`greet target6
|
||||
`greet target7
|
||||
`greet target8
|
||||
`greet target9
|
||||
`greet target10
|
||||
rts
|
||||
|
||||
hello1: .byte "HELLO, ",0
|
||||
hello2: .byte "!", 13, 0
|
||||
|
||||
target1: .byte "PROGRAMMER", 0
|
||||
target2: .byte "ROOM", 0
|
||||
target3: .byte "BUILDING", 0
|
||||
target4: .byte "NEIGHBORHOOD", 0
|
||||
target5: .byte "CITY", 0
|
||||
target6: .byte "NATION", 0
|
||||
target7: .byte "WORLD", 0
|
||||
target8: .byte "SOLAR SYSTEM", 0
|
||||
target9: .byte "GALAXY", 0
|
||||
target10: .byte "UNIVERSE", 0
|
||||
|
||||
; DELAY routine. Takes values from the Accumulator and pauses
|
||||
; for that many jiffies (1/60th of a second).
|
||||
.scope
|
||||
.data
|
||||
.space _tmp 1
|
||||
.space _target 1
|
||||
|
||||
.text
|
||||
|
||||
delay: sta _tmp ; save argument (rdtim destroys it)
|
||||
jsr rdtim
|
||||
clc
|
||||
adc _tmp ; add current time to get target
|
||||
sta _target
|
||||
* jsr rdtim
|
||||
cmp _target
|
||||
bmi - ; Buzz until target reached
|
||||
rts
|
||||
.scend
|
||||
|
||||
.checkpc $A000
|
||||
.data
|
||||
.checkpc $D000</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></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"
|
||||
><A
|
||||
HREF="x485.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="x493.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor4c.oph</TT
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="a454.html"
|
||||
ACCESSKEY="U"
|
||||
>Up</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor6.oph</TT
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,266 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>tutor6.oph</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="UP"
|
||||
TITLE="Example Programs"
|
||||
HREF="a454.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="tutor5.oph"
|
||||
HREF="x489.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="c64-2.oph"
|
||||
HREF="x497.html"></HEAD
|
||||
><BODY
|
||||
CLASS="SECTION"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x489.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
>Example Programs</TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x497.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="TUTOR6-SRC"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor6.oph</TT
|
||||
></A
|
||||
></H1
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.include "c64-1.oph"
|
||||
|
||||
.data
|
||||
.org $C000
|
||||
.space cache 2
|
||||
.text
|
||||
|
||||
.macro print
|
||||
lda #<_1
|
||||
ldx #>_1
|
||||
jsr printstr
|
||||
.macend
|
||||
|
||||
.macro greet
|
||||
lda #30
|
||||
jsr delay
|
||||
`print hello1
|
||||
`print _1
|
||||
`print hello2
|
||||
.macend
|
||||
|
||||
; Save the zero page locations that PRINTSTR uses.
|
||||
lda $10
|
||||
sta cache
|
||||
lda $11
|
||||
sta cache+1
|
||||
|
||||
lda #147
|
||||
jsr chrout
|
||||
`greet target1
|
||||
`greet target2
|
||||
`greet target3
|
||||
`greet target4
|
||||
`greet target5
|
||||
`greet target6
|
||||
`greet target7
|
||||
`greet target8
|
||||
`greet target9
|
||||
`greet target10
|
||||
|
||||
; Restore the zero page values printstr uses.
|
||||
lda cache
|
||||
sta $10
|
||||
lda cache+1
|
||||
sta $11
|
||||
|
||||
rts
|
||||
|
||||
hello1: .byte "HELLO, ",0
|
||||
hello2: .byte "!", 13, 0
|
||||
|
||||
target1: .byte "PROGRAMMER", 0
|
||||
target2: .byte "ROOM", 0
|
||||
target3: .byte "BUILDING", 0
|
||||
target4: .byte "NEIGHBORHOOD", 0
|
||||
target5: .byte "CITY", 0
|
||||
target6: .byte "NATION", 0
|
||||
target7: .byte "WORLD", 0
|
||||
target8: .byte "SOLAR SYSTEM", 0
|
||||
target9: .byte "GALAXY", 0
|
||||
target10: .byte "UNIVERSE", 0
|
||||
|
||||
; DELAY routine. Takes values from the Accumulator and pauses
|
||||
; for that many jiffies (1/60th of a second).
|
||||
.scope
|
||||
.data
|
||||
.space _tmp 1
|
||||
.space _target 1
|
||||
|
||||
.text
|
||||
|
||||
delay: sta _tmp ; save argument (rdtim destroys it)
|
||||
jsr rdtim
|
||||
clc
|
||||
adc _tmp ; add current time to get target
|
||||
sta _target
|
||||
* jsr rdtim
|
||||
cmp _target
|
||||
bmi - ; Buzz until target reached
|
||||
rts
|
||||
.scend
|
||||
|
||||
; PRINTSTR routine. Accumulator stores the low byte of the address,
|
||||
; X register stores the high byte. Destroys the values of $10 and
|
||||
; $11.
|
||||
|
||||
.scope
|
||||
printstr:
|
||||
sta $10
|
||||
stx $11
|
||||
ldy #$00
|
||||
_lp: lda ($10),y
|
||||
beq _done
|
||||
jsr chrout
|
||||
iny
|
||||
bne _lp
|
||||
_done: rts
|
||||
.scend
|
||||
|
||||
.checkpc $A000
|
||||
.data
|
||||
.checkpc $D000</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></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"
|
||||
><A
|
||||
HREF="x489.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="x497.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor5.oph</TT
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="a454.html"
|
||||
ACCESSKEY="U"
|
||||
>Up</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>c64-2.oph</TT
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,204 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>c64-2.oph</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="UP"
|
||||
TITLE="Example Programs"
|
||||
HREF="a454.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="tutor6.oph"
|
||||
HREF="x493.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="tutor7.oph"
|
||||
HREF="x501.html"></HEAD
|
||||
><BODY
|
||||
CLASS="SECTION"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x493.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
>Example Programs</TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x501.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="C64-2-SRC"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>c64-2.oph</TT
|
||||
></A
|
||||
></H1
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.word $0801
|
||||
.org $0801
|
||||
|
||||
.scope
|
||||
.word _next, 10 ; Next line and current line number
|
||||
.byte $9e," 2064",0 ; SYS 2064
|
||||
_next: .word 0 ; End of program
|
||||
.scend
|
||||
|
||||
.advance $0810
|
||||
|
||||
.require "kernal.oph"
|
||||
|
||||
.data zp
|
||||
.org $0002
|
||||
|
||||
.text
|
||||
|
||||
.scope
|
||||
; Cache BASIC's zero page at top of available RAM.
|
||||
ldx #$7E
|
||||
* lda $01, x
|
||||
sta $CF81, x
|
||||
dex
|
||||
bne -
|
||||
|
||||
jsr _main
|
||||
|
||||
; Restore BASIC's zero page and return control.
|
||||
|
||||
ldx #$7E
|
||||
* lda $CF81, x
|
||||
sta $01, x
|
||||
dex
|
||||
bne -
|
||||
rts
|
||||
|
||||
_main:
|
||||
; Program follows...
|
||||
.scend</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></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"
|
||||
><A
|
||||
HREF="x493.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="x501.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor6.oph</TT
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="a454.html"
|
||||
ACCESSKEY="U"
|
||||
>Up</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor7.oph</TT
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,257 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>tutor7.oph</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="UP"
|
||||
TITLE="Example Programs"
|
||||
HREF="a454.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="c64-2.oph"
|
||||
HREF="x497.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="Ophis Command Reference"
|
||||
HREF="a505.html"></HEAD
|
||||
><BODY
|
||||
CLASS="SECTION"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x497.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
>Example Programs</TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="a505.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="TUTOR7-SRC"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>tutor7.oph</TT
|
||||
></A
|
||||
></H1
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.include "c64-2.oph"
|
||||
|
||||
.data
|
||||
.org $C000
|
||||
.text
|
||||
|
||||
.macro print
|
||||
lda #<_1
|
||||
ldx #>_1
|
||||
jsr printstr
|
||||
.macend
|
||||
|
||||
.macro greet
|
||||
lda #30
|
||||
jsr delay
|
||||
`print hello1
|
||||
`print _1
|
||||
`print hello2
|
||||
.macend
|
||||
|
||||
lda #147
|
||||
jsr chrout
|
||||
`greet target1
|
||||
`greet target2
|
||||
`greet target3
|
||||
`greet target4
|
||||
`greet target5
|
||||
`greet target6
|
||||
`greet target7
|
||||
`greet target8
|
||||
`greet target9
|
||||
`greet target10
|
||||
|
||||
rts
|
||||
|
||||
hello1: .byte "HELLO, ",0
|
||||
hello2: .byte "!", 13, 0
|
||||
|
||||
target1: .byte "PROGRAMMER", 0
|
||||
target2: .byte "ROOM", 0
|
||||
target3: .byte "BUILDING", 0
|
||||
target4: .byte "NEIGHBORHOOD", 0
|
||||
target5: .byte "CITY", 0
|
||||
target6: .byte "NATION", 0
|
||||
target7: .byte "WORLD", 0
|
||||
target8: .byte "SOLAR SYSTEM", 0
|
||||
target9: .byte "GALAXY", 0
|
||||
target10: .byte "UNIVERSE", 0
|
||||
|
||||
; DELAY routine. Takes values from the Accumulator and pauses
|
||||
; for that many jiffies (1/60th of a second).
|
||||
.scope
|
||||
.data
|
||||
.space _tmp 1
|
||||
.space _target 1
|
||||
|
||||
.text
|
||||
|
||||
delay: sta _tmp ; save argument (rdtim destroys it)
|
||||
jsr rdtim
|
||||
clc
|
||||
adc _tmp ; add current time to get target
|
||||
sta _target
|
||||
* jsr rdtim
|
||||
cmp _target
|
||||
bmi - ; Buzz until target reached
|
||||
rts
|
||||
.scend
|
||||
|
||||
; PRINTSTR routine. Accumulator stores the low byte of the address,
|
||||
; X register stores the high byte. Destroys the values of $10 and
|
||||
; $11.
|
||||
|
||||
.scope
|
||||
.data zp
|
||||
.space _ptr 2
|
||||
.text
|
||||
printstr:
|
||||
sta _ptr
|
||||
stx _ptr+1
|
||||
ldy #$00
|
||||
_lp: lda (_ptr),y
|
||||
beq _done
|
||||
jsr chrout
|
||||
iny
|
||||
bne _lp
|
||||
_done: rts
|
||||
.scend
|
||||
|
||||
.checkpc $A000
|
||||
|
||||
.data
|
||||
.checkpc $D000
|
||||
|
||||
.data zp
|
||||
.checkpc $80</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></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"
|
||||
><A
|
||||
HREF="x497.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="a505.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
><TT
|
||||
CLASS="FILENAME"
|
||||
>c64-2.oph</TT
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="a454.html"
|
||||
ACCESSKEY="U"
|
||||
>Up</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
>Ophis Command Reference</TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,428 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>Producing Commodore 64 programs</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="UP"
|
||||
TITLE="The basics"
|
||||
HREF="c35.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="The basics"
|
||||
HREF="c35.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="Related commands and options"
|
||||
HREF="x119.html"></HEAD
|
||||
><BODY
|
||||
CLASS="SECTION"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="c35.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
>The basics</TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x119.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN51"
|
||||
>Producing Commodore 64 programs</A
|
||||
></H1
|
||||
><P
|
||||
> Commodore 64 programs are stored in
|
||||
the <TT
|
||||
CLASS="FILENAME"
|
||||
>PRG</TT
|
||||
> format on disk. Some emulators
|
||||
(such as CCS64 or VICE) can run <TT
|
||||
CLASS="FILENAME"
|
||||
>PRG</TT
|
||||
>
|
||||
programs directly; others need them to be transferred to
|
||||
a <TT
|
||||
CLASS="FILENAME"
|
||||
>D64</TT
|
||||
> image first.
|
||||
</P
|
||||
><P
|
||||
> The <TT
|
||||
CLASS="FILENAME"
|
||||
>PRG</TT
|
||||
> format is ludicrously simple. It
|
||||
has two bytes of header data: This is a little-endian number
|
||||
indicating the starting address. The rest of the file is a
|
||||
single continuous chunk of data loaded into memory, starting at
|
||||
that address. BASIC memory starts at memory location 2048, and
|
||||
that's probably where we'll want to start.
|
||||
</P
|
||||
><P
|
||||
> Well, not quite. We want our program to be callable from BASIC,
|
||||
so we should have a BASIC program at the start. We guess the
|
||||
size of a simple one line BASIC program to be about 16 bytes.
|
||||
Thus, we start our program at memory location 2064 ($0810), and
|
||||
the BASIC program looks like this:
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>10 SYS 2064
|
||||
</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
> We <KBD
|
||||
CLASS="USERINPUT"
|
||||
>SAVE</KBD
|
||||
> this program to a file, then
|
||||
study it in a debugger. It's 15 bytes long:
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="SCREEN"
|
||||
>1070:0100 01 08 0C 08 0A 00 9E 20-32 30 36 34 00 00 00
|
||||
</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
> The first two bytes are the memory location: $0801. The rest of
|
||||
the data breaks down as follows:
|
||||
</P
|
||||
><DIV
|
||||
CLASS="TABLE"
|
||||
><A
|
||||
NAME="AEN65"
|
||||
></A
|
||||
><P
|
||||
><B
|
||||
>Table 1. BASIC program breakdown</B
|
||||
></P
|
||||
><TABLE
|
||||
BORDER="1"
|
||||
BGCOLOR="#E0E0E0"
|
||||
CELLSPACING="0"
|
||||
CELLPADDING="4"
|
||||
CLASS="CALSTABLE"
|
||||
><THEAD
|
||||
><TR
|
||||
><TH
|
||||
ALIGN="CENTER"
|
||||
>Memory Locations</TH
|
||||
><TH
|
||||
ALIGN="CENTER"
|
||||
>Value</TH
|
||||
></TR
|
||||
></THEAD
|
||||
><TBODY
|
||||
><TR
|
||||
><TD
|
||||
>$0801-$0802</TD
|
||||
><TD
|
||||
>2-byte pointer to the next line of BASIC code ($080C).</TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
>$0803-$0804</TD
|
||||
><TD
|
||||
>2-byte line number ($000A = 10).</TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
>$0805</TD
|
||||
><TD
|
||||
>Byte code for the <KBD
|
||||
CLASS="USERINPUT"
|
||||
>SYS</KBD
|
||||
> command.</TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
>$0806-$080A</TD
|
||||
><TD
|
||||
>The rest of the line, which is just the string <SPAN
|
||||
CLASS="QUOTE"
|
||||
>" 2064"</SPAN
|
||||
>.</TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
>$080B</TD
|
||||
><TD
|
||||
>Null byte, terminating the line.</TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
>$080C-$080D</TD
|
||||
><TD
|
||||
>2-byte pointer to the next line of BASIC code ($0000 = end of program).</TD
|
||||
></TR
|
||||
></TBODY
|
||||
></TABLE
|
||||
></DIV
|
||||
><P
|
||||
> That's 13 bytes. We started at 2049, so we need 2 more bytes of
|
||||
filler to make our code actually start at location 2064. These
|
||||
17 bytes will give us the file format and the BASIC code we need
|
||||
to have our machine language program run.
|
||||
</P
|
||||
><P
|
||||
> These are just bytes—indistinguishable from any other sort of
|
||||
data. In Ophis, bytes of data are specified with
|
||||
the <TT
|
||||
CLASS="LITERAL"
|
||||
>.byte</TT
|
||||
> command. We'll also have to tell
|
||||
Ophis what the program counter should be, so that it knows what
|
||||
values to assign to our labels. The <TT
|
||||
CLASS="LITERAL"
|
||||
>.org</TT
|
||||
>
|
||||
(origin) command tells Ophis this. Thus, the Ophis code for our
|
||||
header and linking info is:
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.byte $01, $08, $0C, $08, $0A, $00, $9E, $20
|
||||
.byte $32, $30, $36, $34, $00, $00, $00, $00
|
||||
.byte $00, $00
|
||||
.org $0810
|
||||
</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
> This gets the job done, but it's completely incomprehensible,
|
||||
and it only uses two directives—not very good for a
|
||||
tutorial. Here's a more complicated, but much clearer, way of
|
||||
saying the same thing.
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.word $0801
|
||||
.org $0801
|
||||
|
||||
.word next, 10 ; Next line and current line number
|
||||
.byte $9e," 2064",0 ; SYS 2064
|
||||
next: .word 0 ; End of program
|
||||
|
||||
.advance 2064
|
||||
</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
> This code has many advantages over the first.
|
||||
|
||||
<P
|
||||
></P
|
||||
><UL
|
||||
><LI
|
||||
><P
|
||||
> It describes better what is actually
|
||||
happening. The <TT
|
||||
CLASS="LITERAL"
|
||||
>.word</TT
|
||||
> directive at the
|
||||
beginning indicates a 16-bit value stored in the typical
|
||||
65xx way (small byte first). This is followed by
|
||||
an <TT
|
||||
CLASS="LITERAL"
|
||||
>.org</TT
|
||||
> statement, so we let the
|
||||
assembler know right away where everything is supposed to
|
||||
be.
|
||||
</P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
> Instead of hardcoding in the value $080C, we
|
||||
instead use a label to identify the location it's pointing
|
||||
to. Ophis will compute the address
|
||||
of <TT
|
||||
CLASS="LITERAL"
|
||||
>next</TT
|
||||
> and put that value in as data.
|
||||
We also describe the line number in decimal since BASIC
|
||||
line numbers generally <I
|
||||
CLASS="EMPHASIS"
|
||||
>are</I
|
||||
> in decimal.
|
||||
Labels are defined by putting their name, then a colon, as
|
||||
seen in the definition of <TT
|
||||
CLASS="LITERAL"
|
||||
>next</TT
|
||||
>.
|
||||
</P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
>
|
||||
Instead of putting in the hex codes for the string part of
|
||||
the BASIC code, we included the string directly. Each
|
||||
character in the string becomes one byte.
|
||||
</P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
>
|
||||
Instead of adding the buffer ourselves, we
|
||||
used <TT
|
||||
CLASS="LITERAL"
|
||||
>.advance</TT
|
||||
>, which outputs zeros until
|
||||
the specified address is reached. Attempting
|
||||
to <TT
|
||||
CLASS="LITERAL"
|
||||
>.advance</TT
|
||||
> backwards produces an
|
||||
assemble-time error.
|
||||
</P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
>
|
||||
It has comments that explain what the data are for. The
|
||||
semicolon is the comment marker; everything from a semicolon
|
||||
to the end of the line is ignored.
|
||||
</P
|
||||
></LI
|
||||
></UL
|
||||
>
|
||||
</P
|
||||
></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"
|
||||
><A
|
||||
HREF="c35.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="x119.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
>The basics</TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="c35.html"
|
||||
ACCESSKEY="U"
|
||||
>Up</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
>Related commands and options</TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,309 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>Basic arguments</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="UP"
|
||||
TITLE="Ophis Command Reference"
|
||||
HREF="a505.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="Ophis Command Reference"
|
||||
HREF="a505.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="Compound Arguments"
|
||||
HREF="x620.html"></HEAD
|
||||
><BODY
|
||||
CLASS="SECTION"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="a505.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
>Ophis Command Reference</TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x620.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN572"
|
||||
>Basic arguments</A
|
||||
></H1
|
||||
><P
|
||||
> Most arguments are just a number or label. The formats for
|
||||
these are below.
|
||||
</P
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H2
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN575"
|
||||
>Numeric types</A
|
||||
></H2
|
||||
><P
|
||||
></P
|
||||
><UL
|
||||
><LI
|
||||
><P
|
||||
><I
|
||||
CLASS="EMPHASIS"
|
||||
>Hex:</I
|
||||
> <TT
|
||||
CLASS="LITERAL"
|
||||
>$41</TT
|
||||
> (Prefixed with $)</P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
><I
|
||||
CLASS="EMPHASIS"
|
||||
>Decimal:</I
|
||||
> <TT
|
||||
CLASS="LITERAL"
|
||||
>65</TT
|
||||
> (No markings)</P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
><I
|
||||
CLASS="EMPHASIS"
|
||||
>Octal:</I
|
||||
> <TT
|
||||
CLASS="LITERAL"
|
||||
>0101</TT
|
||||
> (Prefixed with zero)</P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
><I
|
||||
CLASS="EMPHASIS"
|
||||
>Binary:</I
|
||||
> <TT
|
||||
CLASS="LITERAL"
|
||||
>%01000001</TT
|
||||
> (Prefixed with %)</P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
><I
|
||||
CLASS="EMPHASIS"
|
||||
>Character:</I
|
||||
> <TT
|
||||
CLASS="LITERAL"
|
||||
>'A</TT
|
||||
> (Prefixed with single quote)</P
|
||||
></LI
|
||||
></UL
|
||||
></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H2
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN598"
|
||||
>Label types</A
|
||||
></H2
|
||||
><P
|
||||
> Normal labels are simply referred to by name. Anonymous
|
||||
labels may be referenced with strings of - or + signs (the
|
||||
label <TT
|
||||
CLASS="LITERAL"
|
||||
>-</TT
|
||||
> refers to the immediate
|
||||
previous anonymous label, <TT
|
||||
CLASS="LITERAL"
|
||||
>--</TT
|
||||
> the
|
||||
one before that, etc., while <TT
|
||||
CLASS="LITERAL"
|
||||
>+</TT
|
||||
>
|
||||
refers to the next anonymous label), and the special
|
||||
label <TT
|
||||
CLASS="LITERAL"
|
||||
>^</TT
|
||||
> refers to the program
|
||||
counter at the start of the current instruction or directive.
|
||||
</P
|
||||
><P
|
||||
> Normal labels are <I
|
||||
CLASS="EMPHASIS"
|
||||
>defined</I
|
||||
> by
|
||||
prefixing a line with the label name and then a colon
|
||||
(e.g., <TT
|
||||
CLASS="LITERAL"
|
||||
>label:</TT
|
||||
>). Anonymous labels
|
||||
are defined by prefixing a line with an asterisk
|
||||
(e.g., <TT
|
||||
CLASS="LITERAL"
|
||||
>*</TT
|
||||
>).
|
||||
</P
|
||||
><P
|
||||
> Temporary labels are only reachable from inside the
|
||||
innermost enclosing <TT
|
||||
CLASS="LITERAL"
|
||||
>.scope</TT
|
||||
>
|
||||
statement. They are identical to normal labels in every
|
||||
way, except that they start with an underscore.
|
||||
</P
|
||||
></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H2
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN611"
|
||||
>String types</A
|
||||
></H2
|
||||
><P
|
||||
> Strings are enclosed in double quotation marks. Backslashed
|
||||
characters (including backslashes and double quotes) are
|
||||
treated literally, so the string <TT
|
||||
CLASS="LITERAL"
|
||||
>"The man said,
|
||||
\"The \\ character is the backslash.\""</TT
|
||||
> produces
|
||||
the ASCII sequence for <TT
|
||||
CLASS="LITERAL"
|
||||
>The man said, "The \
|
||||
character is the backslash."</TT
|
||||
>
|
||||
</P
|
||||
><P
|
||||
> Strings are generally only used as arguments to assembler
|
||||
directives—usually for filenames
|
||||
(e.g., <TT
|
||||
CLASS="LITERAL"
|
||||
>.include</TT
|
||||
>) but also for string
|
||||
data (in association with <TT
|
||||
CLASS="LITERAL"
|
||||
>.byte</TT
|
||||
>).
|
||||
</P
|
||||
><P
|
||||
> It is legal, though unusual, to attempt to pass a string to
|
||||
the other data statements. This will produces a series of
|
||||
words/dwords where all bytes that aren't least-significant
|
||||
are zero. Endianness and size will match what the directive
|
||||
itself indicated.
|
||||
</P
|
||||
></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"
|
||||
><A
|
||||
HREF="a505.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="x620.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
>Ophis Command Reference</TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="a505.html"
|
||||
ACCESSKEY="U"
|
||||
>Up</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
>Compound Arguments</TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,212 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>Compound Arguments</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="UP"
|
||||
TITLE="Ophis Command Reference"
|
||||
HREF="a505.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="Basic arguments"
|
||||
HREF="x572.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="Memory Model"
|
||||
HREF="x647.html"></HEAD
|
||||
><BODY
|
||||
CLASS="SECTION"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x572.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
>Ophis Command Reference</TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x647.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN620"
|
||||
>Compound Arguments</A
|
||||
></H1
|
||||
><P
|
||||
> Compound arguments may be built up from simple ones, using the
|
||||
standard +, -, *, and / operators, which carry the usual
|
||||
precedence. Also, the unary operators > and <, which
|
||||
bind more tightly than anything else, provide the high and low
|
||||
bytes of 16-bit values, respectively.
|
||||
</P
|
||||
><P
|
||||
> Use brackets [ ] instead of parentheses ( ) when grouping
|
||||
arithmetic operations, as the parentheses are needed for the
|
||||
indirect addressing modes.
|
||||
</P
|
||||
><P
|
||||
> Examples:
|
||||
</P
|
||||
><P
|
||||
></P
|
||||
><UL
|
||||
><LI
|
||||
><P
|
||||
><TT
|
||||
CLASS="LITERAL"
|
||||
>$D000</TT
|
||||
> evaluates to $D000</P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
><TT
|
||||
CLASS="LITERAL"
|
||||
>$D000+32</TT
|
||||
> evaluates to $D020</P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
><TT
|
||||
CLASS="LITERAL"
|
||||
>$D000+$20</TT
|
||||
> also evaluates to $D020</P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
><TT
|
||||
CLASS="LITERAL"
|
||||
><$D000+32</TT
|
||||
> evaluates to $20</P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
><TT
|
||||
CLASS="LITERAL"
|
||||
>>$D000+32</TT
|
||||
> evaluates to $F0</P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
><TT
|
||||
CLASS="LITERAL"
|
||||
>>[$D000+32]</TT
|
||||
> evaluates to $D0</P
|
||||
></LI
|
||||
><LI
|
||||
><P
|
||||
><TT
|
||||
CLASS="LITERAL"
|
||||
>>$D000-275</TT
|
||||
> evaluates to $CE</P
|
||||
></LI
|
||||
></UL
|
||||
></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"
|
||||
><A
|
||||
HREF="x572.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="book1.html"
|
||||
ACCESSKEY="H"
|
||||
>Home</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="x647.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="left"
|
||||
VALIGN="top"
|
||||
>Basic arguments</TD
|
||||
><TD
|
||||
WIDTH="34%"
|
||||
ALIGN="center"
|
||||
VALIGN="top"
|
||||
><A
|
||||
HREF="a505.html"
|
||||
ACCESSKEY="U"
|
||||
>Up</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="33%"
|
||||
ALIGN="right"
|
||||
VALIGN="top"
|
||||
>Memory Model</TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></BODY
|
||||
></HTML
|
||||
>
|
@ -1,373 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML
|
||||
><HEAD
|
||||
><TITLE
|
||||
>Memory Model</TITLE
|
||||
><META
|
||||
NAME="GENERATOR"
|
||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
||||
REL="HOME"
|
||||
TITLE="Programming with Ophis"
|
||||
HREF="book1.html"><LINK
|
||||
REL="UP"
|
||||
TITLE="Ophis Command Reference"
|
||||
HREF="a505.html"><LINK
|
||||
REL="PREVIOUS"
|
||||
TITLE="Compound Arguments"
|
||||
HREF="x620.html"><LINK
|
||||
REL="NEXT"
|
||||
TITLE="Macros"
|
||||
HREF="x692.html"></HEAD
|
||||
><BODY
|
||||
CLASS="SECTION"
|
||||
BGCOLOR="#FFFFFF"
|
||||
TEXT="#000000"
|
||||
LINK="#0000FF"
|
||||
VLINK="#840084"
|
||||
ALINK="#0000FF"
|
||||
><DIV
|
||||
CLASS="NAVHEADER"
|
||||
><TABLE
|
||||
SUMMARY="Header navigation table"
|
||||
WIDTH="100%"
|
||||
BORDER="0"
|
||||
CELLPADDING="0"
|
||||
CELLSPACING="0"
|
||||
><TR
|
||||
><TH
|
||||
COLSPAN="3"
|
||||
ALIGN="center"
|
||||
>Programming with Ophis</TH
|
||||
></TR
|
||||
><TR
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="left"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x620.html"
|
||||
ACCESSKEY="P"
|
||||
><<< Previous</A
|
||||
></TD
|
||||
><TD
|
||||
WIDTH="80%"
|
||||
ALIGN="center"
|
||||
VALIGN="bottom"
|
||||
>Ophis Command Reference</TD
|
||||
><TD
|
||||
WIDTH="10%"
|
||||
ALIGN="right"
|
||||
VALIGN="bottom"
|
||||
><A
|
||||
HREF="x692.html"
|
||||
ACCESSKEY="N"
|
||||
>Next >>></A
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><HR
|
||||
ALIGN="LEFT"
|
||||
WIDTH="100%"></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H1
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN647"
|
||||
>Memory Model</A
|
||||
></H1
|
||||
><P
|
||||
> In order to properly compute the locations of labels and the
|
||||
like, Ophis must keep track of where assembled code will
|
||||
actually be sitting in memory, and it strives to do this in a
|
||||
way that is independent both of the target file and of the
|
||||
target machine.
|
||||
</P
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H2
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN650"
|
||||
>Basic PC tracking</A
|
||||
></H2
|
||||
><P
|
||||
> The primary technique Ophis uses is <I
|
||||
CLASS="EMPHASIS"
|
||||
>program counter
|
||||
tracking</I
|
||||
>. As it assembles the code, it keeps
|
||||
track of a virtual program counter, and uses that to
|
||||
determine where the labels should go.
|
||||
</P
|
||||
><P
|
||||
> In the absence of an <TT
|
||||
CLASS="LITERAL"
|
||||
>.org</TT
|
||||
> directive, it
|
||||
assumes a starting PC of zero. <TT
|
||||
CLASS="LITERAL"
|
||||
>.org</TT
|
||||
>
|
||||
is a simple directive, setting the PC to the value
|
||||
that <TT
|
||||
CLASS="LITERAL"
|
||||
>.org</TT
|
||||
> specifies. In the simplest
|
||||
case, one <TT
|
||||
CLASS="LITERAL"
|
||||
>.org</TT
|
||||
> directive appears at the
|
||||
beginning of the code and sets the location for the rest of
|
||||
the code, which is one contiguous block.
|
||||
</P
|
||||
></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H2
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN659"
|
||||
>Basic Segmentation simulation</A
|
||||
></H2
|
||||
><P
|
||||
> However, this isn't always practical. Often one wishes to
|
||||
have a region of memory reserved for data without actually
|
||||
mapping that memory to the file. On some systems (typically
|
||||
cartridge-based systems where ROM and RAM are seperate, and
|
||||
the target file only specifies the ROM image) this is
|
||||
mandatory. In order to access these variables symbolically,
|
||||
it's necessary to put the values into the label lookup
|
||||
table.
|
||||
</P
|
||||
><P
|
||||
> It is possible, but inconvenient, to do this
|
||||
with <TT
|
||||
CLASS="LITERAL"
|
||||
>.alias</TT
|
||||
>, assigning a specific
|
||||
memory location to each variable. This requires careful
|
||||
coordination through your code, and makes creating reusable
|
||||
libraries all but impossible.
|
||||
</P
|
||||
><P
|
||||
> A better approach is to reserve a section at the beginning
|
||||
or end of your program, put an <TT
|
||||
CLASS="LITERAL"
|
||||
>.org</TT
|
||||
>
|
||||
directive in, then use the <TT
|
||||
CLASS="LITERAL"
|
||||
>.space</TT
|
||||
>
|
||||
directive to divide up the data area. This is still a bit
|
||||
inconvenient, though, because all variables must be
|
||||
assigned all at once. What we'd really like is to keep
|
||||
multiple PC counters, one for data and one for code.
|
||||
</P
|
||||
><P
|
||||
> The <TT
|
||||
CLASS="LITERAL"
|
||||
>.text</TT
|
||||
>
|
||||
and <TT
|
||||
CLASS="LITERAL"
|
||||
>.data</TT
|
||||
> directives do this. Each
|
||||
has its own PC that starts at zero, and you can switch
|
||||
between the two at any point without corrupting the other's
|
||||
counter. In this way each function can have
|
||||
a <TT
|
||||
CLASS="LITERAL"
|
||||
>.data</TT
|
||||
> section (filled
|
||||
with <TT
|
||||
CLASS="LITERAL"
|
||||
>.space</TT
|
||||
> commands) and
|
||||
a <TT
|
||||
CLASS="LITERAL"
|
||||
>.text</TT
|
||||
> section (that contains the
|
||||
actual code). This lets our library routines be almost
|
||||
completely self-contained - we can have one source file
|
||||
that could be <TT
|
||||
CLASS="LITERAL"
|
||||
>.included</TT
|
||||
> by multiple
|
||||
projects without getting in anything's way.
|
||||
</P
|
||||
><P
|
||||
> However, any given program may have its own ideas about
|
||||
where data and code go, and it's good to ensure with
|
||||
a <TT
|
||||
CLASS="LITERAL"
|
||||
>.checkpc</TT
|
||||
> at the end of your code
|
||||
that you haven't accidentally overwritten code with data or
|
||||
vice versa. If your <TT
|
||||
CLASS="LITERAL"
|
||||
>.data</TT
|
||||
>
|
||||
segment <I
|
||||
CLASS="EMPHASIS"
|
||||
>did</I
|
||||
> start at zero, it's
|
||||
probably wise to make sure you aren't smashing the stack,
|
||||
too (which is sitting in the region from $0100 to
|
||||
$01FF).
|
||||
</P
|
||||
><P
|
||||
> If you write code with no segment-defining statements in
|
||||
it, the default segment
|
||||
is <TT
|
||||
CLASS="LITERAL"
|
||||
>text</TT
|
||||
>.
|
||||
</P
|
||||
><P
|
||||
> The <TT
|
||||
CLASS="LITERAL"
|
||||
>data</TT
|
||||
> segment is designed only
|
||||
for organizing labels. As such, errors will be flagged if
|
||||
you attempt to actually output information into
|
||||
a <TT
|
||||
CLASS="LITERAL"
|
||||
>data</TT
|
||||
> segment.
|
||||
</P
|
||||
></DIV
|
||||
><DIV
|
||||
CLASS="SECTION"
|
||||
><H2
|
||||
CLASS="SECTION"
|
||||
><A
|
||||
NAME="AEN683"
|
||||
>General Segmentation Simulation</A
|
||||
></H2
|
||||
><P
|
||||
> One text and data segment each is usually sufficient, but
|
||||
for the cases where it is not, Ophis allows for user-defined
|
||||
segments. Putting a label
|
||||
after <TT
|
||||
CLASS="LITERAL"
|
||||
>.text</TT
|
||||
>
|
||||
or <TT
|
||||
CLASS="LITERAL"
|
||||
>.data</TT
|
||||
> produces a new segment with
|
||||
the specified name.
|
||||
</P
|
||||
><P
|
||||
> Say, for example, that we have access to the RAM at the low
|
||||
end of the address space, but want to reserve the zero page
|
||||
for truly critical variables, and use the rest of RAM for
|
||||
everything else. Let's also assume that this is a 6510
|
||||
chip, and locations $00 and $01 are reserved for the I/O
|
||||
port. We could start our program off with:
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.data
|
||||
.org $200
|
||||
.data zp
|
||||
.org $2
|
||||
.text
|
||||
.org $800</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
><P
|
||||
> And, to be safe, we would probably want to end our code
|
||||
with checks to make sure we aren't overwriting anything:
|
||||
</P
|
||||
><TABLE
|
||||
BORDER="0"
|
||||
BGCOLOR="#E0E0E0"
|
||||
WIDTH="100%"
|
||||
><TR
|
||||
><TD
|
||||
><PRE
|
||||
CLASS="PROGRAMLISTING"
|
||||
>.data
|
||||
.checkpc $800
|
||||
.data zp
|
||||
.checkpc $100</PRE
|
||||
></TD
|
||||
></TR
|
||||
></TABLE
|
||||
></DIV
|
||||
></DIV
|
||||
><DIV
|
||||
CLASS="NAVFOOTER"
|
||||
><HR
|
||||