Ophis/site/manual/x732.html

595 lines
9.7 KiB
HTML
Raw Normal View History

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Assembler directives</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="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="x692.html"
ACCESSKEY="P"
>&#60;&#60;&#60; Previous</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Ophis Command Reference</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
>&nbsp;</TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECTION"
><H1
CLASS="SECTION"
><A
NAME="AEN732"
>Assembler directives</A
></H1
><P
> Assembler directives are all instructions to the assembler
that are not actual instructions. Ophis's set of directives
follow.
</P
><P
></P
><UL
><LI
><P
><TT
CLASS="LITERAL"
>.advance</TT
> <I
CLASS="EMPHASIS"
>address</I
>:
Forces the program counter to
be <I
CLASS="EMPHASIS"
>address</I
>. Unlike
the <TT
CLASS="LITERAL"
>.org</TT
>
directive, <TT
CLASS="LITERAL"
>.advance</TT
> outputs zeroes until the
program counter reaches a specified address. Attempting
to <TT
CLASS="LITERAL"
>.advance</TT
> to a point behind the current
program counter is an assemble-time error.</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>.alias</TT
> <I
CLASS="EMPHASIS"
>label</I
> <I
CLASS="EMPHASIS"
>value</I
>: The
.alias directive assigns an arbitrary value to a label. This
value may be an arbitrary argument, but cannot reference any
label that has not already been defined (this prevents
recursive label dependencies).</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>.byte</TT
> <I
CLASS="EMPHASIS"
>arg</I
> [ , <I
CLASS="EMPHASIS"
>arg</I
>, ... ]:
Specifies a series of arguments, which are evaluated, and
strings, which are included as raw ASCII data. The final
results of these arguments must be one byte in size. Seperate
constants are seperated by comments.</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>.checkpc</TT
> <I
CLASS="EMPHASIS"
>address</I
>: Ensures that the
program counter is less than or equal to the address
specified, and emits an assemble-time error if it is not.
<I
CLASS="EMPHASIS"
>This produces no code in the final binary - it is there to
ensure that linking a large amount of data together does not
overstep memory boundaries.</I
></P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>.data</TT
> <I
CLASS="EMPHASIS"
>[label]</I
>: Sets the segment to
the segment name specified and disallows output. If no label
is given, switches to the default data segment.</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>.incbin</TT
> <I
CLASS="EMPHASIS"
>filename</I
>: Inserts the
contents of the file specified as binary data. Use it to
include graphics information, precompiled code, or other
non-assembler data.</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>.include</TT
> <I
CLASS="EMPHASIS"
>filename</I
>: Includes the
entirety of the file specified at that point in the program.
Use this to order your final sources.</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>.org</TT
> <I
CLASS="EMPHASIS"
>address</I
>: Sets the program
counter to the address specified. <I
CLASS="EMPHASIS"
>This does not emit any
code in and of itself, nor does it overwrite anything that
previously existed.</I
> If you wish to jump ahead in memory,
use <TT
CLASS="LITERAL"
>.advance</TT
>.</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>.require</TT
> <I
CLASS="EMPHASIS"
>filename</I
>: Includes the entirety
of the file specified at that point in the program. Unlike <TT
CLASS="LITERAL"
>.include</TT
>,
however, code included with <TT
CLASS="LITERAL"
>.require</TT
> will only be inserted once.
The <TT
CLASS="LITERAL"
>.require</TT
> directive is useful for ensuring that certain code libraries
are somewhere in the final binary. They are also very useful for guaranteeing that
macro libraries are available.</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>.space</TT
> <I
CLASS="EMPHASIS"
>label</I
> <I
CLASS="EMPHASIS"
>size</I
>: This
directive is used to organize global variables. It defines the
label specified to be at the current location of the program
counter, and then advances the program counter <I
CLASS="EMPHASIS"
>size</I
>
steps ahead. No actual code is produced. This is equivalent
to <TT
CLASS="LITERAL"
>label: .org ^+size</TT
>.</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>.text</TT
> <I
CLASS="EMPHASIS"
>[label]</I
>: Sets the segment to
the segment name specified and allows output. If no label is
given, switches to the default text segment.</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>.word</TT
> <I
CLASS="EMPHASIS"
>arg</I
> [ , <I
CLASS="EMPHASIS"
>arg</I
>, ... ]:
Like <TT
CLASS="LITERAL"
>.byte</TT
>, but values are all treated as two-byte
values and stored low-end first (as is the 6502's wont). Use
this to create jump tables (an unadorned label will evaluate
to that label's location) or otherwise store 16-bit
data.</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>.dword</TT
> <I
CLASS="EMPHASIS"
>arg</I
> [ , <I
CLASS="EMPHASIS"
>arg</I
>, ...]:
Like <TT
CLASS="LITERAL"
>.word</TT
>, but for 32-bit values.</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>.wordbe</TT
> <I
CLASS="EMPHASIS"
>arg</I
> [ , <I
CLASS="EMPHASIS"
>arg</I
>, ...]:
Like <TT
CLASS="LITERAL"
>.word</TT
>, but stores the value in a big-endian format (high byte first).</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>.dwordbe</TT
> <I
CLASS="EMPHASIS"
>arg</I
> [ , <I
CLASS="EMPHASIS"
>arg</I
>, ...]:
Like <TT
CLASS="LITERAL"
>.dword</TT
>, but stores the value high byte first.</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>.scope</TT
>: Starts a new scope block. Labels
that begin with an underscore are only reachable from within
their innermost enclosing <TT
CLASS="LITERAL"
>.scope</TT
> statement.</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>.scend</TT
>: Ends a scope block. Makes the
temporary labels defined since the last <TT
CLASS="LITERAL"
>.scope</TT
>
statement unreachable, and permits them to be redefined in a
new scope.</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>.macro</TT
> <I
CLASS="EMPHASIS"
>name</I
>: Begins a macro
definition block. This is a scope block that can be inlined
at arbitrary points with <TT
CLASS="LITERAL"
>.invoke</TT
>. Arguments to the
macro will be bound to temporary labels with names like
<TT
CLASS="LITERAL"
>_1</TT
>, <TT
CLASS="LITERAL"
>_2</TT
>, etc.</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>.macend</TT
>: Ends a macro definition
block.</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>.invoke</TT
> <I
CLASS="EMPHASIS"
>label</I
> [<I
CLASS="EMPHASIS"
>argument</I
> [,
<I
CLASS="EMPHASIS"
>argument</I
> ...]]: invokes (inlines) the specified
macro, binding the values of the arguments to the ones the
macro definition intends to read. A shorthand for <TT
CLASS="LITERAL"
>.invoke</TT
>
is the name of the macro to invoke, backquoted.</P
></LI
></UL
><P
> The following directives are deprecated, added for
compatibility with the old Perl
assembler <B
CLASS="COMMAND"
>P65</B
>. Use
the <TT
CLASS="LITERAL"
>-d</TT
> option to Ophis to enable
them.
</P
><P
></P
><UL
><LI
><P
><TT
CLASS="LITERAL"
>.ascii</TT
>: Equivalent to <TT
CLASS="LITERAL"
>.byte</TT
>,
which didn't used to be able to handle strings.</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>.code</TT
>: Equivalent to <TT
CLASS="LITERAL"
>.text</TT
>.</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>.segment</TT
>: Equivalent to <TT
CLASS="LITERAL"
>.text</TT
>,
from when there was no distinction between <TT
CLASS="LITERAL"
>.text</TT
> and
<TT
CLASS="LITERAL"
>.data</TT
> segments.</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>.address</TT
>: Equivalent to
<TT
CLASS="LITERAL"
>.word</TT
>.</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>.link</TT
> <I
CLASS="EMPHASIS"
>filename address</I
>: Assembles
the file specified as if it began at the address specified.
This is generally for use in <SPAN
CLASS="QUOTE"
>"top-level"</SPAN
> files, where there
is not necessarily a one-to-one correspondence between file
position and memory position. This is equivalent to an
<TT
CLASS="LITERAL"
>.org</TT
> directive followed by an <TT
CLASS="LITERAL"
>.include</TT
>.
With the introduction of the <TT
CLASS="LITERAL"
>.org</TT
> directive this one is
less useful (and in most cases, any <TT
CLASS="LITERAL"
>.org</TT
> statement
you use will actually be at the top of the <TT
CLASS="LITERAL"
>.include</TT
>d
file).</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="x692.html"
ACCESSKEY="P"
>&#60;&#60;&#60; 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"
>&nbsp;</TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Macros</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="a505.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>&nbsp;</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>