⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 apcsasm.html

📁 关于ARM汇编的非常好的教程
💻 HTML
字号:
<!doctype html public "-//W3C//DTD HTML 3.2//EN"><html><head><title>APCS - opinions on various assemblers</title><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" /><meta http-equiv="content-language" content="en" /><meta name="resource-type" content="document"><meta name="copyright" content="This document copyright 2001 by Richard Murray. Use for non-profit and education purposes explicitly granted."><meta name="author" content="Richard Murray"><meta name="rating" content="general"></head><!--  /assembler/apcsasm.html            --><!--                                     --><!--  (C) Copyright 2001 Richard Murray  --><!--  Designed by Richard Murray         --><!--  rmurray@heyrick.co.uk              --><!--                                     --><body bgcolor="#f0f0f0" text="#000000" link="#0022dd" vlink="#002288"><table border = "0" width="100%">  <tr>    <td align=center width=100>      <img src="arm3.gif" width=79 height=78 align = middle>    </td>    <td>      <h1 align="center"><font color="#800080">APCS</font></h1>      <h3 align="center"><font color="#800080">Opinions on various assemblers</font></h3>    </td>    <td align=center width=100>      <img src="arm3.gif" width=79 height=78 align = middle>    </td></table><p>&nbsp;<p>These are my personal opinions of various RISC OS assemblers that are available. I have noted theversions tested, if a comment has been addressed in a later version, do let me know!<p>&nbsp;<p>This is the test program:<pre>r0 RN  0        AREA |main|, CODE, READONLY        ENTRY        ADR    r0, title        SWI    &02         ; OS_Write0        SWI    &10         ; OS_GetEnv        SWI    &02         ; OS_Write0        SWI    &03         ; OS_NewLine        SWI    &11         ; OS_Exittitle        =      "This program was called with:", 10, 13, "   ", 0        ALIGN        END</pre>When run, the program outputs a short title, followed by the command line that started theprogram. For example:<table width="100%"><tr bgcolor="#000000"><td><pre><font color = "#ffffff">TaskWindow Server v0.01*catDir. IDEFS::Willow.$.Coding.Projects.Assembler.apcstest Option 00 (Off) CSD  IDEFS::Willow.$.Coding.Projects.Assembler.apcstestLib. IDEFS::Buffy.$.libraryURD  Unseto            D/      s            D/     test         WR/*test -this -is a -testThis program was called with:   test -this -is a -test*</font></pre></td></tr></table><p>&nbsp;<p><h2>AAsm</h2>(v2.00, Acorn, expensive)<p>This is a simple assembler that doesn't support areas, and it outputs an Absolute file (there isno linker stage). It is sorta a stripped-down objasm with built-in linker, a throw-back to thedays of old prior to the DDE and C code (once upon a time, Acorn suggested that majorapplications would be written in pure assembler; then, they also once suggested that majorapplications would be implemented as relocatable modules - duh!).<br>Removing the AREA and ENTRY lines will allow the test file to compile correctly.<br>The output is 60 bytes long, as there is no AOF header.<p>&nbsp;<p><h2>ARMmaker</h2>(v0.52, Steven Haslam, freely downloadable)<p>I cannot get this to output AOF files. I define <b><code>ENTRY&nbsp;start</code></b> and<b><code>AREA&nbsp;main,&nbsp;CODE,&nbsp;READONLY</code></b> at the start of the program, andARMmaker replies &quot;<code>Entry point &quot;start&quot; not defined</code>&quot;.<br>I put this down to my unfamiliarity with the program. Asking ARMmaker to output an absolute fileworked, creating a 60 byte program (identical to AAsm's output).<p>The code used for ARMmaker was:<pre>r0 BINDREG R0        OUTPUT ABSOLUTEstart        ADR    r0, title        SWI    "OS_Write0"        SWI    "OS_GetEnv"        SWI    "OS_Write0"        SWI    "OS_NewLine"        SWI    "OS_Exit"title        DCS    "This program was called with:\n\r   "        DCB    0        ALIGN</pre>Like Nick Roberts' ASM, this assembler can convert SWI names for you. Sadly, it does not use the'RN' register assignment convention, but it's a minor point. In it's favour, it does understandC-style characters (&quot;\n\r&quot;).<p>&nbsp;<p><h2>AS</h2>(v1.21, Niklas R&#246;jemo, <a href="http://src.doc.ic.ac.uk/packages/archimedes/collections/hensa/programming/as.arc">download from <i>src.doc.ac.uk</i>'s HENSA mirror</a>) <font color = "red" size = "-1">[EXTERNAL LINK]</font><p>AS was quite happy with the original <i>objasm</i> input.<p>As a bonus, AS can also cope with SWI name conversions.<br>AS is not a 'better' version of objasm as it lacks the macro facilities and the more exoticfeatures of objasm. However, on the plus side it is supplied with source so you can add your owncustom bits, or look to see how an assembler works.<p>&nbsp;<p><a name="asm"></a><h2>ASM</h2>(v4.10, Nick Roberts,<a href="http://www.argonet.co.uk/users/tigger/programs/misc.html">download from Nick'swebsite</a>) <font color = "red" size = "-1">[EXTERNAL LINK]</font><p>I use <i>objasm</i> because I have used it in the past, and because I have a basic knowledge ofit. However, <i>objasm</i> has a main competitor... Actually, that's not really true.<i>objasm</i> kicks ass, but this, <i>ASM</i>, whips out a General Electrics Minigun and layswaste to swathes of ass. Well, it's an analogy I figured Glenn would like, so sue me.<tt>:-)</tt><p>One of the more complex (and powerful) of the free assemblers, ASM supports IF...THEN, macros,different processors, 32 bit code, includes, labels, maths in instructions (such as <code>DCFE12345.6 + (1 << 12)</code>), built-in assembly-time mathematical functions (sin, cos, tan, acs,etc etc), floating point code, NOPs, macros, full conditional assembly, structures (!!!),limited-scope labels, pragmas, and redefinable constants.<p>All in all, this may rate as <i>the</i> best assembler. <i>ASM</i> leaves <i>objasm</i>standing... Then again, it leaves the others standing too!<p>ASM failed to recognise the RN directive. This isn't a big issue, as the standard (r#) and APCSnames are understood by the assembler.<br>It allows name assignment, and can be used to write quite readable code. The documentationprovides us with:<pre>        result = 0        lhs = result + 1        rhs = lhs + 2                        EXPORT  Long_Add        ; Make the function externalLong_Add:       STMFD   sp!,{lhs ,lhs+1,link}                ADDS    lhs,lhs,rhs                ADCS    lhs+1,lhs+1,rhs+1     ...etc...</pre>The example has been snipped for space reasons. While <i>objasm</i> allows variables to benamed, I am not sure it is <i>that</i> flexible. Note the final ADCS instruction.<p>ASM requires that labels are suffixed with a colon and, like ARMmaker, it wasn't happy with thestring syntax so the more traditional EQUS/EQUB has been used.<br>END was not required, and as you can see ASM is capable of converting SWI names on the fly.<br>I am describing the differences in ASM so verbosely not because I want to pick on ASM, butbecause I feel that Nick's minor changes (such as the colon) and the SWI conversion all make formuch tidier looking code. I also like the EQUx directives, I use them in BASIC and feel happierwith them than with DCx or stuff like '='.<p>The code used for ASM was:<pre>        AREA main, CODE, READONLY        ENTRY startstart:        ADR    r0, title        SWI    "OS_Write0"        SWI    "OS_GetEnv"        SWI    "OS_Write0"        SWI    "OS_NewLine"        SWI    "OS_Exit"title:        EQUS   "This program was called with:\n\r   "        EQUB   0        ALIGN</pre><p>As always, a descriptive manual is supplied in Impression or text format.</i><br><a href="http://www.argonet.co.uk/users/tigger/programs/misc.html">Download ASM</a> <font color = "red" size = "-1">[EXTERNAL LINK]</font><p>&nbsp;<p><h2>objasm</h2>(v2.00, Acorn, expensive)<p>This was used as the benchmark (being Acorn's own), so was obviously happy with the input!<br>A capable assembler, this was supplied with the Acorn Desktop assembler package. A later and morecapable (ie, later processors/facilities) version is now provided with Acorn's C++ developmentsuite.<br>Being a macro assembler, it has <i>very</i> powerful options for devising macros, although thesyntax is a bit difficult for a newbie.<br>Here's an example from the 32bit development release:<pre><font size = "-1">; ****************************************************; ***  SCPSR - Set and clear bits in PSR from the  ***; ***  masks $set, $clr, using register $regtmp    ***; ****************************************************        MACRO$label  SCPSR   $set, $clr, $regtmp, $cond, $oldpsr        LCLS    srcreg        [ &quot;$oldpsr&quot;=&quot;&quot;srcreg  SETS    &quot;$regtmp&quot;        |srcreg  SETS    &quot;$oldpsr&quot;        ]$label  mymrs   $cond, $srcreg, CPSR        [ (($set) :AND: ($clr)) &lt;&gt; 0        ! 1, &quot;Attempt to simultaneously set and clear a bit in SCPSR&quot;        ]CPU32_set PSRto32 $setCPU32_clr PSRto32 $clr [ (CPU32_set :AND: &amp;F0000000) &lt;&gt; 0 :LAND: (CPU32_set :AND: &amp;F0) &lt;&gt; 0        ORR$cond $regtmp, $srcreg, #CPU32_set :AND: &amp;F0000000        ORR$cond $regtmp, $regtmp, #CPU32_set :AND: &amp;0FFFFFFFsrcreg  SETS &quot;$regtmp&quot; | [ CPU32_set &lt;&gt; 0        ORR$cond $regtmp, $srcreg, #CPU32_setsrcreg  SETS &quot;$regtmp&quot; ] ] [ (CPU32_clr :AND: &amp;F0000000) &lt;&gt; 0 :LAND: (CPU32_clr :AND: &amp;F0) &lt;&gt; 0        BIC$cond $regtmp, $srcreg, #CPU32_clr :AND: &amp;F0000000        BIC$cond $regtmp, $regtmp, #CPU32_clr :AND: &amp;0FFFFFFFsrcreg  SETS &quot;$regtmp&quot; | [ CPU32_clr &lt;&gt; 0        BIC$cond $regtmp, $srcreg, #CPU32_clrsrcreg  SETS &quot;$regtmp&quot; ] ]        somemsr  $cond, CPSR,$srcreg, CPU32_set:OR:CPU32_clr        MEND</font></pre><p>&nbsp;<p><h2>TLA</h2>(v0.1f, G.F.A.@ Lancaster, <a href="http://sunsite.doc.ic.ac.uk/packages/archimedes/collections/uni-stuttgart/acornet/long/development/assembler/tla.arc">download from <i>sunsite</i>'sarchives<a>) <font color = "red" size = "-1">[EXTERNAL LINK]</font><p>TLA is a very peculiar assembler. It appears to have a central core which is machine independentalong with various opcodes for the ARM processor.<br>It is obscure (in my opinion), and I wasn't able to get an ADR style instruction assembled. Tobe precise, the OS_Write0 example (in the documentation) crashed with the same error (branchthrough zero at &lt;some address in ROM&gt;).<br>But, for interests sake, I have recoded the program to work with TLA, though I would recommenda different assembler - something that is closer to the DDE style.The code used for TLA was:<pre>        .ENTRY start        .CODEAREA        .PROC mainstart        SWI    OS_WriteS        .ASCII "This program was called with:"        SWI    OS_NewLine        SWI    OS_WriteS        .ASCII "   "        SWI    OS_GetEnv        SWI    OS_Write0        SWI    OS_NewLine        SWI    OS_Exit        .END</pre><p>&nbsp;<p>&nbsp;<p><hr size = "3"><a href="index.html#08">Return to assembler index</a><hr size = "3"><address>Copyright &copy; 2001 Richard Murray</address></body></html>

⌨️ 快捷键说明

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