home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / f / forthmac / !Forthmacs / docs / html / armassem < prev    next >
Encoding:
Text File  |  1997-05-01  |  22.2 KB  |  591 lines

  1. <!-- Forthmacs Formatter generated HTML V.2 output -->
  2. <html>
  3. <head>
  4. <title>ARM Assembler</title>
  5. </head>
  6. <body>
  7. <h1>ARM Assembler</h1>
  8. <hr>
  9. <p>
  10. <p>
  11. <h2>Using the assembler</h2>
  12. <p>
  13. Coding in ARM assembler is very straightforward.  If you have used an ARM 
  14. Assembler before, you will already know the instructions.  Otherwise I recommend 
  15. <p>
  16. <em>Acorn Risc Machine Family Data Manual, Prentice Hall, ISBN 0-13-781618-9</em> 
  17. <p>
  18. for further information.  It tells you everything about the ARM cpu you should 
  19. know and covers the whole instruction set plus lots of hardware details.  In 
  20. fact it was my only source of information at hand when starting this 
  21. RISC OS Forthmacs port.  
  22. <p>
  23. This documentation is by far not complete, but it covers most aspects.  If you 
  24. are writing code, just have a look at some kernel sources and see how it works.  
  25. Whenever you are not sure about the produced code, have a look at it by 
  26. <p><pre>  code demo ...... c;</pre><p>
  27. <p><pre>  see demo</pre><p>
  28. and you have the code just in front of you.  
  29. <p>
  30. Also there is a chapter "Assembler Tutorial".  
  31. <p>
  32. As most Forth assemblers are, this assembler is really just a vocabulary which 
  33. contains the words for assembling ARM code.  It is "activated" by adding the 
  34. assembler vocabulary to the search order.  There are also some common ways to 
  35. control assembly which do more than just put the assembler vocabulary in the 
  36. search order.  It also uses a <em>data first - operand last</em> syntax as Forth 
  37. generally does.  
  38. <p>
  39. Lets now have a look at some kernel source and see what the syntax looks like in 
  40. the forth assembler syntax and in the original Acorn Syntax ( displayed by the 
  41. disassembler utility).  
  42. <p>
  43. <p><pre>
  44. code count      (s adr -- adr1 cnt ) 
  45.         r0      top     mov
  46.         top     r0 byte )+ ldr
  47.         r0      sp      push c;
  48. see count
  49. code count 
  50.  (   a148 )  mov     r0,r10
  51.  (   a14c )  ldrb    r10,[r0],#1
  52.  (   a150 )  str     r0,[r13,#-4]!
  53.  (   a154 )  ldr     pc,[r8],#4
  54. </pre><p>
  55. <p>
  56. <p>
  57. <h2>General syntax</h2>
  58. <p>
  59. All instructions follow the general syntax: 
  60. <p>
  61. <p><pre>
  62.         ARM:        opcode  r-dest r-n operand
  63.         Forth:      r-dest r-nsrc operand modifiers  condition op-code
  64. </pre><p>
  65. <p>
  66. <p>
  67. The brackets and commas in the original assembler source are replaced by spaces, <em>addressing mode indicators</em> 
  68. and macros.  The 
  69. <p>
  70. ia [r0],#4 will be )+ , indicating a postincrement by 1 or 4 according to 
  71. byte/word access.  
  72. <p>
  73. push is a macro meaning 
  74. <p><pre>  -( str.</pre><p>
  75. <p>
  76. c; at the end assembles a next instruction 
  77. <p><pre>  ldr     pc,[r8],#4</pre><p>
  78. <p><pre>  pc  ip )+  ldr</pre><p>
  79. and quits assembling.  
  80. <p>
  81. The operands ( registers or numbers ) must appear in the correct order followed 
  82. by modifiers.  
  83. <p>
  84. <p>
  85. <h2>Conditions</h2>
  86. <p>
  87. All instructions can be conditionally executed on ARM cpus.  All condition codes 
  88. are implemented, they should be preferably written just before the opcode 
  89. itself.  You don't have to write down the <strong>al</strong> condition, it is 
  90. the default.  
  91. <p>
  92. Note: According to ARM standards, <strong>nv</strong> is <code><A href="_smal_AJ#279">not</A></code> 
  93. implemented and should never be used because of future instruction set 
  94. extensions.  
  95. <p>
  96. Condition codes available : <strong>eq ne cs cc mi pl vs vc hi ls ge lt gt le al</strong> 
  97. <p>
  98. <p>
  99. <h2>Shifts</h2>
  100. <p>
  101. There a numerous shifts for operators available, 
  102. <p>
  103. <strong>asl #asl lsl #lsl lsr #lsr asr #asr ror #ror rrx</strong> , 
  104. <p>
  105. all shift operator leaded by a # mean count of shift specified by a number, 
  106. otherwise by a register.  
  107. <p>
  108. This assembler is clever enough to find out shifted immediates itself, so you 
  109. don't have to worry about lines like 
  110. <p><pre>  top th f0 #  td 24 #lsl mov</pre><p>
  111. just write 
  112. <p><pre>  top th f0000000 # mov</pre><p>
  113. instead.  
  114. <p>
  115. <p>
  116. <h2>Register usage</h2>
  117. <p>
  118. Registers <strong>r0 - r6</strong> are available for use within code 
  119. definitions.  Don't try to use them for permanent storage, because they are used 
  120. by many code words with no attempt to preserve the previous contents.  
  121. <p>
  122. <p><pre>  r9      user area pointer       up</pre><p>
  123. <p><pre>  r10     top-of-stack register   top</pre><p>
  124. <p><pre>  r11     return stack pointer    rp</pre><p>
  125. <p><pre>  r12     instruction pointer     ip</pre><p>
  126. <p><pre>  r13     stack pointer           sp</pre><p>
  127. <p><pre>  r14     link register           lk</pre><p>
  128. <p><pre>  r15     pc + status + flags     pc</pre><p>
  129. Note: In future CPU Versions, the internal structure of the <code><A href="_smal_BI#50">pc</A></code> 
  130. register will be different, it seems to be better, to imagine <code><A href="_smal_BI#50">pc</A></code> 
  131. and status register as two registers.  The hardware-errors and the <code><A href="_smal_AT#43">.registers</A></code> 
  132. instruction know about this already.  
  133. <p>
  134. <p>
  135. <h2>Structured programming</h2>
  136. <p>
  137. This assembler supports structured programming not by using labels but common 
  138. forth-like structures instead.  The structures do not have to fit on one line, 
  139. and they may be nested to any level.  The range of the branches assembled by 
  140. these structures is not restricted.  
  141. <p>
  142. Implemented structures are: 
  143. <p><pre>  set the flags                   \ produce the condition</pre><p>
  144. <p><pre>  condition if ...                \ if condition is met do this</pre><p>
  145. <p><pre>            else ...              \ otherwise this</pre><p>
  146. <p><pre>            then</pre><p>
  147. <p><pre>  </pre><p>
  148. <p><pre>  </pre><p>
  149. <p><pre>  </pre><p>
  150. <p><pre>  begin ....</pre><p>
  151. <p><pre>        set the flags             \ produce the condition</pre><p>
  152. <p><pre>  condition     while ...         \ do this when condition met</pre><p>
  153. <p><pre>        ( you may set the flags )</pre><p>
  154. <p><pre>  ( condition ) repeat            \ the repeat is normally always done</pre><p>
  155. <p><pre>                                  \ but you may also test for another</pre><p>
  156. <p><pre>                                  \ condition.</pre><p>
  157. <p><pre>  </pre><p>
  158. <p><pre>  </pre><p>
  159. <p><pre>  begin ...</pre><p>
  160. <p><pre>        set the flags             \ produce the condition</pre><p>
  161. <p><pre>  condition until                 \ leave the loop when condition is met</pre><p>
  162. <p><pre>  </pre><p>
  163. <p><pre>  </pre><p>
  164. <p><pre>  </pre><p>
  165. <p><pre>  begin ... again                 \ loop until whatever may happen</pre><p>
  166. <p>
  167. <p>
  168. <h2>Porting</h2>
  169. <p>
  170. The ARM assembler can be used also by other Forth systems, all hardware specific 
  171. parts are written portable and can be changed in case of problems very easily.  
  172. So a 68k-Forthmacs can metacompile ARM code by this assembler without any 
  173. change.  In fact, the very first metacompilation of this RISC OS Forthmacs took 
  174. place on an ATARI-ST having 1MB Ram and a 720k disk.  
  175. <p>
  176. <p>
  177. <h2>Byte-sex</h2>
  178. <p>
  179. Both byte-sexes can be produced by this assembler, this allows portable 
  180. assembler code for all ARM CPUs.  <strong>little-endian</strong> and <strong>big-endian</strong> 
  181. do the switch.  
  182. <p>
  183. <p>
  184. <h2>ARM2/3/6</h2>
  185. <p>
  186. The assembler takes care of some cpu dependent restrictions, <strong>arm2</strong> 
  187. disallows the more advanced instructions, <strong>arm3</strong> allows them.  
  188. <p>
  189. <p>
  190. <h2>Forth Virtual Machine Considerations</h2>
  191. <p>
  192. The Forth parameter stack is implemented with r13, but the name <code><A href="_smal_BJ#51">sp</A></code> 
  193. should be used instead of r13, in case the virtual machine implementation should 
  194. change.  
  195. <p>
  196. The return stack is implemented with r11, and the name <code><A href="_smal_BD#1B">rp</A></code> 
  197. should be used to refer to it.  
  198. <p>
  199. The base address of the user area ( the user pointer) is r9 but should be 
  200. referred to as <code><A href="_smal_BD#31B">up</A>.</code> User variable number 
  201. 124 (for instance) may be accessed with the 
  202. <p><pre>  up td 124 d)</pre><p>
  203. addressing mode.  There is a macro <code><A href="_smal_BF#1D">'user</A></code> 
  204. which will assemble this addressing mode for you.  
  205. <p>
  206. The interpreter pointer <code><A href="_smal_BC#1A">ip</A></code> is r12.  The 
  207. interpreter is post-incrementing, so when a code definition is being executed, <code><A href="_smal_BC#1A">ip</A></code> 
  208. points to the token after the one being executed.  A "token" is the number that 
  209. is compiled into the dictionary for each Forth word in a definitions.  For 
  210. RISC OS Forthmacs, a token is a 32-bit absolute address.  
  211. <p>
  212. <p>
  213. <h2>Assembler Glossary </h2>
  214. <p>
  215.  
  216. <hr><h3><A name="17">pc</A> ( -- n )</h3>
  217. <br>
  218. portable name for the <code><A href="_smal_BI#50">pc</A></code> register 
  219.  
  220. <hr><h3><A name="18">sp</A> ( -- n )</h3>
  221. <br>
  222. portable name for the stack pointer 
  223.  
  224. <hr><h3><A name="19">up</A> ( -- n )</h3>
  225. <br>
  226. portable name for the user pointer 
  227.  
  228. <hr><h3><A name="1A">ip</A> ( -- n )</h3>
  229. <br>
  230. portable name for the instruction pointer 
  231.  
  232. <hr><h3><A name="1B">rp</A> ( -- n )</h3>
  233. <br>
  234. portable name for the return stack pointer 
  235.  
  236. <hr><h3><A name="1C">top</A> ( -- n )</h3>
  237. <br>
  238. portable name for the top of stack register 
  239.  
  240. <hr><h3><A name="1D">'user</A> ( --  )</h3> <kbd>name</kbd> 
  241. <br>
  242. Executed in the form: 
  243. <p><pre>       top   'user <name>   ldr</pre><p>
  244. <name> is the name of a User variable.  Assembles the appropriate 
  245. addressing mode for accessing that User variable.  
  246. <p>
  247. In RISC OS Forthmacs, the addressing mode for User variables is 
  248. <p><pre>               up #n d)</pre><p>
  249. where #n is the offset of that variable within the User area.  
  250.  
  251. <hr><h3><A name="1E">;code</A> ( --  )</h3>
  252.  Extra: C,I
  253. <br>
  254. <h5>C: ( --  )</h5><br>
  255. <br>
  256. Used in the form: 
  257. <p><pre>               : <name>  ... create ... ;code ... c; (or end-code)</pre><p>
  258. Stops compilation, terminates the defining word <name>, executes <code><A href="_smal_BT#14B">arm-assembler</A>,</code> 
  259. and does <code><A href="_smal_AS#1C2">do-entercode</A>.</code> 
  260. <p>
  261. When <name> is later executed in the form: 
  262. <p><pre>               <name> <new-name></pre><p>
  263. to define the word <new-name>, the later execution of <new-name> 
  264. will cause the machine code sequence following the <code><A href="_smal_BE#10C">;code</A></code> 
  265. to be executed.  
  266. This is analogous to <code><A href="_smal_BC#1CA">does></A>,</code> except 
  267. that the behavior of the defined words <word-name> is specified in 
  268. assembly language instead of high-level Forth.  
  269. <p>
  270. <code><A href="_smal_BE#10C">;code</A></code> calls <code><A href="_smal_AS#1C2">do-entercode</A>,</code> 
  271. this is implementation specific and used to assemble some instructions to set 
  272. the parameter-field-address on top the code needed to start the assembler code 
  273. with the body of the defined 
  274. <p><pre>       top     sp      push</pre><p>
  275. <p><pre>       top     lk      th fc000003 # bic</pre><p>
  276. From version 3.1/2.62 on this isn't the case any more, you have to write those 
  277. instructions yourself.  
  278.  
  279. See: <code><A href="_smal_AC#182">code</A></code> <code><A href="_smal_BC#1CA">does></A></code> 
  280. <p>
  281.  
  282. <hr><h3><A name="1F">adr</A> ( rx addr --  )</h3>
  283. <br>
  284. Assembler macro with the following effect: 
  285. <p>
  286. addr is moved to register rx.  Within short distances this is achieved by a <code><A href="_smal_AI#38">pcr</A></code> 
  287. instruction, otherwise it's more complicated.  
  288. <p>
  289. Note: The address will be relocated correctly! 
  290.  
  291. <hr><h3><A name="20">aligning?</A> ( -- addr  )</h3>
  292. <br>
  293. variable holding flag, true means assembler does aligning on its own.  
  294. Implemented for CPU independent metacompiling.  
  295.  
  296. <hr><h3><A name="21">alu-instructions</A> ( r-dest r-op1 op2{r-op2|imm} --  )</h3>
  297. <br>
  298. Available instructions with this syntax: 
  299. <p>
  300. <strong>and eor sub rsb add adc sbc rsc tst teq cmp cmn orr bic </strong> 
  301. <p>
  302. These instructions all have two data-inputs to the alu, the register r-op1 and 
  303. the operand op2.  This can be another register or an 8-bit immediate.  
  304. <p>
  305. The register r-op2 can be "shifted" in any way specified by a shift specifier, 
  306. either a 5-bit integer or another register plus the shifted register.  The 
  307. immediate operand can be rotated right by 2*(4-bit-integer).  
  308. <p>
  309. If you give "large" literals as arguments, the assembler will generate the 
  310. correct shifts itself.  
  311. <p>
  312. The <strong>#</strong> modifier declares an immediate operand as in: \ top r0 3 
  313. # add 
  314. <p>
  315. The <strong>s</strong> modifier will set the flags according to the result, the 
  316. instruction will be <strong>adds</strong> instead of <strong>add</strong> .  
  317. <strong>mov</strong> and <strong>mvn</strong> are somewhat different, the 
  318. operand r-op1 isn't needed.  Also, both can handle "big" immediates themselves, 
  319. <p><pre>       top th 12345678 # mov</pre><p>
  320. won't be a problem, <strong>mov</strong> assembles all instructions needed.  
  321. <p>
  322. <strong>cmp</strong> and <strong>cmn</strong> can both handle negative immediate 
  323. operandes, they try to find out which operand is possible.  
  324. <p>
  325.  
  326. <hr><h3><A name="22">asm-allot</A> ( n --  )</h3>
  327.  Extra: deferred
  328. <br>
  329. Allocates n bytes in the dictionary.  The address of the next available 
  330. dictionary location is adjusted accordingly.  
  331. <p>
  332. default <code><A href="_smal_BM#144">allot</A>,</code> implemented for ( cpu 
  333. independent ) metacompiling.  
  334.  
  335. <hr><h3><A name="23">arm-assembler</A> ( --  )</h3>
  336. <br>
  337. Execution replaces the first vocabulary in the search order with the <code><A href="_smal_BT#14B">arm-assembler</A></code> 
  338. vocabulary, making all the assembler words accessible.  
  339.  
  340. <hr><h3><A name="24">big-endian</A> ( -- )</h3>
  341. <br>
  342. Switches assembler to big-endian target code 
  343.  
  344. <hr><h3><A name="25">branch</A> ( addr --  )</h3>
  345. <br>
  346. Assembles a branch instruction to here.  Can be modified by <code><A href="_smal_BT#2B">dolink</A></code> 
  347. and all condition codes.  
  348.  
  349. <hr><h3><A name="26">byte</A> ( -- )</h3>
  350. <br>
  351. modifier for the assembler, memory accesses mean byte wide access 
  352.  
  353. <hr><h3><A name="27">code</A> ( --  )</h3> <kbd>name</kbd> 
  354.  Extra: M
  355. <br>
  356. A defining word executed in the form: 
  357. <p><pre>               code <name> ... end-code or c;</pre><p>
  358. Creates a dictionary entry for <name> to be defined by a following 
  359. sequence of assembly language words.  Words thus defined are called code 
  360. definitions or primitives.  Executes <code><A href="_smal_BT#14B">arm-assembler</A></code> 
  361. and sets the opcode defaults .  
  362. <p>
  363. This is the most common way to begin assembly.  
  364. <p>
  365.  
  366. See: <code><A href="_smal_BT#1DB">end-code</A></code> <code><A href="_smal_BD#16B">c;</A></code> 
  367.  
  368. <hr><h3><A name="28">c;</A> ( --  )</h3>
  369. <br>
  370. Terminates the current code definition and allows its name to be found in the 
  371. dictionary.  
  372. <p>
  373. Sets the <code><A href="_smal_AQ#190">context</A></code> vocabulary to be same 
  374. as the <code><A href="_smal_BG#19E">current</A></code> vocabulary (which removes 
  375. the <code><A href="_smal_BT#14B">arm-assembler</A></code> vocabulary from the 
  376. search order, unless you have explicitly done something funny to the search 
  377. order while assembling the code).  
  378. <p>
  379. Executes <code><A href="_smal_AG#36">next</A></code> to assemble the "next" 
  380. routine at then end of the code word word being defined.  The "next" routine 
  381. causes the Forth interpreter to continue execution with the next word.  
  382. <p>
  383. <p>
  384. This is the most common way to end assembly, calls <code><A href="_smal_BT#1DB">end-code</A>.</code> 
  385.  
  386. <hr><h3><A name="29">conditions</A> ( --  )</h3>
  387. <br>
  388. All instruction are executed only if the correct condition is met, the 
  389. assemblers default is <strong>al</strong> (always), but these are also 
  390. available: 
  391. <p>
  392. <strong>eq ne cs cc mi pl vs vc hi ls ge lt gt le al</strong> 
  393.  
  394. <hr><h3><A name="2A">decr</A> ( reg n# --  )</h3>
  395. <br>
  396. Macro, n# will be subtracted from reg.  
  397.  
  398. <hr><h3><A name="2B">dolink</A> ( --  )</h3>
  399. <br>
  400. modifier for <code><A href="_smal_AT#163">branch</A></code> instruction, the 
  401. current pc will be saved to the link register.  
  402.  
  403. <hr><h3><A name="2C">end-code</A> ( --  )</h3>
  404. <br>
  405. Terminates a code definition and allows the <name> of the corresponding 
  406. code definition to be found in the dictionary.  
  407. <p>
  408. The <code><A href="_smal_AQ#190">context</A></code> vocabulary is set to the 
  409. same as the <code><A href="_smal_BG#19E">current</A></code> vocabulary (which 
  410. removes the <code><A href="_smal_BT#14B">arm-assembler</A></code> vocabulary 
  411. from the search order, unless you have explicitly done something funny to the 
  412. search order while assembling the code).  
  413. <p>
  414. The <code><A href="_smal_AG#36">next</A></code> routine is not automatically 
  415. added to the end of the code definition.  Usually you want <code><A href="_smal_AG#36">next</A></code> 
  416. to be at the end of the definition, but sometimes the last thing in the 
  417. definition is a branch to somewhere else, so the <code><A href="_smal_AG#36">next</A></code> 
  418. at the end is not needed.  
  419. <p>
  420.  
  421. See: <code><A href="_smal_BD#16B">c;</A></code> 
  422.  
  423. <hr><h3><A name="2D">entercode</A> ( --  )</h3>
  424. <br>
  425. Starts assembling after stack checking, setting the assembler defaults and 
  426. switching to <code><A href="_smal_BT#14B">arm-assembler</A>.</code> 
  427.  
  428. See: <code><A href="_smal_AS#1C2">do-entercode</A></code> <code><A href="_smal_BE#10C">;code</A></code> 
  429.  
  430. <hr><h3><A name="2E">get-link</A> ( -- reg --  )</h3>
  431. <br>
  432. Assembler macro, equivalent for: 
  433. <p><pre>  lk fc000003 # bic</pre><p>
  434. this is useful to get the address after a branch instruction.  
  435. <p><pre>  xxxxx dolink branch  ---+</pre><p>
  436. <p><pre>    A) data ...           |</pre><p>
  437. <p><pre>                          |</pre><p>
  438. <p><pre>                          |</pre><p>
  439. <p><pre>    B) top get-link  <----+</pre><p>
  440. So after branching to B), <code><A href="_smal_BE#1C">top</A></code> will be set 
  441. to A) 
  442.  
  443. <hr><h3><A name="2F">incr</A> ( reg n# --  )</h3>
  444. <br>
  445. Macro, n# will be added to reg.  
  446.  
  447. <hr><h3><A name="30">label</A> ( --  )</h3> <kbd>name</kbd> 
  448.  Extra: F83
  449. <br>
  450. A defining word used in the form: 
  451. <p><pre>  label <name> ... end-code</pre><p>
  452. <p><pre>  label <name> ... c;</pre><p>
  453. Creates a dictionary entry for <name> consisting of a following sequence 
  454. of assembly language words.  When <name> is later executed, the address of 
  455. the first word of the assembly language sequence is left on the stack.  
  456. <p>
  457.  
  458. See: <code><A href="_smal_BT#1DB">end-code</A></code> 
  459.  
  460. <hr><h3><A name="31">ldm</A> ( rx1 rx2 .. rxn  n#  r-adr --  )</h3>
  461. <br>
  462. Load multiple registers from the address pointed to by r-adr, an addressing 
  463. modes must be defined.  
  464. <p>
  465. The register list is given by all register names (don't name a register twice) 
  466. and the number of registers.  
  467. <p><pre>   r0 r1 r2 r3 4   sp ia! ldm</pre><p>
  468. This loads registers r0-r3 from the stack and sets the stack pointer to the next 
  469. stack entry.  
  470. <p>
  471.  
  472. See: <code><A href="_smal_AC#32">ldr</A></code> <code><A href="_smal_AL#3B">stm</A></code> 
  473.  
  474. <hr><h3><A name="32">ldr</A> ( r-data r-adr operand2 --  )</h3>
  475. <br>
  476. r-data is read from memory, the default is word (32-bit) wide, but the modifier <code><A href="_smal_BO#26">byte</A></code> 
  477. sets this byte-wide access.  
  478. <p>
  479. The address is calculated using r-adr and the operand2.  It can be another 
  480. register (the shift specified as usual by a 5-bit literal and a shift type) or a 
  481. 12-bit immediate offset.  
  482. <p>
  483. operand2 can be added to or subtracted from r-adr according to the addressing 
  484. mode defined by two letters.  The first tells whether (i)ncreasing or 
  485. (d)decreasing should be used, the second whether the in/decreasing takes place 
  486. (b)efore or (a)fter the memory access.  A "!" at the end tells "write-back" will 
  487. take place.  So these modes are possible 
  488. <p><pre>       da  ia  db  ib    \ decrease/increase after/before</pre><p>
  489. <p><pre>       da  ia! db! ib!   \ as above plus write-back</pre><p>
  490. <p>
  491. Some macros make live a bit more easy, they are somewhat 68k alike, and must 
  492. follow a <code><A href="_smal_BO#26">byte</A></code> modifier because an offset 
  493. will be calculated by the assembler itself.  
  494. <p>
  495. <p><pre>  : )      0 #   ib ;</pre><p>
  496. <p><pre>  : )+     @increment  ia ;</pre><p>
  497. <p><pre>  : )-     @increment  da ;</pre><p>
  498. <p><pre>  : -(     @increment  db! ;</pre><p>
  499. <p><pre>  : +(     @increment  ib! ;</pre><p>
  500. <p><pre>  </pre><p>
  501. <p><pre>  : d)     dup abs # offset?  swap 0<  if db  else ib  then ;</pre><p>
  502. <p><pre>  : d)!    dup abs # offset?  swap 0<  if db! else ib! then ;</pre><p>
  503. <p><pre>  : push   -( str ;</pre><p>
  504. <p><pre>  : pop    )+ ldr ;</pre><p>
  505. Examples: 
  506. <p><pre>    top  r6 byte )+ ldr</pre><p>
  507. <p><pre>    top  up 8 d)    ldr</pre><p>
  508. <p>
  509.  
  510. See: <code><A href="_smal_AM#3C">str</A></code> 
  511. <p>
  512.  
  513. <hr><h3><A name="33">little-endian</A> ( -- )</h3>
  514. <br>
  515. Switches assembler to little-endian target code 
  516.  
  517. <hr><h3><A name="34">mla</A> ( r-dest r-op1 r-op2 r-add )</h3>
  518. <br>
  519. Assembles a multiply-and-accumulate instruction, r-dest is r-add + (r-op1*rop2) 
  520.  
  521. <hr><h3><A name="35">mul</A> ( r-dest r-op1 r-op2 )</h3>
  522. <br>
  523. Assembles a multiply instruction.  
  524.  
  525. <hr><h3><A name="36">next</A> ( --  )</h3>
  526. <br>
  527. Assembler macro which assembles the <code><A href="_smal_AG#36">next</A></code> 
  528. routine, which is the Forth address interpreter.  
  529. <p>
  530. In RISC OS Forthmacs this is one single instruction.  
  531. <p><pre>       pc  ip  )+  ldr</pre><p>
  532.  
  533. <hr><h3><A name="37">nop</A> ( --  )</h3>
  534. <br>
  535. Assembler macro, equivalent to 
  536. <p><pre>  r0 r0 mov</pre><p>
  537.  
  538. <hr><h3><A name="38">pcr</A> ( addr -- pc offset  )</h3>
  539. <br>
  540. Assembler macro, expects an address on the stack and calculates its address 
  541. offset from <code><A href="_smal_BI#50">pc</A>.</code> The addressing mode is 
  542. also set.  
  543.  
  544. <hr><h3><A name="39">return</A> ( --  )</h3>
  545. <br>
  546. macro for 
  547. <p><pre>  pc  lk  mov</pre><p>
  548.  
  549. <hr><h3><A name="3A">s</A> ( --  )</h3>
  550. <br>
  551. modifier, the instruction will set the flags according to the result.  default 
  552. for tst, teq tstp teqp cmp cmn cmpp cmnp.  
  553.  
  554. <hr><h3><A name="3B">stm</A> ( rx1 rx2 .. rxn  n#  r-adr --  )</h3>
  555. <br>
  556. Store multiple registers to the address pointed to by r-adr, an addressing modes 
  557. must be defined.  
  558. <p>
  559.  
  560. See: <code><A href="_smal_AB#31">ldm</A></code> for more details.  
  561.  
  562. <hr><h3><A name="3C">str</A> ( r-data r-adr operand2 --  )</h3>
  563. <br>
  564. r-data is stored to memory, the default is word (32-bit) wide, but the modifier <code><A href="_smal_BO#26">byte</A></code> 
  565. sets this byte-wide access.  
  566. <p>
  567.  
  568. See: <code><A href="_smal_AC#32">ldr</A></code> 
  569.  
  570. <hr><h3><A name="3D">swi</A> ( swi# --  )</h3>
  571. <br>
  572. assembles a swi instruction, the number is swi#.  
  573.  
  574. <hr><h3><A name="3E">swix</A> ( swi# --  )</h3>
  575. <br>
  576. assembles a swix instruction, the number is swi#.  
  577.  
  578. <hr><h3><A name="3F">swp</A> ( r-dest r-base r-source --  )</h3>
  579. <br>
  580. assembles a swp instruction if Arm3-code is allowed by <strong>arm3</strong> 
  581.  
  582. <hr><h3><A name="40">t</A> ( --  )</h3>
  583. <br>
  584. modifier, force -T pin.  
  585.  
  586. <hr><h3><A name="41">^</A> ( --  )</h3>
  587. <br>
  588. modifier, force access to user-mode registers.  
  589. </body>
  590. </html>
  591.