home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / unix / riscbsd / datafile / _btriscbsd / booter / h / arm6 < prev    next >
Encoding:
Text File  |  1994-08-07  |  4.4 KB  |  162 lines

  1. ; ARM6 PSR transfer macros
  2.  
  3. ; Condition code symbols
  4.  
  5. Cond_EQ *       0  :SHL: 28
  6. Cond_NE *       1  :SHL: 28
  7. Cond_CS *       2  :SHL: 28
  8. Cond_HS * Cond_CS
  9. Cond_CC *       3  :SHL: 28
  10. Cond_LO * Cond_CC
  11. Cond_MI *       4  :SHL: 28
  12. Cond_PL *       5  :SHL: 28
  13. Cond_VS *       6  :SHL: 28
  14. Cond_VC *       7  :SHL: 28
  15. Cond_HI *       8  :SHL: 28
  16. Cond_LS *       9  :SHL: 28
  17. Cond_GE *       10 :SHL: 28
  18. Cond_LT *       11 :SHL: 28
  19. Cond_GT *       12 :SHL: 28
  20. Cond_LE *       13 :SHL: 28
  21. Cond_AL *       14 :SHL: 28
  22. Cond_   * Cond_AL
  23. Cond_NV *       15 :SHL: 28
  24.  
  25. ; New positions of I and F bits in 32-bit PSR
  26.  
  27. I32_bit *       1 :SHL: 7
  28. F32_bit *       1 :SHL: 6
  29. IF32_26Shift *  26-6
  30.  
  31. ; Processor mode numbers
  32.  
  33. USR26_mode      *       2_00000
  34. FIQ26_mode      *       2_00001
  35. IRQ26_mode      *       2_00010
  36. SVC26_mode      *       2_00011
  37. USR32_mode      *       2_10000
  38. FIQ32_mode      *       2_10001
  39. IRQ32_mode      *       2_10010
  40. SVC32_mode      *       2_10011
  41. ABT32_mode      *       2_10111
  42. UND32_mode      *       2_11011
  43.  
  44. ; New register names
  45.  
  46. r13_abort       RN      13
  47. r14_abort       RN      14
  48. lr_abort        RN      14
  49.  
  50. r13_undef       RN      13
  51. r14_undef       RN      14
  52. lr_undef        RN      14
  53.  
  54.         MACRO
  55.         mrs     $cond, $rd, $psrs
  56.         LCLA    psrtype
  57. psrtype SETA    -1
  58.  [ "$psrs" = "CPSR" :LOR: "$psrs" = "CPSR_all"
  59. psrtype SETA    0 :SHL: 22
  60.  ]
  61.  [ "$psrs" = "SPSR" :LOR: "$psrs" = "SPSR_all"
  62. psrtype SETA    1 :SHL: 22
  63.  ]
  64.         ASSERT  psrtype <> -1
  65.         ASSERT  $rd <> 15
  66.         &       Cond_$cond :OR: 2_00000001000011110000000000000000 :OR: psrtype :OR: ($rd :SHL: 12)
  67.         MEND
  68.  
  69.         MACRO
  70.         msr     $cond, $psrl, $op2a, $op2b
  71.         LCLA    psrtype
  72.         LCLS    op2as
  73.         LCLA    op
  74.         LCLA    shift
  75. psrtype SETA    -1
  76.  [ "$psrl" = "CPSR" :LOR: "$psrl" = "CPSR_all"
  77. psrtype SETA    (0:SHL:22) :OR: (1:SHL:19) :OR: (1:SHL:16)
  78.  ]
  79.  [ "$psrl" = "CPSR_flg"
  80. psrtype SETA    (0:SHL:22) :OR: (1:SHL:19) :OR: (0:SHL:16)
  81.  ]
  82.  [ "$psrl" = "CPSR_ctl"
  83. psrtype SETA    (0:SHL:22) :OR: (0:SHL:19) :OR: (1:SHL:16)
  84.  ]
  85.  [ "$psrl" = "SPSR" :LOR: "$psrl" = "SPSR_all"
  86. psrtype SETA    (1:SHL:22) :OR: (1:SHL:19) :OR: (1:SHL:16)
  87.  ]
  88.  [ "$psrl" = "SPSR_flg"
  89. psrtype SETA    (1:SHL:22) :OR: (1:SHL:19) :OR: (0:SHL:16)
  90.  ]
  91.  [ "$psrl" = "SPSR_ctl"
  92. psrtype SETA    (1:SHL:22) :OR: (0:SHL:19) :OR: (1:SHL:16)
  93.  ]
  94.         ASSERT  psrtype <> -1
  95.  [ ("$op2a" :LEFT: 1) = "#"
  96.  ; Immediate operand
  97.  
  98. op2as   SETS    "$op2a" :RIGHT: ((:LEN: "$op2a")-1)
  99. op      SETA    $op2as
  100.  
  101.   [ "$op2b" = ""
  102.   ; Rotate not specified in immediate operand
  103. shift   SETA    0
  104.         WHILE   (op :AND: &FFFFFF00)<>0 :LAND: shift<16
  105. op      SETA    ((op:SHR:30):AND:3):OR:(op:SHL:2)
  106. shift   SETA    shift + 1
  107.         WEND
  108.         ASSERT  (op :AND: &FFFFFF00)=0
  109.   |
  110.   ; Rotate of immediate operand specified explicitly
  111.         ASSERT  (($op2b):AND:&FFFFFFE1)=0
  112. shift   SETA    ($opt2b):SHR:1
  113.   ]
  114. op      SETA    (shift :SHL: 8) :OR: op :OR: (1:SHL:25)
  115.  |
  116.  
  117.  ; Not an immediate operand
  118.   [ "$op2b" = ""
  119.   ; Unshifted register
  120. op      SETA    ($op2a) :OR: (0:SHL:25)
  121.   |
  122.         ! 1, "Shifted register not yet implemented in this macro!"
  123.   ]
  124.  ]
  125.         &       Cond_$cond :OR: 2_00000001001000001111000000000000 :OR: op :OR: psrtype
  126.         MEND
  127.  
  128. ; SetMode newmode, reg1, regoldpsr
  129. ;
  130. ; Sets processor mode to constant value newmode
  131. ; using register reg1 as a temporary.
  132. ; If regoldpsr is specified, then this register
  133. ; on exit holds the old PSR before the mode change
  134. ; reg1 on exit always holds the new PSR after the mode change
  135.  
  136. ;        MACRO
  137. ;        SetMode $newmode, $reg1, $regoldpsr
  138. ; [ "$regoldpsr"=""
  139. ;        mrs     AL, $reg1, CPSR_all
  140. ;        BIC     $reg1, $reg1, #&1F
  141. ;        ORR     $reg1, $reg1, #$newmode
  142. ;        msr     AL, CPSR_all, $reg1
  143. ; |
  144. ;        mrs     AL, $regoldpsr, CPSR_all
  145. ;        BIC     $reg1, $regoldpsr, #&1F
  146. ;        ORR     $reg1, $reg1, #$newmode
  147. ;        msr     AL, CPSR_all, $reg1
  148. ; ]
  149. ;        MEND
  150.  
  151.         MACRO
  152.         mrc     $cond, $coproc, $op, $rd, $crn, $crm, $info
  153.         &       Cond_$cond :OR: 2_00001110000100000000000000010000 :OR: ($coproc :SHL: 8) :OR: ($op :SHL: 21) :OR: ($rd :SHL: 12) :OR: ($crn :SHL: 16) :OR: $crm :OR: ($info :SHL: 5)
  154.         MEND
  155.  
  156.         MACRO
  157.         mcr     $cond, $coproc, $op, $rd, $crn, $crm, $info
  158.         &       Cond_$cond :OR: 2_00001110000000000000000000010000 :OR: ($coproc :SHL: 8) :OR: ($op :SHL: 21) :OR: ($rd :SHL: 12) :OR: ($crn :SHL: 16) :OR: $crm :OR: ($info :SHL: 5)
  159.         MEND
  160.  
  161.     END
  162.