levelMemoryDefinition.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /*
  2. NetWinder Floating Point Emulator
  3. (c) Rebel.COM, 1998,1999
  4. (c) Philip Blundell, 2001
  5. Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. #ifndef __FPOPCODE_H__
  19. #define __FPOPCODE_H__
  20. /*
  21. ARM Floating Point Instruction Classes
  22. | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
  23. |c o n d|1 1 0 P|U|u|W|L| Rn |v| Fd |0|0|0|1| o f f s e t | CPDT
  24. |c o n d|1 1 0 P|U|w|W|L| Rn |x| Fd |0|0|1|0| o f f s e t | CPDT (copro 2)
  25. | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
  26. |c o n d|1 1 1 0|a|b|c|d|e| Fn |j| Fd |0|0|0|1|f|g|h|0|i| Fm | CPDO
  27. |c o n d|1 1 1 0|a|b|c|L|e| Fn | Rd |0|0|0|1|f|g|h|1|i| Fm | CPRT
  28. |c o n d|1 1 1 0|a|b|c|1|e| Fn |1|1|1|1|0|0|0|1|f|g|h|1|i| Fm | comparisons
  29. | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
  30. CPDT data transfer instructions
  31. LDF, STF, LFM (copro 2), SFM (copro 2)
  32. CPDO dyadic arithmetic instructions
  33. ADF, MUF, SUF, RSF, DVF, RDF,
  34. POW, RPW, RMF, FML, FDV, FRD, POL
  35. CPDO monadic arithmetic instructions
  36. MVF, MNF, ABS, RND, SQT, LOG, LGN, EXP,
  37. SIN, COS, TAN, ASN, ACS, ATN, URD, NRM
  38. CPRT joint arithmetic/data transfer instructions
  39. FIX (arithmetic followed by load/store)
  40. FLT (load/store followed by arithmetic)
  41. CMF, CNF CMFE, CNFE (comparisons)
  42. WFS, RFS (write/read floating point status register)
  43. WFC, RFC (write/read floating point control register)
  44. cond condition codes
  45. P pre/post index bit: 0 = postindex, 1 = preindex
  46. U up/down bit: 0 = stack grows down, 1 = stack grows up
  47. W write back bit: 1 = update base register (Rn)
  48. L load/store bit: 0 = store, 1 = load
  49. Rn base register
  50. Rd destination/source register
  51. Fd floating point destination register
  52. Fn floating point source register
  53. Fm floating point source register or floating point constant
  54. uv transfer length (TABLE 1)
  55. wx register count (TABLE 2)
  56. abcd arithmetic opcode (TABLES 3 & 4)
  57. ef destination size (rounding precision) (TABLE 5)
  58. gh rounding mode (TABLE 6)
  59. j dyadic/monadic bit: 0 = dyadic, 1 = monadic
  60. i constant bit: 1 = constant (TABLE 6)
  61. */
  62. /*
  63. TABLE 1
  64. +-------------------------+---+---+---------+---------+
  65. | Precision | u | v | FPSR.EP | length |
  66. +-------------------------+---+---+---------+---------+
  67. | Single | 0 | 0 | x | 1 words |
  68. | Double | 1 | 1 | x | 2 words |
  69. | Extended | 1 | 1 | x | 3 words |
  70. | Packed decimal | 1 | 1 | 0 | 3 words |
  71. | Expanded packed decimal | 1 | 1 | 1 | 4 words |
  72. +-------------------------+---+---+---------+---------+
  73. Note: x = don't care
  74. */
  75. /*
  76. TABLE 2
  77. +---+---+---------------------------------+
  78. | w | x | Number of registers to transfer |
  79. +---+---+---------------------------------+
  80. | 0 | 1 | 1 |
  81. | 1 | 0 | 2 |
  82. | 1 | 1 | 3 |
  83. | 0 | 0 | 4 |
  84. +---+---+---------------------------------+
  85. */
  86. /*
  87. TABLE 3: Dyadic Floating Point Opcodes
  88. +---+---+---+---+----------+-----------------------+-----------------------+
  89. | a | b | c | d | Mnemonic | Description | Operation |
  90. +---+---+---+---+----------+-----------------------+-----------------------+
  91. | 0 | 0 | 0 | 0 | ADF | Add | Fd := Fn + Fm |
  92. | 0 | 0 | 0 | 1 | MUF | Multiply | Fd := Fn * Fm |
  93. | 0 | 0 | 1 | 0 | SUF | Subtract | Fd := Fn - Fm |
  94. | 0 | 0 | 1 | 1 | RSF | Reverse subtract | Fd := Fm - Fn |
  95. | 0 | 1 | 0 | 0 | DVF | Divide | Fd := Fn / Fm |
  96. | 0 | 1 | 0 | 1 | RDF | Reverse divide | Fd := Fm / Fn |
  97. | 0 | 1 | 1 | 0 | POW | Power | Fd := Fn ^ Fm |
  98. | 0 | 1 | 1 | 1 | RPW | Reverse power | Fd := Fm ^ Fn |
  99. | 1 | 0 | 0 | 0 | RMF | Remainder | Fd := IEEE rem(Fn/Fm) |
  100. | 1 | 0 | 0 | 1 | FML | Fast Multiply | Fd := Fn * Fm |
  101. | 1 | 0 | 1 | 0 | FDV | Fast Divide | Fd := Fn / Fm |
  102. | 1 | 0 | 1 | 1 | FRD | Fast reverse divide | Fd := Fm / Fn |
  103. | 1 | 1 | 0 | 0 | POL | Polar angle (ArcTan2) | Fd := arctan2(Fn,Fm) |
  104. | 1 | 1 | 0 | 1 | | undefined instruction | trap |
  105. | 1 | 1 | 1 | 0 | | undefined instruction | trap |
  106. | 1 | 1 | 1 | 1 | | undefined instruction | trap |
  107. +---+---+---+---+----------+-----------------------+-----------------------+
  108. Note: POW, RPW, POL are deprecated, and are available for backwards
  109. compatibility only.
  110. */
  111. /*
  112. TABLE 4: Monadic Floating Point Opcodes
  113. +---+---+---+---+----------+-----------------------+-----------------------+
  114. | a | b | c | d | Mnemonic | Description | Operation |
  115. +---+---+---+---+----------+-----------------------+-----------------------+
  116. | 0 | 0 | 0 | 0 | MVF | Move | Fd := Fm |
  117. | 0 | 0 | 0 | 1 | MNF | Move negated | Fd := - Fm |
  118. | 0 | 0 | 1 | 0 | ABS | Absolute value | Fd := abs(Fm) |
  119. | 0 | 0 | 1 | 1 | RND | Round to integer | Fd := int(Fm) |
  120. | 0 | 1 | 0 | 0 | SQT | Square root | Fd := sqrt(Fm) |
  121. | 0 | 1 | 0 | 1 | LOG | Log base 10 | Fd := log10(Fm) |
  122. | 0 | 1 | 1 | 0 | LGN | Log base e | Fd := ln(Fm) |
  123. | 0 | 1 | 1 | 1 | EXP | Exponent | Fd := e ^ Fm |
  124. | 1 | 0 | 0 | 0 | SIN | Sine | Fd := sin(Fm) |
  125. | 1 | 0 | 0 | 1 | COS | Cosine | Fd := cos(Fm) |
  126. | 1 | 0 | 1 | 0 | TAN | Tangent | Fd := tan(Fm) |
  127. | 1 | 0 | 1 | 1 | ASN | Arc Sine | Fd := arcsin(Fm) |
  128. | 1 | 1 | 0 | 0 | ACS | Arc Cosine | Fd := arccos(Fm) |
  129. | 1 | 1 | 0 | 1 | ATN | Arc Tangent | Fd := arctan(Fm) |
  130. | 1 | 1 | 1 | 0 | URD | Unnormalized round | Fd := int(Fm) |
  131. | 1 | 1 | 1 | 1 | NRM | Normalize | Fd := norm(Fm) |
  132. +---+---+---+---+----------+-----------------------+-----------------------+
  133. Note: LOG, LGN, EXP, SIN, COS, TAN, ASN, ACS, ATN are deprecated, and are
  134. available for backwards compatibility only.
  135. */
  136. /*
  137. TABLE 5
  138. +-------------------------+---+---+
  139. | Rounding Precision | e | f |
  140. +-------------------------+---+---+
  141. | IEEE Single precision | 0 | 0 |
  142. | IEEE Double precision | 0 | 1 |
  143. | IEEE Extended precision | 1 | 0 |
  144. | undefined (trap) | 1 | 1 |
  145. +-------------------------+---+---+
  146. */
  147. /*
  148. TABLE 5
  149. +---------------------------------+---+---+
  150. | Rounding Mode | g | h |
  151. +---------------------------------+---+---+
  152. | Round to nearest (default) | 0 | 0 |
  153. | Round toward plus infinity | 0 | 1 |
  154. | Round toward negative infinity | 1 | 0 |
  155. | Round toward zero | 1 | 1 |
  156. +---------------------------------+---+---+
  157. */
  158. /*
  159. ===
  160. === Definitions for load and store instructions
  161. ===
  162. */
  163. /* bit masks */
  164. #define BIT_PREINDEX 0x01000000
  165. #define BIT_UP 0x00800000
  166. #define BIT_WRITE_BACK 0x00200000
  167. #define BIT_LOAD 0x00100000
  168. /* masks for load/store */
  169. #define MASK_CPDT 0x0c000000 /* data processing opcode */
  170. #define MASK_OFFSET 0x000000ff
  171. #define MASK_TRANSFER_LENGTH 0x00408000
  172. #define MASK_REGISTER_COUNT MASK_TRANSFER_LENGTH
  173. #define MASK_COPROCESSOR 0x00000f00
  174. /* Tests for transfer length */
  175. #define TRANSFER_SINGLE 0x00000000