训练营PLSR题目
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

282 linhas
12 KiB

  1. ;********************************************************************************************************
  2. ; uC/CPU
  3. ; CPU CONFIGURATION & PORT LAYER
  4. ;
  5. ; (c) Copyright 2004-2013; Micrium, Inc.; Weston, FL
  6. ;
  7. ; All rights reserved. Protected by international copyright laws.
  8. ;
  9. ; uC/CPU is provided in source form to registered licensees ONLY. It is
  10. ; illegal to distribute this source code to any third party unless you receive
  11. ; written permission by an authorized Micrium representative. Knowledge of
  12. ; the source code may NOT be used to develop a similar product.
  13. ;
  14. ; Please help us continue to provide the Embedded community with the finest
  15. ; software available. Your honesty is greatly appreciated.
  16. ;
  17. ; You can find our product's user manual, API reference, release notes and
  18. ; more information at https://doc.micrium.com.
  19. ; You can contact us at www.micrium.com.
  20. ;********************************************************************************************************
  21. ;********************************************************************************************************
  22. ;
  23. ; CPU PORT FILE
  24. ;
  25. ; ARM-Cortex-M4
  26. ; IAR C Compiler
  27. ;
  28. ; Filename : cpu_a.asm
  29. ; Version : V1.30.01.00
  30. ; Programmer(s) : JJL
  31. ;********************************************************************************************************
  32. ;********************************************************************************************************
  33. ; PUBLIC FUNCTIONS
  34. ;********************************************************************************************************
  35. PUBLIC CPU_IntDis
  36. PUBLIC CPU_IntEn
  37. PUBLIC CPU_SR_Save
  38. PUBLIC CPU_SR_Restore
  39. PUBLIC CPU_WaitForInt
  40. PUBLIC CPU_WaitForExcept
  41. PUBLIC CPU_CntLeadZeros
  42. PUBLIC CPU_CntTrailZeros
  43. PUBLIC CPU_RevBits
  44. ;********************************************************************************************************
  45. ; CODE GENERATION DIRECTIVES
  46. ;********************************************************************************************************
  47. RSEG CODE:CODE:NOROOT(2)
  48. THUMB
  49. ;********************************************************************************************************
  50. ; DISABLE and ENABLE INTERRUPTS
  51. ;
  52. ; Description: Disable/Enable interrupts.
  53. ;
  54. ; Prototypes : void CPU_IntDis(void);
  55. ; void CPU_IntEn (void);
  56. ;********************************************************************************************************
  57. CPU_IntDis
  58. CPSID I
  59. BX LR
  60. CPU_IntEn
  61. CPSIE I
  62. BX LR
  63. ;********************************************************************************************************
  64. ; CRITICAL SECTION FUNCTIONS
  65. ;
  66. ; Description : Disable/Enable interrupts by preserving the state of interrupts. Generally speaking, the
  67. ; state of the interrupt disable flag is stored in the local variable 'cpu_sr' & interrupts
  68. ; are then disabled ('cpu_sr' is allocated in all functions that need to disable interrupts).
  69. ; The previous interrupt state is restored by copying 'cpu_sr' into the CPU's status register.
  70. ;
  71. ; Prototypes : CPU_SR CPU_SR_Save (void);
  72. ; void CPU_SR_Restore(CPU_SR cpu_sr);
  73. ;
  74. ; Note(s) : (1) These functions are used in general like this :
  75. ;
  76. ; void Task (void *p_arg)
  77. ; {
  78. ; CPU_SR_ALLOC(); /* Allocate storage for CPU status register */
  79. ; :
  80. ; :
  81. ; CPU_CRITICAL_ENTER(); /* cpu_sr = CPU_SR_Save(); */
  82. ; :
  83. ; :
  84. ; CPU_CRITICAL_EXIT(); /* CPU_SR_Restore(cpu_sr); */
  85. ; :
  86. ; }
  87. ;********************************************************************************************************
  88. CPU_SR_Save
  89. MRS R0, PRIMASK ; Set prio int mask to mask all (except faults)
  90. CPSID I
  91. BX LR
  92. CPU_SR_Restore ; See Note #2.
  93. MSR PRIMASK, R0
  94. BX LR
  95. ;********************************************************************************************************
  96. ; WAIT FOR INTERRUPT
  97. ;
  98. ; Description : Enters sleep state, which will be exited when an interrupt is received.
  99. ;
  100. ; Prototypes : void CPU_WaitForInt (void)
  101. ;
  102. ; Argument(s) : none.
  103. ;********************************************************************************************************
  104. CPU_WaitForInt:
  105. WFI ; Wait for interrupt
  106. BX LR
  107. ;********************************************************************************************************
  108. ; WAIT FOR EXCEPTION
  109. ;
  110. ; Description : Enters sleep state, which will be exited when an exception is received.
  111. ;
  112. ; Prototypes : void CPU_WaitForExcept (void)
  113. ;
  114. ; Argument(s) : none.
  115. ;********************************************************************************************************
  116. CPU_WaitForExcept:
  117. WFE ; Wait for exception
  118. BX LR
  119. ;********************************************************************************************************
  120. ; CPU_CntLeadZeros()
  121. ; COUNT LEADING ZEROS
  122. ;
  123. ; Description : Counts the number of contiguous, most-significant, leading zero bits before the
  124. ; first binary one bit in a data value.
  125. ;
  126. ; Prototype : CPU_DATA CPU_CntLeadZeros(CPU_DATA val);
  127. ;
  128. ; Argument(s) : val Data value to count leading zero bits.
  129. ;
  130. ; Return(s) : Number of contiguous, most-significant, leading zero bits in 'val'.
  131. ;
  132. ; Caller(s) : Application.
  133. ;
  134. ; This function is an INTERNAL CPU module function but MAY be called by application
  135. ; function(s).
  136. ;
  137. ; Note(s) : (1) (a) Supports 32-bit data value size as configured by 'CPU_DATA' (see 'cpu.h
  138. ; CPU WORD CONFIGURATION Note #1').
  139. ;
  140. ; (b) For 32-bit values :
  141. ;
  142. ; b31 b30 b29 ... b04 b03 b02 b01 b00 # Leading Zeros
  143. ; --- --- --- --- --- --- --- --- ---------------
  144. ; 1 x x x x x x x 0
  145. ; 0 1 x x x x x x 1
  146. ; 0 0 1 x x x x x 2
  147. ; : : : : : : : : :
  148. ; : : : : : : : : :
  149. ; 0 0 0 1 x x x x 27
  150. ; 0 0 0 0 1 x x x 28
  151. ; 0 0 0 0 0 1 x x 29
  152. ; 0 0 0 0 0 0 1 x 30
  153. ; 0 0 0 0 0 0 0 1 31
  154. ; 0 0 0 0 0 0 0 0 32
  155. ;
  156. ;
  157. ; (2) MUST be defined in 'cpu_a.asm' (or 'cpu_c.c') if CPU_CFG_LEAD_ZEROS_ASM_PRESENT is
  158. ; #define'd in 'cpu_cfg.h' or 'cpu.h'.
  159. ;********************************************************************************************************
  160. CPU_CntLeadZeros:
  161. CLZ R0, R0 ; Count leading zeros
  162. BX LR
  163. ;********************************************************************************************************
  164. ; CPU_CntTrailZeros()
  165. ; COUNT TRAILING ZEROS
  166. ;
  167. ; Description : Counts the number of contiguous, least-significant, trailing zero bits before the
  168. ; first binary one bit in a data value.
  169. ;
  170. ; Prototype : CPU_DATA CPU_CntTrailZeros(CPU_DATA val);
  171. ;
  172. ; Argument(s) : val Data value to count trailing zero bits.
  173. ;
  174. ; Return(s) : Number of contiguous, least-significant, trailing zero bits in 'val'.
  175. ;
  176. ; Caller(s) : Application.
  177. ;
  178. ; This function is an INTERNAL CPU module function but MAY be called by application
  179. ; function(s).
  180. ;
  181. ; Note(s) : (1) (a) Supports 32-bit data value size as configured by 'CPU_DATA' (see 'cpu.h
  182. ; CPU WORD CONFIGURATION Note #1').
  183. ;
  184. ; (b) For 32-bit values :
  185. ;
  186. ; b31 b30 b29 b28 b27 ... b02 b01 b00 # Trailing Zeros
  187. ; --- --- --- --- --- --- --- --- ----------------
  188. ; x x x x x x x 1 0
  189. ; x x x x x x 1 0 1
  190. ; x x x x x 1 0 0 2
  191. ; : : : : : : : : :
  192. ; : : : : : : : : :
  193. ; x x x x 1 0 0 0 27
  194. ; x x x 1 0 0 0 0 28
  195. ; x x 1 0 0 0 0 0 29
  196. ; x 1 0 0 0 0 0 0 30
  197. ; 1 0 0 0 0 0 0 0 31
  198. ; 0 0 0 0 0 0 0 0 32
  199. ;
  200. ;
  201. ; (2) MUST be defined in 'cpu_a.asm' (or 'cpu_c.c') if CPU_CFG_TRAIL_ZEROS_ASM_PRESENT is
  202. ; #define'd in 'cpu_cfg.h' or 'cpu.h'.
  203. ;********************************************************************************************************
  204. CPU_CntTrailZeros:
  205. RBIT R0, R0 ; Reverse bits
  206. CLZ R0, R0 ; Count trailing zeros
  207. BX LR
  208. ;********************************************************************************************************
  209. ; CPU_RevBits()
  210. ; REVERSE BITS
  211. ;
  212. ; Description : Reverses the bits in a data value.
  213. ;
  214. ; Prototypes : CPU_DATA CPU_RevBits(CPU_DATA val);
  215. ;
  216. ; Argument(s) : val Data value to reverse bits.
  217. ;
  218. ; Return(s) : Value with all bits in 'val' reversed (see Note #1).
  219. ;
  220. ; Caller(s) : Application.
  221. ;
  222. ; This function is an INTERNAL CPU module function but MAY be called by application function(s).
  223. ;
  224. ; Note(s) : (1) The final, reversed data value for 'val' is such that :
  225. ;
  226. ; 'val's final bit 0 = 'val's original bit N
  227. ; 'val's final bit 1 = 'val's original bit (N - 1)
  228. ; 'val's final bit 2 = 'val's original bit (N - 2)
  229. ;
  230. ; ... ...
  231. ;
  232. ; 'val's final bit (N - 2) = 'val's original bit 2
  233. ; 'val's final bit (N - 1) = 'val's original bit 1
  234. ; 'val's final bit N = 'val's original bit 0
  235. ;********************************************************************************************************
  236. CPU_RevBits:
  237. RBIT R0, R0 ; Reverse bits
  238. BX LR
  239. ;********************************************************************************************************
  240. ; CPU ASSEMBLY PORT FILE END
  241. ;********************************************************************************************************
  242. END