home *** CD-ROM | disk | FTP | other *** search
/ ftp.uni-stuttgart.de/pub/systems/acorn/ / Acorn.tar / Acorn / acornet / dev / assembler / extasm.spk / !extASM / Manuals / !Manual < prev    next >
Text File  |  1995-07-12  |  52KB  |  1,584 lines

  1. =====================================================================
  2.                    extASM v1.00 - Users Manual
  3. =====================================================================
  4.  
  5. Contents
  6. --------
  7. 1.   Introduction
  8. 2.   Conditions of use
  9. 3.   Starting extASM
  10.  
  11. 4.   Windows
  12. 4.1  Icon bar icon
  13. 4.2  Menu
  14.  
  15. 4.3  Process
  16. 4.4  Status Info
  17. 4.5  Options
  18.  
  19. 5.   Switches
  20. 6.   Extra instructions/statements
  21.  
  22. 7.   Miscellaneous
  23. 7.1  Extra info
  24. 7.2  Case sensitivity
  25. 7.3  Register binding
  26. 7.4  Values
  27. 7.5  Value types
  28. 7.6  Operators
  29. 7.7  Local variables
  30. 7.8  FP instruction precisions
  31. 7.9  Starting assembly from command line, or Obey file
  32. 7.10 Limits
  33. 7.11 Stack setup
  34. 7.12 Removing warning messages
  35. 7.13 Possible future features for extASM
  36.  
  37. 8.   Auto-expansion
  38. 9.   Auto-expanding technical section
  39. 9.1  Instruction changing
  40. 9.2  Auto-expansion method
  41. 9.3  PSR setting for auto-expansion
  42. 9.4  Auto-expanding instructions
  43.  
  44. 10.  ARM and FPA pie chart instructions
  45.  
  46. 11.  ARM instructions
  47. 12.  FPA instructions
  48.  
  49.  
  50. 1. Introduction
  51. ---------------
  52. extASM is an extended assembler for ARM RISC Processors.
  53. Å Complete ARM 2/3/6 and FPA10 instruction set.
  54. Å Interactive WIMP interface.
  55. Å Smart auto-expanding instruction-set.
  56. Å Written in assembly code.
  57. Å Can produce object code in AOF (ARM Object Format) with the aid of the 
  58.   extAOF application, which is bundled with extASM. This function may
  59.   be incorporated later into extASM.
  60.  
  61. 2. Conditions of use
  62. --------------------
  63. This program is Shareware. See the !Help file for the legalities and how to
  64. register.
  65.  
  66. ⌐ 1995 Eivind Hagen & Terje Sletteb°
  67.  
  68. 3. Starting extASM
  69. ------------------
  70. Double click on the application. It will then install itself on the 
  71. iconbar.
  72.  
  73.  
  74. 4. Windows
  75. ---------------------------------------------------------------------
  76. 4.1 Iconbar icon
  77. ----------------
  78. SELECT - Open Process window
  79. MENU   - Open menu
  80. ADJUST - Open Status-info window
  81. Drag:    Drag the source file to the icon-bar icon to load, and start 
  82.          assembly process. You can also drag the source into the PROCESS 
  83.          window.
  84.  
  85.          The OS-variable "Tmp$Dir", which can be used in the assembly 
  86.          source, is set to the same directory as the source. If no path 
  87.          is available, it is set to the currently selected directory.
  88.  
  89. 4.2 Menu
  90. --------
  91. Info     - This leads to the Info window. Click to get StrongHelp help 
  92.            about extASM. If the StrongHelp application has been seen, it 
  93.            will be loaded.
  94.  
  95.            The extASM StrongHelp help has almost exactly the same
  96.            information as that given in this file, since the text in the
  97.            help is copied from this file. The only difference between the
  98.            two manual versions is that the StrongHelp version doesn't have
  99.            the 'Contents' index, and things like that, since it is 
  100.            organized slightly differently from this manual file.
  101.  
  102. Options  - This leads to the Options window. Click to open the Options 
  103.            window.
  104. Misc     - This leads to the Miscellaneous menu
  105. Abort    - Abort assembly
  106. Pause    - Pause assembly
  107. Continue - Continue assembly after Pause is selected
  108. Quit     - Quit program
  109.  
  110. Miscellaneous menu
  111. ------------------
  112. Save Status - This leads to a save window where you can save the Status 
  113.               Info text.
  114. Colours     - This leads to the Colours menu where you can select the 
  115.               colours in the Status Info window.
  116. ARM         - This leads to a pie chart window which shows the distribution 
  117.               of the ARM instruction groups. Click to open the window. 
  118.               The 'Code statistics' option must have been selected before 
  119.               the last assembly.
  120. FPA         - This leads to a pie chart window which shows the distribution 
  121.               of the FPA instruction groups. Click to open the window. 
  122.               The 'Code statistics' option must have been selected before 
  123.               the last assembly.
  124. Radius      - This leads to a menu where you can select the radius of the 
  125.               ARM and FPA pie charts.
  126. Min. lines  - This leads to a menu where you can select the minimum number
  127.               of lines in the Status-info window. This is the y-size it 
  128.               will resize to when it is cleared, when a new file is 
  129.               loaded.
  130.  
  131.  
  132. 4.3 Process window
  133. ------------------
  134. Reload - Reload the last source file.
  135.  
  136. Source box
  137. ----------
  138. Name - Edit this if you want to reload another source file.
  139.  
  140. Object box
  141. ----------
  142. File - Drag to save.
  143. Save - Click to save.
  144. Name - Edit this if you want another object file name.
  145.  
  146.  
  147. 4.4 Status-info window
  148. ----------------------
  149. All messages appear here!
  150.  
  151.  
  152. 4.5 Options window
  153. ------------------
  154. Auto Shrink
  155. -----------
  156. When this is on, it will try to shrink the code again, if at a later pass 
  157. it turns out that a smaller statement can be used or no auto-expansion is 
  158. needed. As it is now, a NOP is inserted after a statement if it shrinks, 
  159. to avoid recalculating offsets etc.
  160.  
  161. When this option is on it will make the most efficient code, but it may use
  162. more passes. It may also not succeed at all, and in this case, a warning
  163. will be given and it will temporarily turn off the auto-shrink option (for
  164. the current assembly). The maximum number of passes before this happens is
  165. 10.
  166.  
  167. Auto Save Object
  168. ----------------
  169. When this is on, it will save the object code after assembly.
  170.  
  171. Auto Run after Save
  172. -------------------
  173. When this is on, it will run the object file after assembly.
  174.  
  175. Use default header
  176. ------------------
  177. When this is on, it will also assemble the file called "Header" in the 
  178. "Resources" directory. This file can be changed if wanted.
  179.  
  180. Auto Pop PROCESS window
  181. -----------------------
  182. When this is on, the PROCESS window will be opened, if not opened, and 
  183. put at the top when a file is loaded.
  184.  
  185. Auto Pop STATUS window
  186. ----------------------
  187. When this is on, the STATUS window will be opened, if not opened, and 
  188. put at the top when a file is loaded.
  189.  
  190. Auto Expand
  191. -----------
  192. When this is on it will give a message when it auto-expands a statement.
  193.  
  194. This can be very useful for "profiling" your code, in that you can see 
  195. where it is auto-expaneded. Then you can reserve TEMP-registers if you 
  196. want, or move data closer, to make less auto-expanding. More about 
  197. auto-expanding later. At the end of the listing, an auto-expansion 
  198. summary will be displayed. It will also show how many FP values are 
  199. stored at each #fppool.
  200.  
  201. The 'Number of Fast-NOPs' printed is the number of ADR instructions that 
  202. are expanded using a NOP, i.e. no auto-expansion was necessary. This may 
  203. happen if the 'Fast' option is on (ADRs are minimum 16-bit, described 
  204. below) or if the 'ADRL' (long ADR) form of of the ADR is used, which 
  205. means use the 'Fast' option for this instruction.
  206.  
  207. The 'Number of Fallback NOPs' printed is the number of ADR instructions 
  208. that have been auto-expanded, but were at a later pass found to need less 
  209. or no auto-expansion (because the address became aligned in some way, 
  210. e.g. from &FFFC to &10000). extASM will then insert a NOP (MOV R0,R0) 
  211. after the ADR, to give the same length as previous passes, so that 
  212. offsets in other parts of the program do not have to be recalculated.
  213.  
  214. If the 'Auto Shrink' option is on (described above), it will shrink the 
  215. code again instead of inserting a NOP after an ADR.
  216.  
  217. Summary
  218. -------
  219. When this is on, only the summary will be printed when the 'Auto Expand' 
  220. option is turned on.
  221.  
  222. Only ADR and Load/Store
  223. -----------------------
  224. When this is on, only auto-expanding of ADRs and load/store instructions 
  225. will be displayed. The 'Auto Expand' option must be on.
  226.  
  227. Unused variable warning
  228. -----------------------
  229. When this is on, extASM will give a warning about any variables which are 
  230. not used by the program.
  231.  
  232. Code statistics
  233. ---------------
  234. When this is on, it will show code statistics. This also makes it possible 
  235. to display the two pie charts, from the menu, showing the distribution of 
  236. the ARM and FPA instruction groups. The statistics given are:
  237.  
  238.    Å The number of each ARM instruction, and the total number of ARM 
  239.      instructions
  240.    Å The number of each FPA instruction, and the total number of FPA 
  241.      instructions
  242.    Å The total number of instructions.
  243.    Å The number of each condition code, and the total number of condition 
  244.      codes
  245.    Å The number of each shift type (type and register/constant shift), and 
  246.      the total number of shifts.
  247.    Å The number of 'constant' shifts, that is when a constant is shifted 
  248.      to produce the constant wanted, like: "MOV   R1,#&FF000000"
  249.  
  250. All statistics are based on the source code, except the constant shifts, 
  251. which are based on the generated code. Therefore if you e.g. have an 
  252. auto-expanding MOV, it will still be counted as one MOV, and not one 
  253. MOV followed by one ORR, which may be the generated code.
  254.  
  255. Macro
  256. -----
  257. When this is on, code in macros, when they are called, will also be counted 
  258. in the code statistics.
  259.  
  260. Variable listing
  261. ----------------
  262. When this is on, it will show the variable list, optionally sorted, and 
  263. macro list. It will also show the number of references to each variable, 
  264. and the number of times each macro is called.
  265.  
  266. Sort
  267. ----
  268. When this is on, the variable list will be sorted.
  269.  
  270. No-period labels
  271. ----------------
  272. When this is on, labels can be specified without a period in front of them.
  273. All other assembly statements must then be indented by one or more spaces 
  274. or TABs.
  275.  
  276. Make AOF format
  277. ---------------
  278. When this is on, extASM will produce an object file in ARM Object Format, 
  279. which can then be linked with e.g. C.
  280.  
  281. This is done with the aid of extAOF, which is bundled with extASM. This
  282. function may later be incorporated into extASM. The following statements 
  283. are used:
  284. '#area', '#end', '#import', '#export', '#entry' and '#%'. 
  285. They are ignored by extASM, but used by the extAOF application.
  286.  
  287. Throwback
  288. ---------
  289. When this is on, extASM will also use Throwback to display errors, warnings
  290. and 'output' statement etc., so any editor which has Throwback can display
  291. them.
  292.  
  293. Auto scroll
  294. -----------
  295. When this is on, the STATUS window will scroll to the end, when new 
  296. messages are added.
  297.  
  298. Fast
  299. ----
  300. When this is on, it will auto-expand all ADRs to minimum 16-bit (two 
  301. instructions). This may reduce the number of passes, at the expense of 
  302. more NOPs. However, it is recommended that you use the new 'relative' 
  303. statement to reduce auto-expanding, and then use the new 'ADRL' 
  304. (minimum 16-bit ADR) where it is needed.
  305.  
  306.  
  307. 5. Switches
  308. ---------------------------------------------------------------------
  309. Switches must be at the first non-blank character of a line. A switch may 
  310. follow another switch on a line, separated by a colon.
  311.  
  312. Most of the switches are actually handled by the Assembler, and not the 
  313. Preprocessor. This is so that variables and expressions etc. can be used 
  314. as parameters.
  315.  
  316. However, many of them are often used anyway in the Preprocessor, to 
  317. determine the number of variables and macros so that the right amount of 
  318. memory can be reserved for them. Since 'hashing' is used for variable and 
  319. macro searching (which makes it very fast), the assembler needs to reserve 
  320. the maximum space needed for variables and macros, before any variables or 
  321. macros are stored. The only switches that are handled completely by the 
  322. Preprocessor are:
  323.  
  324. #name
  325. #include
  326. #speed
  327.  
  328.  
  329. #name <objectname>
  330. ------------------
  331. Set name of object file. Default "Object".
  332.  
  333.  
  334. #base <address>
  335. ---------------
  336. Set base address for assembly. Default &8000.
  337. If it is used, this must be used before any assembler instructions.
  338.  
  339. #type <filetype>
  340. ----------------
  341. Set type of object file. Default &FF8.
  342.  
  343. #load <address>
  344. ---------------
  345. Set object load address (type must be 0). Default 0.
  346.  
  347. #exec <address>
  348. ---------------
  349. Set object exec address (type must be 0). Default 0.
  350.  
  351.  
  352. #include <filename>
  353. -------------------
  354. Includes another source file, like in C.
  355.  
  356.  
  357. #set <variable> = <expression>
  358. ------------------------------
  359. Set integer value of <variable> to that of <expression>.
  360.  
  361. #fpset <FP-variable> = <expression>
  362. -----------------------------------
  363. Set Floating Point value of <FP-variable> to that of <expression>. The 
  364. number is stored in maximum precision ('E' - Extended) format.
  365.  
  366. All expressions using FP values are evaluated with the maximum precision. 
  367. Integer and Floating Point operands will will be automatically cast to the 
  368. other, if it is required by the operation. The same goes for the result, 
  369. if it is required by the variable it is stored in, or the instruction which 
  370. uses the value. When a FP value is cast to integer, it is rounded by 
  371. discarding the decimals.
  372.  
  373. #strset <String-variable> = <expression>
  374. ----------------------------------------
  375. Set <String-variable> to that of <expression>. 
  376.  
  377. #if <expression>
  378. ----------------
  379. Assemble code if <expression> if TRUE (non-zero)
  380. Part of the #if-#else-#endif construction.
  381. #if's may be nested
  382.  
  383. #else
  384. -----
  385. Assemble from here if #if was FALSE (zero)
  386.  
  387. #endif
  388. ------
  389. End #if/#else conditional assembly
  390.  
  391.  
  392. #rept <number>
  393. --------------
  394. Repeat code <number> times
  395. The code is ended with #endr.
  396. #rept's may be nested
  397.  
  398. #endr
  399. -----
  400. End of code to be repeated (after a #rept)
  401.  
  402.  
  403. #fppool [<Register> [,<Offset>]]
  404. --------------------------------
  405. This tells the assembler where Floating Point values can be stored, when 
  406. FP-instructions are auto-expanded. The assembler will store FP-values at 
  407. the address of the next "#fppool" statement. If the range to this is less 
  408. than 1020 bytes, the LDF instruction used in the auto-expansion does not 
  409. have to be expanded as well as the FP-instruction.
  410.  
  411. If <Register> is used, then <Register> will be used as the "relative" 
  412. register in the LDF, instead of the usual R15. <Register> must then be 
  413. set up before any FP instruction that may be auto-expanded is used. 
  414. <Offset> makes the address of the values start from <Offset>. This means 
  415. that you can take advantage of the +/- sign of the LDF that loads the 
  416. value. If you set the register to point at the address of the 
  417. #fppool + Offset, the <Offset> should be set to -Offset.
  418.  
  419. #format <number-format>
  420. -----------------------
  421. Set format for converting Floating Point values in the 'STR$(num)' function
  422. or the 'output' command. See below. Default &1100 (General, 17 digits).
  423.  
  424. #smile
  425. ------
  426. Gives a smile when life is good :-) (no errors in assembly). Default off.
  427.  
  428. #speed <lines>
  429. --------------
  430. Set number of lines to assemble each Wimp-Poll. Default 256.
  431.  
  432.  
  433. AOF switches
  434. ------------
  435. The use of these switches is explained in the !AOFManual file. Here is 
  436. just a summary.
  437.  
  438. #area <Name> [,code|noinit] [,readonly]
  439. ---------------------------------------
  440. Start an area
  441.  
  442. #end
  443. ----
  444. End an area (it doesn't have to be used if a new #area follows after 
  445. another #area)
  446.  
  447. #import <Variable>
  448. ------------------
  449. Reference an external symbol
  450.  
  451. #export <Variable>
  452. ------------------
  453. Define a symbol
  454.  
  455. #entry
  456. ------
  457. Set entry point for AOF file (address to start program)
  458.  
  459. #% <Size>
  460. ---------
  461. Set size of zero-initialised area
  462.  
  463.  
  464. #format syntax
  465. --------------
  466. This assembler switch determines how FP-numbers shall be formatted in 
  467. the "STR$(num)" function, and the "output" statement. This is about the 
  468. same as the @% variable in Basic.
  469.  
  470. Byte (byte 4 is MSB, byte 1 is LSB)
  471. -----------------------------------
  472. 4     - Not used
  473. 3     - Format type
  474.         0 - General format. Numbers have the form nnn.nnn. Trailing zeros 
  475.             are skipped. If the number is bigger than the field width, or 
  476.             less than 0.001, the Exponent format is used instead.
  477.         1 - Exponent format. Numbers have the form n.nnnEnn. The number of 
  478.             digits printed is given in the field width.
  479.         2 - Fixed format. Numbers have the form nnn.nnn. If the number is 
  480.             bigger than the width of the precision (18 digits), the 
  481.             Exponent format is used instead.
  482. 2    - Field width. This is the number of digits printed. For Fixed 
  483.        format, it gives the number of decimals printed.
  484. 1    - Not used.
  485.  
  486.  
  487. 6. Extra instructions/statements
  488. ---------------------------------------------------------------------
  489. ADR
  490. DIV
  491. EXG
  492.  
  493. ALIGN
  494.  
  495. DCx
  496. DCFx
  497. DBx
  498. DBFx
  499.  
  500. INCBIN
  501. STRUCT
  502. RELATIVE
  503. MACRO
  504.  
  505. TEMP
  506. LOCK
  507.  
  508. OUTPUT
  509.  
  510.  
  511. Extra instructions
  512. ------------------
  513. ADR
  514. ---
  515. Get address.
  516.  
  517. Syntax:    ADR[CC]   Rd,<Label>
  518. Operation: Rd = Address of <label>
  519.  
  520. Examples of use:
  521.  
  522. ADR      R1,Data_Block
  523.  
  524. ADRL
  525. ----
  526. Minimum 16-bit ADR.
  527.  
  528. This is the same as ADR, except that it assembles to minimum 16 bit 
  529. (two instructions) (long ADR). It's the same as setting the 'Fast' option 
  530. for this ADR. Using this for the ADR instructions that needs it can reduce 
  531. the number of passes.
  532.  
  533. extASM will continue to assemble until two passes have the same length 
  534. and all variables are resolved. Therefore, if you specify ADR's as 
  535. minimum 16-bit then they will auto-expand to that the first time, 
  536. instead of maybe a later pass, if it uses a forward referencing label.
  537.  
  538.  
  539. DIV
  540. ---
  541. Integer division.
  542.  
  543. Syntax:    DIV[CC]   Rd,Rn,Rs
  544. Operation: Rd = Rn DIV Rs
  545.            Rn = Rn MOD Rs
  546. Notice:    Rd, Rn & Rs must be uniqe.
  547. Extra:     Uses 1 Temp Register.
  548.  
  549. Examples of use:
  550.  
  551. DIV      R1,R4,R7
  552. DIVLE    R10,R11,R12
  553.  
  554.  
  555. EXG
  556. ---
  557. Exhange contents of two integer registers.
  558.  
  559. Syntax:    EXG[CC]   Rd,Rn
  560. Operation: Rd = old Rn
  561.            Rn = old Rd
  562. Notice:    Rd must be different from Rn.
  563.  
  564. Examples of use:
  565.  
  566. EXG      R1,R2
  567. EXGLT    R3,R9
  568.  
  569.  
  570. Statements
  571. ----------
  572. ALIGN
  573. -----
  574. Alignment of Code & Data
  575.  
  576. Syntax: ALIGN [Boundary] [,Offset]
  577. Notice: The assembler will issue warnings if code is not word-aligned, but
  578.         it will not warn if data is not word-aligned (bytes...).
  579.  
  580. It aligns the code to a chosen boundary and offset. (default boundary is 4
  581. (word) and offset 0). Offset means that after <Offset> bytes, the pointer
  582. will be <Boundary> aligned.
  583.  
  584. Examples of use:
  585.  
  586. ALIGN
  587.  
  588. ALIGN 16,4              ; Cache-alignment
  589. DCD   0                 ; This will not be aligned
  590. .Start                  ; But this will be!
  591.  
  592.  
  593. Constant Declarations
  594. ---------------------
  595. DCB    Declare Constant Byte, also used for strings.
  596. DCW    Declare Constant Word (16 bit).
  597. DCD    Declare Constant Doubleword (32 bit).
  598. DCFS   Declare FP-Constant, Single precision (32 bit)
  599. DCFD   Declare FP-Constant, Double precision (64 bit)
  600. DCFE   Declare FP-Constant, Extended precision (96 bit)
  601. DCFP   Declare FP-Constant, Packed BCD (96 bit)
  602. DCFEP  Declare FP-Constant, Extended Packed BCD (128 bit)
  603.  
  604. Syntax:  <DCB | DCW | DCD | DCFS | DCFD | DCFE | DCFP | DCFEP> 
  605.          <Const> {,<Const>}
  606. Special: DCB <Const | String> {,<Const | String>}
  607. Where:   Const is any legal expression, and String is any string.
  608.  
  609. Examples of use:
  610.  
  611. DCB   0
  612. DCB   1,2,3
  613. DCB   "Text",0,"More text","Yet more ""and in quotes"", 
  614.                  <10> Linefeed" 10,13,0
  615. DCB   "More quotes |"Some text|", the following is taken 
  616.                literally |<10>","<Some$Var>"
  617. DCW   10000,20000,30000,101,102,103
  618. DCD   -1,-2,-3,1 << 16,1 << 24,1 << 30
  619. DCD   Label_1,Label_4-Label_3,&8000+Offset_to_something
  620. DCFS  1.23
  621. DCFD  123.4E10
  622. DCFE  0.00123E-20
  623. DCFP  -1.23
  624. DCFEP 123
  625.  
  626. Block Declarations
  627. ------------------
  628. DBB    Declare Block of Bytes.
  629. DBW    Declare Block of Words (16 bit).
  630. DBD    Declare Block of Doublewords (32 bit).
  631. DBFS   Declare Block of FP-Constant, Single precision (32 bit)
  632. DBFD   Declare Block of FP-Constant, Double precision (64 bit)
  633. DBFE   Declare Block of FP-Constant, Extended precision (96 bit)
  634. DBFP   Declare Block of FP-Constant, Packed BCD (96 bit)
  635. DBFEP  Declare Block of FP-Constant, Extended Packed BCD (128 bit)
  636.  
  637. Syntax: 
  638.  <DBB | DBW | DBD | DBFS | DBFD | DBFE | DBFP | DBFEP> Size [, Const]
  639. Where:  Size is how many items in the block (bytes, words or doubles).
  640.         Const is the value of each item, default 0.
  641.  
  642. Examples of use:
  643.  
  644. DBB   1024,&FF
  645. DBW   100,%0110110101010100
  646. DBD   512
  647. DBFS  10,1.23
  648. DBFD  4,123
  649. DBFE  100
  650. DBFP  20,123E10
  651. DBFEP 10,123.4
  652.  
  653.  
  654. Including binary file (data-file)
  655. ---------------------------------
  656. INCBIN
  657. ------
  658. Include binary file.
  659.  
  660. Syntax:  INCBIN <filename>
  661. Where:   <filename> is the data-file to insert.
  662. Notice:  Space is automatically allocated for the file, and is 
  663.          byte-aligned.
  664.  
  665. Examples of use:
  666.  
  667. .SinTable   incbin   "<Tmp$Dir>.Tables.SinusTable"
  668.  
  669.  
  670. Structures
  671. ----------
  672. Structures let you combine several data-types to make a complex data-type. 
  673. Most high-level languages support such mechanisms, and now you can benefit 
  674. from this useful technique in assembly level programming as well.
  675.  
  676. The labels inside the structure will start at zero (or <Offset>). If you 
  677. use <Step>, then the address will increase by <Step> for each line. You 
  678. can also have nameless structures.
  679.  
  680. Syntax:
  681. -------
  682. STRUCT [<Name>] [,#<Offset>] [,<Step>]
  683. {
  684. <Data>
  685. }
  686.  
  687. Here are some examples:
  688.  
  689. Here's how to make a simple structure:
  690.  
  691. struct Mouse
  692. {
  693.    .X_Pos       DCD   0
  694.    .Y_Pos       DCD   0
  695.    .Buttons     DCD   0
  696.    .Size                             ; .Size = size of struct! (end...)
  697. }
  698.  
  699. To allocate some static space for an instance of this data-type do this:
  700.  
  701. .MouseBlock
  702.    DBB   Mouse.Size,0                ; Declare block of right size
  703.    ALIGN                             ; Just in case it wasn't aligned...
  704.  
  705. Easy! Now, to address directly into this area, here's how:
  706.  
  707.    SWI      OS_Mouse
  708.    STR      R0,MouseBlock + Mouse.X_Pos
  709.    STR      R1,MouseBlock + Mouse.Y_Pos
  710.    STR      R2,MouseBlock + Mouse.Buttons
  711.  
  712. Or, if you have a register pointing to the data-area, you can:
  713.  
  714.    SWI      OS_Mouse
  715.    ADR      R9,MouseBlock
  716.    STR      R0,[R9,#Mouse.X_Pos]
  717.    STR      R1,[R9,#Mouse.Y_Pos]
  718.    STR      R2,[R9,#Mouse.Buttons]
  719.  
  720.  
  721. struct List,#&1000
  722. {
  723.    .Code1   DCD   0      ; List.Code1 = &1000
  724.    .Code2   DCD   0      ; List.Code2 = &1004
  725.    .Code3   DCD   0      ; List.Code3 = &1008
  726. }
  727.  
  728. struct #&400C0,1
  729. {
  730.  .Wimp_Initialise   ; Wimp_Initialise = &400C0  
  731.  .Wimp_CreateWindow ; Wimp_CreateWindow = &400C1
  732.  .Wimp_CreateIcon   ; Wimp_CreateIcon  = &400C2
  733.  ; This is not needed as extASM works out SWI numbers itself
  734. }
  735.  
  736.  
  737. Structures can also be nested, so you can write something like:
  738.  
  739. struct Person
  740. {
  741.    struct Name
  742.    {
  743.       .First   DCD   0
  744.       .Last    DCD   0
  745.    }
  746.    .Address
  747. }
  748.  
  749. This can be accessed by:
  750.  
  751.    LDR      R1,[R9,#Person.Name.First]
  752.    LDR      R2,[R9,#Person.Name.Last]
  753.    LDR      R3,[R9,#Person.Address]
  754.  
  755.  
  756. 'Relative' statement
  757. --------------------
  758. You can designate an area with labels as relative to a register other than
  759. the usual R15, for Load/Store and ADR. This way you can have one register 
  760. pointing to a data area, and then you can save a lot of auto-expansion. 
  761. The register will then be closer to the area than R15, when used in the 
  762. Load/Store or ADR.
  763.  
  764. The statement is like 'struct', because the labels inside the statement 
  765. start at zero (or <Offset>). One difference is that whereas 'struct' only 
  766. makes a 'template' of the data, assigning only the labels, not storing the 
  767. data, 'relative' executes the source inside the statement as normal. The 
  768. data and code there is retained.
  769.  
  770. If the 'virtual' parameter is used, then only the labels are stored, and 
  771. not the data, as with 'struct'. This can be handy because the object file 
  772. need be no bigger than necessary, or be filled with unnecessary data, if 
  773. the data are initialised at run-time.
  774.  
  775. The variables and labels that are assigned inside the statement are marked 
  776. specially, so that they will be coded as relative to <Register> when used 
  777. with ADR or Load/Store. You will get the usual value when they are used in
  778. other places.
  779.  
  780. Syntax:
  781. -------
  782. RELATIVE <Register> [,<Offset>] [,virtual]
  783. {
  784. <Data>
  785. }
  786.  
  787. For example:
  788.  
  789. relative R12
  790. {
  791. .Label   DCD   0             ; Label  = 0
  792. .Label2  DCD   0             ; Label2 = 4
  793. }
  794.  
  795. ADR      R1,Label            ; Coded as 'ADD   R1,R12,#Label'
  796. LDR      R2,Label2           ; Coded as 'LDR   R2,[R12,#Label2]'
  797. LDFS     F3,Label            ; Coded as 'LDFS  F3,[R12,#Label]'
  798.  
  799.  
  800. If you use the offset you can have twice the amount of data without 
  801. auto-expansion, as you can then use the sign-capability of ADR and 
  802. Load/Store. ADR can access +/- 1K (word-aligned, or else it is +/- 255 
  803. bytes), and LDR/STR can access +/- 4K.
  804.  
  805. relative R10,-16,virtual     ; 'Virtual' parameter, so only the labels are
  806. {                            ; assigned, no data is stored
  807. .Label   DBD   4             ; Label  = -16   
  808. .Label2  DBD   4             ; Label2 = 0    
  809. .Label3  DBD   4             ; Label3 = 16
  810. }
  811.  
  812.  
  813. Macros
  814. ------
  815. The use of macros makes it easier to do things routinely, and can be a very 
  816. powerful tool in making complex code. A macro can be defined anywhere in 
  817. the source, and it is smart to have a standard file of all your standard 
  818. macros, so that you can easily include this into any other programs you 
  819. write.
  820.  
  821. Syntax:
  822. -------
  823. macro <Name>[$<CCVar>] [<Parameter1>:<Type1> {,<Parameter2>:<Type2>} ]
  824. {
  825. <Code>
  826. }
  827.  
  828. The macro header must be the first non-blank character on a line.
  829.  
  830. Macros can take five different passing-parameters, and use seven different 
  831. parameters. The additional use-parameters are temp-registers.
  832.  
  833. Macro condition-codes
  834. ---------------------
  835. You can even have condition-codes for the macros, so that they can make 
  836. new instructions. This can be done by using "$<VarName>" after the macro 
  837. name in the definition. The variable <VarName> will then contain the 
  838. integer condition code (0-15).
  839.  
  840. This can be used by instructions in the macro, by using "$<varname>" after
  841. any of the instructions. In fact, the "<Instruction>$<VarName>" 
  842. construction can be used anywhere in the program, not just in macros.
  843.  
  844. Using macros with condition code can also be handy for debugging. You can
  845. e.g. have a macro call like this: 'PrintCCEQ "The condition code is EQ"'
  846. (the macro name is "PrintCC").
  847.  
  848. If there are characters after the condition code variable, then you can
  849. terminate the variable name with '#', like this:
  850.  
  851. MOV$CC#S   R1,#1
  852. LDM$CC#FD  R1,{R2-R4}
  853.  
  854.  
  855. Macro parameters
  856. ----------------
  857. The five passing-parameter types are:
  858.  
  859.     Type                   Variable type for parameter in macro
  860.     -----------------------------------------------------------
  861.     R    Register          Integer
  862.     F    FP-Register       Integer
  863.     I    Integer           Integer
  864.     X    FP-value          FP
  865.     S    String            String
  866.  
  867. The last two use-only parameters are:
  868.  
  869.     TR   Temp register      Integer
  870.     TF   Temp FP-register   Integer
  871.  
  872. The passing-parameters are the arguments sent from the source upon using 
  873. the macro, and they translate to the parameter variables inside the macro. 
  874. The parameter-variables are local in the macro.
  875.  
  876. The macro temp-registers are additional registers that the macro needs to 
  877. do the job. The temp-registers will be allocated by the assembler 
  878. automatically.
  879.  
  880. Note: If temp-registers are used and stacked, then only the
  881. registers in the header is allowed to be used in the macro, since the 
  882. register may otherwise have been allocated as a temp-register... 
  883. The assembler will give an error if this is done.
  884.  
  885. When allocating FP temp-registers that have to be stacked, the assembler 
  886. allocates subsequent registers, starting from the first free register. 
  887. This is so that SFM/LFM can be used for the stacking.
  888.  
  889. Because of this, when using FP temp-registers in a macro, the macro has to
  890. be called in such a way that there are enough free registers from the first
  891. free register and onwards, to accomodate for the FP temp-registers,
  892. otherwise there will be an error.
  893.  
  894. Here is an example of a macro.
  895.  
  896. ; Define macro
  897.  
  898. macro TEST$cc Reg:r,FPReg:f,Num:i,FPNum:x,Str:s,TempReg:tr,FPTempReg:tf
  899. {
  900.    ADD      Reg,TempReg,#Num
  901.    ADFS     FPReg,FPTempReg,#FPNum
  902.    DCB      Str,0
  903.    ADD$cc   Reg,#1
  904. }
  905.  
  906. TEST R1,F1,123,1.23,"A little string"  ; Call macro, condition code AL (&E)
  907. TESTEQ Reg,FPReg,1+2,sqr(3),"ABC"+"DEF"; Call macro, condition code EQ (&0)
  908.  
  909.  
  910. Temp Register Management
  911. ------------------------
  912. TEMP & FPTEMP   Mark a register as unused, so it can be used as a TempReg.
  913.  
  914. Syntax:   <TEMP | FPTEMP>   RegList
  915. Where:    Reglist is a list of registers, or register-ranges.
  916. Notice:   The contents of RegList is unsafe until it is LOCK'ed or 
  917.           FPLOCK'ed again.
  918.  
  919. Examples of use:
  920.  
  921. TEMP     R0
  922. TEMP     R1,R2,R8-R12
  923. FPTEMP   F0
  924. FPTEMP   F0,F1,F3-F7
  925.  
  926.  
  927. LOCK & FPLOCK  Reclaim a register after a it has been TEMP'ed or FPTEMP'ed.
  928.  
  929. Syntax:  <LOCK | FPLOCK>   RegList
  930. Where:   Reglist is a list of registers, or register-ranges.
  931. Notice:  The contents of RegList is safe after this point.
  932.  
  933. Examples of use:
  934.  
  935. LOCK     R0
  936. LOCK     R1,R2,R8-R12
  937. FPLOCK   F0
  938. FPLOCK   F0,F1,F3-F7
  939.  
  940.  
  941. Output values
  942. -------------
  943. OUTPUT <expression> {,<expression>}
  944.  
  945. This prints expression result in Status-info window.
  946.  
  947.  
  948. 7. Miscellaneous
  949. ---------------------------------------------------------------------
  950. 7.1 Extra info
  951. --------------
  952. The instruction ORR can be spelled OR if you prefer.
  953. You can use spaces or TABs in the source code.
  954.  
  955.  
  956. 7.2 Case sensitivity
  957. --------------------
  958. All assembler syntax is case insensitive.
  959. All macros and variables are case sensitive.
  960.  
  961.  
  962. 7.3 Register binding
  963. --------------------
  964. Registers (R0-R15 or F0-F7) can be typed in several ways:
  965.  
  966. Å Using the hard-coded "R0"-"R15", "PC" or "F0"-"F7".
  967. Å By typing any value, e.g. "8", "%0011", "&A", "(1+2)" or similar.
  968. Å By using a variable defined by #set, or in macro header, 
  969.    e.g. "MyReg", "Result".
  970.  
  971.  
  972. 7.4 Values
  973. ----------
  974. Integers may be specified in decimal, hexadecimal, binary or octal.
  975.  
  976. &, $ - Hexadecimal
  977. %    - Binary
  978. @    - Octal
  979.  
  980. "E" (exponent) may be used for both integers and floating point numbers, 
  981. like this:
  982.  
  983. 123E3
  984. 3.45E-4
  985.  
  986. Special characters can be used in the string. They are:
  987.  
  988. "" = "
  989. "<ASCII value/OS variable>", for example "<10>", "<Obey$Dir>".
  990. ASCII 0 should not be used in a string, as it is used to mark the end of 
  991. the string.
  992.  
  993. "|" is an "escape" character, so |" = " and |<10> = <10>
  994.  
  995.  
  996. 7.5 Value types
  997. ---------------
  998. There are three value types: Integer, floating point and string.
  999.  
  1000. Integer and Floating Point operands will auto-cast to the operands needed 
  1001. for the operator, and for the result required. Thus you can use all the 
  1002. Floating Point and integer operators, whether the operands or your result 
  1003. should be a Floating Point number or an integer.
  1004.  
  1005. If one or both of the operators are of type FP, and there is a 
  1006. corresponding FP operation, any Integer operand will be cast to FP, and 
  1007. the FP operation will be used. Also, the FP operation will be used if 
  1008. the Integer precision is insufficient to hold the result.
  1009.  
  1010. If no corresponding FP operation is available, instead any FP operand 
  1011. will be cast to Integer, and the Integer operation will be used.
  1012.  
  1013.  
  1014. 7.6 Operators
  1015. -------------
  1016. In the following table, the result type is shown by characters in 
  1017. parentheses, if it is different from the type of the operators.
  1018.  
  1019. All the compare operators return integer -1 for TRUE or 0 for FALSE.
  1020.  
  1021. The following operators and functions are implemented:
  1022.  
  1023. Level   Integer                  Floating Point             String
  1024. ----------------------------------------------------------------------------
  1025. 0       ( )                      ( )                        ( )
  1026. 1       NOT   Bitwise NOT        ABS   Absolute value       LEFT$(S,I)
  1027.         RND   Pseudo-random num. SQR   Square root          MID$(S,I [,I] )
  1028.               (see below)        LOG   Logarithm base 10    RIGHT$(S,I)
  1029.         ABS   Absolute value     LN    Logarithm base e     VAL(S)  (I / F)
  1030.         SGN   Sign (-1 for       EXP   Exponent of e (e^x)  STR$(I / F) (S)
  1031.               negative, 0 for    SIN   Sine                 STRING$(S,I)
  1032.               0, and 1 for       COS   Cosine          INSTR(S,S [,I] ) (I)
  1033.               positive)          TAN   Tangent              EVAL(S) (I / F)
  1034.         ALIGN(Num,Boundary)      ASN   Arc-Sine             CHR$(I)     (S)
  1035.               Returns Num        ACS   Arc-Cosine           ASC(S)      (I)
  1036.               aligned to         ATN   Arc-Tangent          TIME$
  1037.               Boundary           DEG   Convert radians to   LEN(S)      (I)
  1038.                                        degrees
  1039.                                  RAD   Convert degrees to
  1040.                                        radians
  1041.                                  SGN (I)   Sign, as for Integer
  1042.                                  INT (I)   Convert to Integer
  1043. 2       ^     Power              ^     Power
  1044. 3       *     Multiplication     *     Multiplication
  1045.         / (F) Division           /     Division
  1046.         DIV   Integer division
  1047.         MOD   Integer modulus
  1048.               (remainder after
  1049.                division)
  1050. 4       +     Addition           +     Addition           + String addition
  1051.         -     Subtraction        -     Subtraction
  1052. 5       <<    Shift left
  1053.         >>    Arithmetic shift
  1054.               right
  1055.         >>>   Logical shift
  1056.               right
  1057. 6       ==         Test for equal             Same as       Same as
  1058.         <> or !=   Test for not-equal         Integer       Integer
  1059.         <= or =<   Test for less-than-or-equal
  1060.         >= or =>   Test for greater-than-or-equal
  1061.         <          Test for less-than
  1062.         >          Test for greater-than
  1063. 7       AND        Bitwise AND
  1064. 8       EOR        Bitwise Exclusive OR
  1065. 9       OR         Bitwise OR
  1066.  
  1067. RND gives a pseudo-random integer between 0 and N-1, where N is the 
  1068. argument. If N is zero, then the previous RND number is given. If N is
  1069. negative, N is used to seed the random number generator, and RND returns N.
  1070.  
  1071. TIME$ gives a date and time string equal to Basic's TIME$.
  1072.  
  1073.  
  1074. 7.7 Local variables
  1075. -------------------
  1076. Local variables are very useful in assembler programming, because they 
  1077. make it possible to use the same label name many times. When defining a 
  1078. local variable, the first character of the label name should be an 
  1079. underscore (_). The scope of the local variable (where it is legal) is 
  1080. only between two normal variables. Here is an example:
  1081.  
  1082. .Skip_Blanks                 ; R0 = char, R10-> next char
  1083.    STMFD    R13!,{R14}
  1084. ._Loop                       ; define local label
  1085.    CMP      R0,#' '          ; search for space-char
  1086.    CMPNE    R0,#&09          ; ... or a TAB-char
  1087.    LDREQB   R0,[R10],#1
  1088.    BEQ      _Loop            ; use local label
  1089.    LDMFD    R13!,{R15}^
  1090.  
  1091. All variable types can be local, by using the '_' character as the first 
  1092. character. like:
  1093. '#set _LocalVar=123'.
  1094.  
  1095.  
  1096. 7.8 FP instruction precision
  1097. ----------------------------
  1098. The number of significant digits, and maximum exponent for the different 
  1099. FP precisions are:
  1100.  
  1101. S - 6-7 digits (over exponent 8 to get Inexact error), exponent 38
  1102. D - 11-12 digits (over exponent 22 to get Inexact error), exponent 308
  1103. E - 18-19 digits, exponent 4932
  1104.  
  1105.  
  1106. 7.9 Starting assembly from command line, or Obey file
  1107. -----------------------------------------------------
  1108. A star-command is supported to enable starting assembly from the command 
  1109. line, or an obey-file, when the assembler is loaded.
  1110.  
  1111. Syntax: *Drag <AppName> <Filename>
  1112. Where:  <AppName> is "extASM" and <Filename> is the source filename.
  1113.  
  1114. This sends a DataLoad message to extASM, so that it loads the source
  1115. <Filename> and starts assembly. It simulates a drag of a file from the
  1116. Filer to the extASM icon on the iconbar. This can also be used for 
  1117. other programs, if wanted.
  1118.  
  1119. Notice: Some editors (e.g. StrongED) can be programmed to start the
  1120.         assembly-process in the same manner (F10 in StrongED).
  1121.  
  1122.  
  1123. 7.10 Limits
  1124. -----------
  1125. Limits                      Memory=Only limited by available memory
  1126. -------------------------------------------------------------------
  1127. #include nesting            Memory
  1128. Macro call nesting          Memory
  1129. #if-#else-#endif nesting    16
  1130. #rept-#endr nesting         16
  1131. struct nesting              16
  1132.  
  1133. Parameters for macro calls  Memory
  1134.  
  1135. Variable name length        Max. 46 characters
  1136. Macro name length           Max. 43 characters.
  1137.  
  1138. Integer                     32 bit
  1139. Floating Point              18 significant digits, max. exponent is 4932
  1140.                             ("E" - Extended format is used)
  1141. String                      Max. 239 characters
  1142.  
  1143.  
  1144. 7.11 Stack setup
  1145. ----------------
  1146. The assembler assumes there is a valid full-descending stack at R13. This 
  1147. is for saving temporary registers during macros or auto-expansion 
  1148. instructions where no temp-regs are available.
  1149.  
  1150. Here is an example of how to set up a valid stack:
  1151.  
  1152. #set StackSize = 1024        ; How large stack do we want?
  1153. .Start
  1154.    ADR      R13,Stack
  1155.    STMFD    R13!,{R14}
  1156.    ;        Normal code
  1157. .End
  1158.    LDMFD    R13!,{R15}^
  1159. .Stack_Base
  1160.    #set Stack=Stack_Base+Stack_Size
  1161.    ; You can also use 'DBB   Stack_Size', but that will increase the size 
  1162.    ; of the object file.
  1163.  
  1164.  
  1165. 7.12 Removing warning messages
  1166. ------------------------------
  1167. A warning message can be commented out, if it is not wanted. This can be 
  1168. done by placing a "|" before the warning-text in the "Asm_War" file 
  1169. (in the "Resources" directory), like this:
  1170.  
  1171. "#&04 = |Data not halfword-aligned".
  1172.  
  1173. This program also supports interactive help, using the !Help application.
  1174.  
  1175.  
  1176. 7.13 Possible/probable future features for extASM
  1177. -------------------------------------------------
  1178. Å AOF capability incorporated into extASM.
  1179.  
  1180. 8. Auto-expansion
  1181. -----------------
  1182. Most ALU, FPU, and Load/Store instructions will be auto-expanded if the 
  1183. immediate constant is too big to be handled by a single instruction. FPU 
  1184. instructions are auto-expanded by using a LDF to load the value, and the 
  1185. value is stored at the next "#fppool" switch. LDR & STR using labels will 
  1186. be auto-expanded if the 4KB range is exceeded. The same is true for LDF, 
  1187. STF, LFM and SFM if their range is exceeded.
  1188.  
  1189. TEMP, LOCK, FPTEMP & FPLOCK are used to tell the assembler that some 
  1190. registers can be temporarily used by macros or for auto-expanding, 
  1191. eliminating the need to save registers on the stack when extra registers 
  1192. are needed.
  1193.  
  1194. Use of the #fppool
  1195. ------------------
  1196. Before FP instructions (besides LDF, STF, LFM and SFM) may be 
  1197. auto-expanded, one or more '#fppool's need to be set up (somewhere in 
  1198. the code). The position of the next #fppool after the instruction will 
  1199. be used to store the data. Here are some examples:
  1200.  
  1201. ADFS   F1,F2,#123   ; Coded as LDFS F1,FPPOOL (LDFS F1,[R15,#Offset]),
  1202.                     ; then ADFS F1,F2,F1
  1203. MVFS   F1,#234      ; ----"--- LDFS F1,FPPOOL+4
  1204.  
  1205. #fppool             ; Here the numbers will be stored, which are here equal
  1206.                     ; to DCFS 123 and DCFS 234
  1207.  
  1208.  
  1209. Another example
  1210. ---------------
  1211. ADR    R12,FPPOOL_Adr
  1212.  
  1213. MVFS   F1,#123      ; Coded as LDFS F1,[R12]
  1214. MVFS   F2,#234      ; ----"--- LDFS F2,[R12,#4]
  1215. MVFS   F3,#345      ; ----"--- LDFS F3,[R12,#8]
  1216.  
  1217. .FPPOOL_Adr
  1218. #fppool R12
  1219.  
  1220.  
  1221. The following statements will be auto-expanded as follows:
  1222.  
  1223. ADFS  F1,F2,#123
  1224. MUFS  F3,F1,#asn(1)*2    ; PI, the number is calculated before storing
  1225.  
  1226. Coded as
  1227. --------
  1228. LDFS  F1,Label_123       ; 123 is stored at "Label_123"
  1229. ADFS  F1,F2,F1
  1230. LDFS  F3,Label_3.1415...
  1231. MUFS  F3,F1,F3
  1232.  
  1233. This exploits the capability of the FPA to execute Load/Store and 
  1234. arithmetic instructions at the same time better than if one loaded the 
  1235. constants at the start of the calculation. If precision for the constant 
  1236. in the instruction is too low, the necessary precision is used in the LDF 
  1237. and the expanded instruction. For example:
  1238.  
  1239. ADFS  F1,F2,#1E100       ; Too big for "S" precision
  1240.  
  1241. Coded as
  1242. --------
  1243. LDFD  F1,Label_1E100
  1244. ADFD  F1,F2,F1
  1245.  
  1246.  
  1247. 9. Auto-expanding technical section
  1248. -----------------------------------
  1249. The following section is not needed to use the assembler, but it shows some
  1250. of the workings of the auto-expansion, and it shows how to make better 
  1251. code.
  1252.  
  1253. 9.1 Instruction changing
  1254. ------------------------
  1255. Some instructions may be automatically changed to others, and any negative
  1256. constant used is changed accordingly. This is done to eliminate or reduce
  1257. auto-expanding. This may be done for the following ARM instructions:
  1258.  
  1259. MOV <-> MVN
  1260. ADD <-> SUB
  1261. ADC <-> SBC
  1262. AND <-> BIC
  1263. CMP <-> CMN
  1264.  
  1265. For the FPA, the same is the case for the following instructions (only if 
  1266. it can be coded without auto-expansion, otherwise the instruction and 
  1267. constant is unchanged):
  1268.  
  1269. MVF <-> MNF
  1270. ADF <-> SUF
  1271. CMF <-> CNF
  1272.  
  1273. This effectively sign-extends the range of values that can be coded with 
  1274. these instructions to include 0.0 - -5.0, -0.5 and -10.0.
  1275.  
  1276. Examples                  Coded as
  1277. ----------------------------------
  1278. MOV   R1,#-123         -> MVN   R1,#122     ; This is NOT -123
  1279. ADD   R1,R2,#-123      -> SUB   R1,R2,#123
  1280. AND   R1,R2,#&FFFFFF00 -> BIC   R1,R2,#&FF
  1281.  
  1282. MVFS  F1,#-3           -> MVFS  F1,#3
  1283.  
  1284.  
  1285. This changing can be handy when variables are used where the sign of the 
  1286. variable is not known (or specified) in advance, like:
  1287.  
  1288. MOV   R1,#Offset       ; May be coded as MOV or MVN depending on the number
  1289.  
  1290.  
  1291. 9.2 Auto-expansion method
  1292. -------------------------
  1293. The auto-expansion is done by using more instructions to encode an 
  1294. immediate constant. For the ALU instructions these can be up to a total 
  1295. of four instructions, for a 32-bit word. The ARM instructions are 
  1296. auto-expanded as follows:
  1297.  
  1298. MOV -> MOV, then one or more ORRs
  1299. MVN -> MVN, --------"------- EORs
  1300. ADD -> ADD, --------"------- ADDs
  1301. SUB -> SUB, --------"------- SUBs
  1302. RSB -> RSB, --------"------- ADDs
  1303. ADC -> ADC, --------"------- ADDs
  1304. SBC -> SBC, --------"------- SUBs
  1305. RSC -> RSC, --------"------- ADDs
  1306.                                    
  1307. AND -> BIC, --------"------- BICs  (AND cannot be divided over several 
  1308. ORR -> ORR, --------"------- ORRs   instructions. The immediate constant is 
  1309. EOR -> EOR, --------"------- EORs   NOTed and BIC is used.)
  1310. BIC -> BIC, --------"------- BICs
  1311.  
  1312. CMP -> An auto-expanding MOV, then CMP
  1313. CMN -> ----------"---------------- CMN
  1314. TST -> ----------"---------------- TST
  1315. TEQ -> An auto-expanding EORS, using a temp-register for the result
  1316.  
  1317. LDR R1,Long_Label -> An (auto-expanding, if necessary) ADR, followed by LDR
  1318. STR R1,Long_Label -> -------------------------"------------------------ STR
  1319.                        (needs temp-reg)
  1320.  
  1321. LDR R1,[R2,#&12344] -> This is done in various ways, depending on 
  1322.                        whether it is pre/post indexed and write-back.
  1323. STR R1,[R2,#&12344] -> ---------------------"------------------------
  1324.  
  1325.  
  1326. Examples
  1327. --------
  1328. MOV   R1,#&1234        -> MOV   R1,#&1200
  1329.                           ORR   R1,R1,#&34
  1330.  
  1331. ADDS  R1,R2,#&12003400 -> ADD   R1,R2,#&12000000
  1332.                           ADDS  R1,R1,#&3400
  1333.  
  1334. AND   R1,R2,#&FFFF     -> BIC   R1,R2,#&FF00
  1335.                           BIC   R1,R1,#&FF
  1336.  
  1337. LDR   R1,Long_Label    -> ADD/SUB R1,R15,#Offset AND NOT &FFF
  1338.                           LDR R1,[R1,#Offset AND #&FFF]
  1339.  
  1340.  
  1341. 9.3 PSR setting for auto-expanding
  1342. ----------------------------------
  1343. Note that the setting of the PSR is slightly different when using 
  1344. auto-expanding instructions, from when using the same instruction with 
  1345. the constant in a register. When auto-expanding, the Z, N and V flags will 
  1346. be set correctly, but the C flag might be different. This is most easily 
  1347. demonstrated with an example:
  1348.  
  1349. We assume that R2 contains zero.
  1350.  
  1351. SUBS  R1,R2,#&1234 -> SUB   R1,R2,#&1200 ; R1=0-&1200 = -&1200
  1352.                       SUBS  R1,R1,#&34   ; R1=R1-&34  = -&1200-&34 = -&1234
  1353.  
  1354. Here the Z, N and V is set right. In the last instruction, the C flag is 
  1355. set, because the first operand (-&1200) is unsigned higher than the 
  1356. second (&34).
  1357.  
  1358. Using the constant in a register, we assume that R2 contains zero and the 
  1359. constant is in R3.
  1360.  
  1361. SUBS  R1,R2,R3
  1362.  
  1363. Here the Z, N and V is also set right, of course. The first operand (0) 
  1364. is _not_ unsigned higher than the second (&1234), so the C flag is 
  1365. cleared. Here is a difference.
  1366.  
  1367.  
  1368. For this reason, the compare instructions can not be auto-expanded like
  1369. this:
  1370.  
  1371. CMP -> Auto-expanding SUBS, using a temp-register for the result.
  1372.  
  1373. However, as shown above, TEQ is auto-expanded differently from the other 
  1374. compare instructions. That is because this is possible, with correct PSR, 
  1375. since it's a logical instruction, and you may save one instruction that 
  1376. way. This can be done as follows:
  1377.  
  1378. First, a usual compare
  1379.  
  1380. CMP   R1,#&1234 -> MOV   TempReg,R1,#&1200
  1381.                    ORR   TempReg,TempReg,#&34
  1382.                    CMP   R1,TempReg
  1383.  
  1384. Instead, if the C flag doesn't have to be set correctly (for EQ/NE tests), 
  1385. an auto-expanding TEQ can be used:
  1386.  
  1387. TEQ   R1,#&1234 -> EOR   TempReg,R1,#&1200
  1388.                    EORS  TempReg,TempReg,#&34
  1389.  
  1390.  
  1391. 9.4 Auto-expanding instructions
  1392. -------------------------------
  1393.                                         Requires    Requires
  1394. Instruction                             temp-reg    FP temp-reg
  1395. ---------------------------------------------------------------
  1396. MOV, MVN, ADD, SUB, RSB, ADC,
  1397. SBC, RSC, AND, ORR, EOR, BIC, ADR
  1398.  
  1399. CMP, CMN, TST, TEQ                      x
  1400.  
  1401. LDR                                     (x) [1]
  1402. STR                                     x
  1403.  
  1404. LDF, LFM                                x
  1405. SDF, SFM                                x
  1406.  
  1407. MVF, MNF, ABS, RND, SQT, LOG, LGN,      (x) [3]
  1408. SIN, COS, TAN, ASN, ACS, ATN, URD, NRM
  1409.  
  1410. ADF, SUF, RSF, MUF, DVF, RDF,           (x) [3]     (x) [2]
  1411. RMF, POW, RPW, FML, FDV, FRD, POL
  1412.  
  1413.  
  1414. [1] If using instruction like LDR R1,[R1,#&12344] (Rd=Rn)
  1415. [2] If using instruction like ADFS F1,F1,#123 (Fd=Fn)
  1416. [3] If range to next #fppool is more than 1020 bytes
  1417.  
  1418. Quite a lot of Load/Store and ADR auto-expansion can be avoided if you 
  1419. have a central variable area (for the "global variables"), and use the 
  1420. "relative <Register>" construct to point to it.
  1421.  
  1422.  
  1423. 10. ARM and FPA pie chart instructions
  1424. --------------------------------------
  1425. The instructions in the different groups in the ARM and FPA pie charts 
  1426. are as follows:
  1427.  
  1428. ARM statistics
  1429. --------------
  1430. Arithmetical - MOV, MVN, ADD, SUB, RSB, ADC, SBC, RSC, MUL, MLA, MRS, MSR
  1431. Logical      - AND, ORR, EOR, BIC
  1432. Compare      - CMP, CMN, TST, TEQ
  1433. Load/Store   - LDR, STR, LDM, STM, SWP
  1434. Branch/BL    - B, BL
  1435. ADR          - ADR (,ADRL)
  1436. SWI          - SWI
  1437.  
  1438. FPA statistics
  1439. --------------
  1440. Unops     - MNF, MVF, ABS, SQT, LOG, LGN, EXP, SIN, COS, TAN, ASN, ACS,
  1441.              ATN, RND, URD, NRM
  1442. Binops    - ADF, SUF, RSF, MUF, DVF, RDF, RMF, FML, FDV, FRD, POW, RPW, POL
  1443. Compare    - CMF, CNF, CMFE, CNFE
  1444. Load/Store - LDF, STF, LFM, SFM
  1445. Reg. trans - FIX, FLT, RFS, WFS, RFC, WFC
  1446.  
  1447. Unops      - Unary operators
  1448. Binops     - Dyadic operators
  1449. Reg. trans - Register transfer
  1450.  
  1451.  
  1452. 11. ARM2/3/6 Instruction Set
  1453. ---------------------------------------------------------------------
  1454. MOV{CC}{S}      Rd, Op2             ; Rd = Op2
  1455. MVN{CC}{S}      Rd, Op2             ; Rd = NOT Op2
  1456.  
  1457. ADD{CC}{S}      Rd, Op1, Op2        ; Rd = Op1 + Op2
  1458. SUB{CC}{S}      Rd, Op1, Op2        ; Rd = Op1 - Op2
  1459. RSB{CC}{S}      Rd, Op1, Op2        ; Rd = Op2 - Op1
  1460. ADC{CC}{S}      Rd, Op1, Op2        ; Rd = Op1 + Op2 + Carry
  1461. SBC{CC}{S}      Rd, Op1, Op2        ; Rd = Op1 - Op2 + Carry - 1
  1462. RSC{CC}{S}      Rd, Op1, Op2        ; Rd = Op2 - Op1 + Carry - 1
  1463. AND{CC}{S}      Rd, Op1, Op2        ; Rd = Op1 AND Op2
  1464. ORR{CC}{S}      Rd, Op1, Op2        ; Rd = Op1 OR Op2
  1465. EOR{CC}{S}      Rd, Op1, Op2        ; Rd = Op1 EOR Op2
  1466. BIC{CC}{S}      Rd, Op1, Op2        ; Rd = Op1 AND NOT Op2
  1467.  
  1468. CMP{CC}{S}{P}   Op1, Op2            ; Same as SUB, but result is discarded
  1469. CMN{CC}{S}{P}   Op1, Op2            ; Same as ADD, but result is discarded
  1470. TST{CC}{S}{P}   Op1, Op2            ; Same as AND, but result is discarded
  1471. TEQ{CC}{S}{P}   Op1, Op2            ; Same as EOR, but result is discarded
  1472.  
  1473. MUL{CC}{S}      Rd, Op1, Op2        ; Rd = Op1 * Op2
  1474. MLA{CC}{S}      Rd, Op1, Op2, Op3   ; Rd = Op1 * Op2 + Op3
  1475.  
  1476. LDR{CC}{B}{T}   Rd,<Address>        ; Rd = Data at <address> in memory
  1477. STR{CC}{B}{T}   Rd,<Address>        ; Data at <address> in memory = Rd
  1478.  
  1479. LDM{CC}<PU>     Rn{!},<Reglist>{^}  ; Load Registers from Rn in memory
  1480. STM{CC}<PU>     Rn{!},<Reglist>{^}  ; Store Registers to Rn in memory
  1481.  
  1482. B{CC}           <Address>           ; Branch
  1483. BL{CC}          <Address>           ; Branch with link
  1484.  
  1485. SWI{CC}         <expression>        ; Perform a SoftWare Interrupt
  1486.  
  1487. SWP{CC}{B}      Rd,Rm,[Rn]          ; Single data swap (ARM 3 or higher)
  1488.  
  1489. MRS{CC}         Rd,<psr>      ; Transfer PSR to register (ARM 6 or higher)
  1490. MSR{CC}         <psr>,Rm      ; Transfer register to PSR (ARM 6 or higher)
  1491.                 <psrf>,<Rm | #<expression>>
  1492.  
  1493. <CC> ::=        < EQ | NE | GT | GE | LE | LT | HI | HS | LS | LO | CS | CC
  1494.                 | MI | PL | VS | VC | AL | NV>
  1495.  
  1496. <Address> ::=   <expression>
  1497.                 [Rn]{!}
  1498.                 [Rn,<#expression>]{!}
  1499.                 [Rn,{+/-}Rm{,<shift>}]{!}
  1500.                 [Rn],<#expression>
  1501.                 [Rn],{+/-}Rm{,<shift>}
  1502.  
  1503. <shift> ::=     [ <LSL | ASL | LSR | ASR | ROR> #<expression> | RRX ]
  1504.  
  1505. <PU> ::=        FD|ED|FA|EA|IA|IB|DA|DB
  1506.  
  1507. <RegList> ::=   {Reg1-Reg2 | ,Reg2}
  1508.  
  1509. <psr> ::=       <CPSR | CPSR_all | SPSR | SPSR_all>
  1510.  
  1511.                 (CPSR and CPSR_all are synonymous, as are SPSR and
  1512.                  SPSR_all)
  1513.  
  1514. <psrf> ::=      <CPSR_flg | SPSR_flg>
  1515.  
  1516.  
  1517. 12. FPA10 Instruction Set
  1518. ---------------------------------------------------------------------
  1519. MVF{CC}<prec>{round}   Fd,<Fm|#value>    ; Fd = Fm
  1520. MNF{CC}<prec>{round}   Fd,<Fm|#value>    ; Fd = - Fm
  1521. ABS{CC}<prec>{round}   Fd,<Fm|#value>    ; Fd = ABS(Fm)
  1522. SQT{CC}<prec>{round}   Fd,<Fm|#value>    ; Fd = square root of (Fm)
  1523. LOG{CC}<prec>{round}   Fd,<Fm|#value>    ; Fd = log10 of (Fm)
  1524. LGN{CC}<prec>{round}   Fd,<Fm|#value>    ; Fd = loge of (Fm)
  1525. EXP{CC}<prec>{round}   Fd,<Fm|#value>    ; Fd = e raised to the power of Fm
  1526. SIN{CC}<prec>{round}   Fd,<Fm|#value>    ; Fd = sine of (Fm)
  1527. COS{CC}<prec>{round}   Fd,<Fm|#value>    ; Fd = cosine of (Fm)
  1528. TAN{CC}<prec>{round}   Fd,<Fm|#value>    ; Fd = tangent of (Fm)
  1529. ASN{CC}<prec>{round}   Fd,<Fm|#value>    ; Fd = arc-sine of (Fm)
  1530. ACS{CC}<prec>{round}   Fd,<Fm|#value>    ; Fd = arc-cosine of (Fm)
  1531. ATN{CC}<prec>{round}   Fd,<Fm|#value>    ; Fd = arc-tangent of (Fm)
  1532. RND{CC}<prec>{round}   Fd,<Fm|#value>    ; Fd = integer value of (Fm)
  1533. URD{CC}<prec>{round}   Fd,<Fm|#value>    ; Fd = unnormalised round of (Fm)
  1534. NRM{CC}<prec>{round}   Fd,<Fm|#value>    ; Fd = normalise (Fm) (after URD)
  1535.  
  1536. ADF{CC}<prec>{round}   Fd,Fn,<Fm|#value> ; Fd = Fn + Fm
  1537. SUF{CC}<prec>{round}   Fd,Fn,<Fm|#value> ; Fd = Fn - Fm
  1538. RSF{CC}<prec>{round}   Fd,Fn,<Fm|#value> ; Fd = Fm - Fn
  1539. MUF{CC}<prec>{round}   Fd,Fn,<Fm|#value> ; Fd = Fn * Fm
  1540. DVF{CC}<prec>{round}   Fd,Fn,<Fm|#value> ; Fd = Fn / Fm
  1541. RDF{CC}<prec>{round}   Fd,Fn,<Fm|#value> ; Fd = Fm / Fn
  1542. RMF{CC}<prec>{round}   Fd,Fn,<Fm|#value> ; Fd = Remainder of (Fn / Fm)
  1543. FML{CC}<prec>{round}   Fd,Fn,<Fm|#value> ; Fd = Fn * Fm (fast, S prec. only)
  1544. FDV{CC}<prec>{round}   Fd,Fn,<Fm|#value> ; Fd = Fn / Fm (fast, S prec. only)
  1545. FRD{CC}<prec>{round}   Fd,Fn,<Fm|#value> ; Fd = Fm / Fn (fast, S prec. only)
  1546. POW{CC}<prec>{round}   Fd,Fn,<Fm|#value> ; Fd = Fn raised to the power Fm
  1547. RPW{CC}<prec>{round}   Fd,Fn,<Fm|#value> ; Fd = Fm raised to the power Fn
  1548. POL{CC}<prec>{round}   Fd,Fn,<Fm|#value> ; Fd = polar angle of (Fn,Fm)
  1549.  
  1550. CMF{CC}                Fn,Fm             ; compare Fn with Fm
  1551. CNF{CC}                Fn,Fm             ; compare Fn with -Fm
  1552. CMFE{CC}               Fn,Fm             ; compare Fn with Fm with exception
  1553. CNFE{CC}               Fn,Fm             ; compare Fn with -Fm with
  1554.                                          ; exception
  1555.  
  1556. LDF{CC}<S|D|E|P>       Fd,<Address>      ; Fd = Data at <address> in memory
  1557. STF{CC}<S|D|E|P>       Fd,<Address>      ; Data at <address> in memory = Fd
  1558.  
  1559. LFM{CC}                Fd,<count>,<Address> ; Load FP-Registers from <adr>
  1560. SFM{CC}                Fd,<count>,<Address> ; Store FP-Registers to <adr>
  1561. LFM{CC}<FD | EA>       Fd,<count>,[Rn]{!}   ; Alternative syntax
  1562. SFM{CC}<FD | EA>       Fd,<count>,[Rn]{!}   ; Alternative syntax
  1563.  
  1564. FLT{CC}<S|D|E>{P|M|Z}  Fn,Rd             ; Fn = Rd
  1565. FIX{CC}{P|M|Z}         Rd,Fm             ; Rd = Fm
  1566. WFS{CC}                Rd                ; FPSR = Rd
  1567. RFS{CC}                Rd                ; Rd = FPSR
  1568. WFC{CC}                Rd                ; FPCR = Rd (SVC mode only)
  1569. RFC{CC}                Rd                ; Rd = FPCR (SVC mode only)
  1570.  
  1571. <prec> ::=             <S | D | E>
  1572.  
  1573. <round> ::=            <P | M | Z>
  1574.  
  1575. <value> ::=            0.0 | 0.5 | 1.0 | 2.0 | 3.0 | 4.0 | 5.0 | 10.0 |
  1576.                        Any value
  1577.  
  1578. <Address> ::=          <expression>
  1579.                        [Rn]
  1580.                        [Rn,<#expression>]{!}
  1581.                        [Rn],<#expression>
  1582.  
  1583. <count> ::=            <1 - 4>
  1584.