ca65-15.html

来自「cc65 的编译器文档」· HTML 代码 · 共 124 行

HTML
124
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML><HEAD> <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.20"> <TITLE>ca65 Users Guide: Porting sources from other assemblers</TITLE> <LINK HREF="ca65-16.html" REL=next> <LINK HREF="ca65-14.html" REL=previous> <LINK HREF="ca65.html#toc15" REL=contents></HEAD><BODY><A HREF="ca65-16.html">Next</A><A HREF="ca65-14.html">Previous</A><A HREF="ca65.html#toc15">Contents</A><HR><H2><A NAME="s15">15.</A> <A HREF="ca65.html#toc15">Porting sources from other assemblers</A></H2><P>Sometimes it is necessary to port code written for older assemblers to ca65.In some cases, this can be done without any changes to the source code byusing the emulation features of ca65 (see <CODE><A HREF="ca65-10.html#.FEATURE">.FEATURE</A></CODE>). In other cases, it is necessary to make changes to thesource code.</P><P>Probably the biggest difference is the handling of the <CODE><A HREF="ca65-10.html#.ORG">.ORG</A></CODE> directive. ca65 generates relocatable code, and placement isdone by the linker. Most other assemblers generate absolute code, placement isdone within the assembler and there is no external linker.</P><P>In general it is not a good idea to write new code using the emulationfeatures of the assembler, but there may be situations where even this rule isnot valid.</P><H2><A NAME="ss15.1">15.1</A> <A HREF="ca65.html#toc15.1">TASS</A></H2><P>You need to use some of the ca65 emulation features to simulate the behaviourof such simple assemblers.</P><P><OL><LI>Prepare your sourcecode like this:<BLOCKQUOTE><CODE><PRE>        ; if you want TASS style labels without colons        .feature labels_without_colons        ; if you want TASS style character constants        ; ("a" instead of the default 'a')        .feature loose_char_term                .word *+2       ; the cbm load address                [yourcode here]</PRE></CODE></BLOCKQUOTE>notice that the two emulation features are mostly useful for portingsources originally written in/for TASS, they are not needed for theactual "simple assembler operation" and are not recommended if you arewriting new code from scratch.</LI><LI>Replace all program counter assignments (which are not possible in ca65by default, and the respective emulation feature works different from whatyou'd expect) by another way to skip to another memory location, for examplethe <CODE><A HREF="ca65-10.html#.RES">.RES</A></CODE>directive.<BLOCKQUOTE><CODE><PRE>        ; *=$2000        .res $2000-*    ; reserve memory up to $2000</PRE></CODE></BLOCKQUOTE>notice that other than the original TASS, ca65 can never move theprogrammcounter backwards - think of it as if you are assembling to disc withTASS.</LI><LI>Conditional assembly (<CODE>.ifeq</CODE>/<CODE>.endif</CODE>/<CODE>.goto</CODE> etc.) must berewritten to match ca65 syntax. Most importantly notice that due to the lackof <CODE>.goto</CODE>, everything involving loops must be replaced by<CODE><A HREF="ca65-10.html#.REPEAT">.REPEAT</A></CODE>.</LI><LI>To assemble code to a different address than it is executed at, use the<CODE><A HREF="ca65-10.html#.ORG">.ORG</A></CODE> directive instead of<CODE>.offs</CODE>-constructs.<BLOCKQUOTE><CODE><PRE>        .org $1800        [floppy code here]        .reloc  ; back to normal</PRE></CODE></BLOCKQUOTE></LI><LI>Then assemble like this:<BLOCKQUOTE><CODE><PRE>        cl65 --start-addr 0x0ffe -t none myprog.s -o myprog.prg</PRE></CODE></BLOCKQUOTE>notice that you need to use the actual start address minus two, since twobytes are used for the cbm load address.</LI></OL></P><HR><A HREF="ca65-16.html">Next</A><A HREF="ca65-14.html">Previous</A><A HREF="ca65.html#toc15">Contents</A></BODY></HTML>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?