home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / program / virtual / VSI_C / a / IncAsm next >
Encoding:
Text File  |  1992-09-15  |  5.5 KB  |  311 lines

  1. ; >  IncAsm
  2.  
  3. ;  IDENTIFICATION:    a.IncAsm
  4. ;
  5. ;  DESCRIPTION:
  6. ;       Assembler Includes, feel free to distribute
  7. ;       Updated to Release 3 of C
  8. ;
  9. ;  CONTENTS:
  10. ;       Register Definitions
  11. ;       Condition code masks
  12. ;       Interrupt Disable masks
  13. ;       Processor mode masks
  14. ;       Status and address masks
  15. ;       SYNC
  16. ;       ARM3R ARM3W
  17. ;       XSWP XSWPEQ XSWPNE XSWPB
  18. ;       ADR ADRCC ADRCS ADREQ ADRNE
  19. ;       ADRGE ADRLT
  20. ;       XMOV XMOVEQ XMOVNE XMVN
  21. ;       XWriteI XWriteS
  22. ;       CHEAD CENTRY CEXIT
  23. ;       DEFAREA DEFLABEL DEFALIGN
  24. ;       DEFB DEFS DEFL DEFA
  25. ;
  26. ;  REVISION HISTORY:
  27.  
  28. ;  C constants
  29.  
  30. .EXTERN x$stack_overflow, x$stack_overflow_1, _WriteS
  31.  
  32. a1  =   0
  33. a2  =   1
  34. a3  =   2
  35. a4  =   3
  36.  
  37. v1  =   4
  38. v2  =   5
  39. v3  =   6
  40. v4  =   7
  41. v5  =   8
  42. v6  =   9
  43.  
  44. sl  =   10
  45. fp  =   11
  46. ip  =   12
  47. sp  =   13
  48.  
  49. lr  =   14
  50. pc  =   15
  51.  
  52. ; General Assembler constants and macros
  53.  
  54. PC  =   15
  55.  
  56. N_bit   =   0x80000000
  57. Z_bit   =   0x40000000
  58. C_bit   =   0x20000000
  59. V_bit   =   0x10000000
  60.  
  61. I_bit   =   0x08000000
  62. F_bit   =   0x04000000
  63.  
  64. U_mode  =   0
  65. F_mode  =   1
  66. I_mode  =   2
  67. S_mode  =   3
  68.  
  69. Adr_bits    =   0x03FFFFFC
  70. Status_bits =   0xFC000003
  71.  
  72. D_bits  =   0x0C000000                   ; Disable all interrupts
  73. P_bits  =   0x00000003
  74.  
  75. Sys_bits    =   D_bits+P_bits
  76.  
  77. ; Error Message format
  78.  
  79. .MACRO  ERRMESS Number, String
  80.         .LONG   Number
  81.         .ASCIZ  String
  82.         .ALIGN
  83. .ENDM
  84.  
  85. ; SYNC - noop after mode change or user bank access
  86. ; not often needed on ARM3 but safer to leave in
  87.  
  88. .MACRO  SYNC
  89.         MOV     r0,r0
  90. .ENDM
  91.  
  92. ; ARM3 Cache controller read/write (CP# 15)
  93.  
  94. .MACRO  ARM3R   Rdest_, A3Cn_
  95.         .LONG   0xEE100F10+(Rdest_<<12)+(A3Cn_<<16)
  96. .ENDM
  97.  
  98.  
  99. .MACRO  ARM3W   Rsource_, A3Cn_
  100.         .LONG   0xEE000F10+(Rsource_<<12)+(A3Cn_<<16)
  101. .ENDM
  102.  
  103. ;  ARM 3 Instruction SWP
  104.  
  105. .MACRO  XSWP    Rsource_, Rdest_, Rbase_
  106.         .LONG   0xE1000090+(Rbase_<<16)+(Rdest_<<12)+Rsource_
  107. .ENDM
  108.  
  109. .MACRO  XSWPEQ  Rsource_, Rdest_, Rbase_
  110.         .LONG   0x01000090+(Rbase_<<16)+(Rdest_<<12)+Rsource_
  111. .ENDM
  112.  
  113. .MACRO  XSWPNE  Rsource_, Rdest_, Rbase_
  114.         .LONG   0x11000090+(Rbase_<<16)+(Rdest_<<12)+Rsource_
  115. .ENDM
  116.  
  117. .MACRO  XSWPB   Rsource_, Rdest_, Rbase_
  118.         .LONG   0xE1400090+(Rbase_<<16)+(Rdest_<<12)+Rsource_
  119. .ENDM
  120.  
  121. ;  Extended operation set
  122.  
  123. .MACRO  ADR     reg_,label_
  124.         ADR_    reg_,label_
  125. .ENDM
  126.  
  127. .MACRO  ADRCC   reg_,label_
  128.         ADR_    reg_,label_,CC
  129. .ENDM
  130.  
  131. .MACRO  ADRCS   reg_,label_
  132.         ADR_    reg_,label_,CS
  133. .ENDM
  134.  
  135. .MACRO  ADREQ   reg_,label_
  136.         ADR_    reg_,label_,EQ
  137. .ENDM
  138.  
  139. .MACRO  ADRNE   reg_,label_
  140.         ADR_    reg_,label_,NE
  141. .ENDM
  142.  
  143. .MACRO  ADRGE   reg_,label_
  144.         ADR_    reg_,label_,GE
  145. .ENDM
  146.  
  147. .MACRO  ADRLT   reg_,label_
  148.         ADR_    reg_,label_,LT
  149. .ENDM
  150.  
  151. .MACRO  XMOV    reg_, value_
  152.         XOP1_   MOV,ORR,reg_,value_
  153. .ENDM
  154.  
  155. .MACRO  XMOVEQ  reg_, value_
  156.         XOP1_   MOVEQ,ORREQ,reg_,value_
  157. .ENDM
  158.  
  159. .MACRO  XMOVNE  reg_, value_
  160.         XOP1_   MOVNE,ORRNE,reg_,value_
  161. .ENDM
  162.  
  163. .MACRO  XMVN    reg_, value_
  164.         XOP1_   MVN,BIC,reg_,value_
  165. .ENDM
  166.  
  167. ;  SWI calls
  168.  
  169. .MACRO  XWriteI  ch_
  170.         SWI     XSWI+OS_WriteI+(ch_)
  171. .ENDM
  172.  
  173. .MACRO  XWriteS  string_
  174.         SWI     XSWI+OS_WriteS
  175.         .ASCIZ  string_
  176.         .ALIGN
  177. .ENDM
  178.  
  179. ;  C macros
  180.  
  181. .MACRO  CHEAD   name_,cname_
  182.         .ALIGN
  183. $1:     .ASCIZ  cname_
  184.         .ALIGN
  185.         .LONG   0xFF000000+$-$1
  186. name_:
  187. .ENDM
  188.  
  189. .MACRO  CENTRY  name_,cname_,aregs_,vregs_,wspace_=0
  190.         CHEAD   name_,cname_
  191.         MOV     ip,sp
  192. .IF .MPEXISTS(aregs_)
  193.     .IF .MPEXISTS(vregs_)
  194.         STMFD   sp!,{aregs_,vregs_,fp,ip,lr,pc}
  195.     .ELSE
  196.         STMFD   sp!,{aregs_,fp,ip,lr,pc}
  197.     .ENDIF
  198. .ELSE
  199.     .IF .MPEXISTS(vregs_)
  200.         STMFD   sp!,{vregs_,fp,ip,lr,pc}
  201.     .ELSE
  202.         STMFD   sp!,{fp,ip,lr,pc}
  203.     .ENDIF
  204. .ENDIF
  205.         SUB     fp,ip,#4
  206. .IF wspace < 64
  207.         CMPS    sp,sl
  208.         BLLT    x$stack_overflow
  209. .ELSE
  210.         SUB     ip,sp,#wspace_*4+4
  211.         CMPS    ip,sl
  212.         BLLT    x$stack_overflow_1
  213. .ENDIF
  214. .IF wspace_ != 0
  215.         SUB     sp,sp,#wspace_*4
  216. .ENDIF
  217. .ENDM
  218.  
  219. .MACRO  CEXIT   vregs_
  220. .IF .MPEXISTS(vregs_)
  221.         LDMEA   fp,{vregs_,fp,sp,pc}^
  222. .ELSE
  223.         LDMEA   fp,{fp,sp,pc}^
  224. .ENDIF
  225. .ENDM
  226.  
  227. ;  Static area or structure definition macros
  228.  
  229. .MACRO  DEFAREA name_,posn_=0
  230. defarea_ :=  posn_
  231. name_    =   defarea_
  232. .ENDM
  233.  
  234. .MACRO  DEFLABEL name_
  235. name_   =   defarea_
  236. .ENDM
  237.  
  238. .MACRO  DEFALIGN align_=4
  239. defarea_ :=  defarea_ & -align_
  240. .ENDM
  241.  
  242. .MACRO  DEFB    name_,count_=1
  243. name_    =  defarea_
  244. defarea_ := defarea_ + (count_)
  245. .ENDM
  246.  
  247. .MACRO  DEFS    name_,count_=1
  248. name_    =  defarea_
  249. defarea_ := defarea_ + 2*(count_)
  250. .ENDM
  251.  
  252. .MACRO  DEFL    name_,count_=1
  253. defarea_ := defarea_ & -4
  254. name_    =  defarea_
  255. defarea_ := defarea_ + 4*(count_)
  256. .ENDM
  257.  
  258. .MACRO  DEFA    name_,count_=1
  259. defarea_ := defarea_ & -4
  260. name_    =  defarea_
  261. defarea_ := defarea_ + 4*(count_)
  262. .ENDM
  263.  
  264. ;  Support Macros - not for direct use
  265.  
  266. .MACRO  ADR_    reg_,label_,cc_
  267. .IF     (label_)>=$+8
  268.         ADD'cc_ reg_,pc,#(label_)-$-8
  269. .ELSE
  270.         SUB'cc_ reg_,pc,#$+8-(label_)
  271. .ENDIF
  272. .ENDM
  273.  
  274. .MACRO  ANALYSE_ number_
  275. s_  :=  number_
  276. s_  :=  (s_ << 4) | (s_ >>> 28) | s_
  277. s_  :=  (s_ << 2) | (s_ >>> 30) | s_
  278. s_  :=  (s_ | (s_ >>> 1)) & 0x55555555
  279. s_  :=  (s_ << 1) | s_
  280. s_  :=  (s_ + 1) & s_
  281. s_  :=  ((s_ - 1) & ~ s_) + 1
  282. .IF s_ == 0
  283.     m_  := 0xFF
  284. .ENDIF
  285. .IF s_ & 0xFFFFFF
  286.     m_  := 0xFF * s_
  287. .ENDIF
  288. .IF s_ & 0xFF000000
  289.     s_ := s_ >>> 24
  290.     m_ := 0xFF * s_
  291.     m_ := (m_ << 24) | (m_ >> 8)
  292. .ENDIF
  293. n1_ :=  number_ & m_
  294. n2_ :=  number_ - n1_
  295. .ENDM
  296.  
  297. .MACRO  XOP1_   op1_, op2_, reg_, value_
  298. .NOLIST
  299.         ANALYSE_ value_
  300. .LIST
  301.         op1_   reg_,#n1_
  302. .NOLIST
  303. .REPEATWHILE    (n2_    != 0)
  304.         ANALYSE_ n2_
  305. .LIST
  306.         op2_   reg_,reg_,#n1_
  307. .NOLIST
  308. .ENDREPEAT
  309. .LIST
  310. .ENDM
  311.