Home | History | Annotate | Download | only in cpu
      1 ; Morpho Technologies MT Arch description.  -*- Scheme -*-
      2 ; Copyright 2001, 2007, 2009 Free Software Foundation, Inc.
      3 ;
      4 ; Contributed by Red Hat Inc; developed under contract from
      5 ; Morpho Technologies.
      6 ;
      7 ; This file is part of the GNU Binutils.
      8 ;
      9 ; This program is free software; you can redistribute it and/or modify
     10 ; it under the terms of the GNU General Public License as published by
     11 ; the Free Software Foundation; either version 3 of the License, or
     12 ; (at your option) any later version.
     13 ;
     14 ; This program is distributed in the hope that it will be useful,
     15 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
     16 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17 ; GNU General Public License for more details.
     18 ;
     19 ; You should have received a copy of the GNU General Public License
     20 ; along with this program; if not, write to the Free Software
     21 ; Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
     22 ; MA 02110-1301, USA.
     23 
     24 (include "simplify.inc")
     25 
     26 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     27 ;; Define The Architecture, Attributes, ISA, CPU, Machine, And Model. ;;
     28 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     29 
     30 ; define-arch must appear first
     31 (define-arch
     32   (name mt) ; name of cpu family
     33   (comment "Morpho Technologies mRISC family")
     34   (default-alignment aligned)
     35   (insn-lsb0? #t)
     36   (machs ms1 ms1-003 ms2)
     37   (isas mt)
     38 )
     39 
     40 ; Instruction set parameters.
     41 
     42 (define-isa
     43   (name mt)
     44   (comment "Morpho Technologies MT ISA")
     45   (default-insn-word-bitsize 32)
     46   (default-insn-bitsize 32)
     47   (base-insn-bitsize 32)
     48   (parallel-insns 2)
     49 )
     50 
     52 ; Cpu family definitions.
     53 
     54 
     55 (define-cpu
     56   ; cpu names must be distinct from the architecture name and machine names.
     57   (name ms1bf)
     58   (comment "Morpho Technologies mRISC family")
     59   (endian big)
     60   (word-bitsize 32)
     61 )
     62 
     63 (define-cpu
     64   ; cpu names must be distinct from the architecture name and machine names.
     65   (name ms1-003bf)
     66   (comment "Morpho Technologies mRISC family")
     67   (endian big)
     68   (word-bitsize 32)
     69 )
     70 
     71 (define-cpu
     72   ; cpu names must be distinct from the architecture name and machine names.
     73   (name ms2bf)
     74   (comment "Morpho Technologies mRISC family")
     75   (endian big)
     76   (word-bitsize 32)
     77 )
     78 
     79 (define-mach
     80   (name ms1)
     81   (comment "Morpho Technologies mrisc")
     82   (cpu ms1bf)
     83   (isas mt)
     84 )
     85 
     86 (define-mach
     87   (name ms1-003)
     88   (comment "Morpho Technologies mrisc")
     89   (cpu ms1-003bf)
     90   (isas mt)
     91 )
     92 
     93 (define-mach
     94   (name ms2)
     95   (comment "Morpho Technologies ms2")
     96   (cpu ms2bf)
     97   (isas mt)
     98 )
     99 
    100 
    102 ; Model descriptions.
    103 ; Can probably take the u-exec out.  We'll see.
    104 (define-model
    105   (name ms1)
    106   (comment "Morpho Technologies mrisc")
    107   (mach ms1)
    108   (unit u-exec "Execution Unit" ()
    109 	1 1 ; issue done
    110 	() ; state
    111 	() ; inputs
    112 	() ; outputs
    113 	() ; profile action (default)
    114 	)
    115 )
    116 
    117 (define-model
    118   (name ms1-003)
    119   (comment "Morpho Technologies mrisc")
    120   (mach ms1-003)
    121   (unit u-exec "Execution Unit" ()
    122 	1 1 ; issue done
    123 	() ; state
    124 	() ; inputs
    125 	() ; outputs
    126 	() ; profile action (default)
    127 	)
    128 )
    129 
    130 (define-model
    131   (name ms2)
    132   (comment "Morpho Technologies ms2")
    133   (mach ms2)
    134   (unit u-exec "Execution Unit" ()
    135 	1 1 ; issue done
    136 	() ; state
    137 	() ; inputs
    138 	() ; outputs
    139 	() ; profile action (default)
    140 	)
    141 )
    142 
    143 ; FIXME: It might simplify things to separate the execute process from the
    144 ; one that updates the PC.
    145 
    147 
    148 ;;;;;;;;;;;;;;;;;;;;;;;;
    149 ;; Instruction Fields ;;
    150 ;;;;;;;;;;;;;;;;;;;;;;;;
    151 
    152 ; Attributes:
    153 ; PCREL-ADDR: pc relative value (for reloc and disassembly purposes)
    154 ; ABS-ADDR: absolute address (for reloc and disassembly purposes?)
    155 ; RESERVED: bits are not used to decode insn, must be all 0
    156 ; RELOC: there is a relocation associated with this field (experiment)
    157 ;
    158 ; f-msys: Identify a a morphosys insns.  1 if msys, 0 if not.
    159 ; f-opc: 6 bit opcode for non-morphosys instructions.
    160 ; f-msopc: 6 bit opcode for morphosys instructions.
    161 ; f-imm: flag to indicate use of an immediate operand.  1 if yes, 0 if no.
    162 ; f-sr1: source resgister 1. (also used for MSYS insns)
    163 ; f-sr2: source register 2. (also used for MSYS insns)
    164 ; f-dr: destination register when located in bits 19:16.
    165 ; f-drrr: destination register when located in bits 15:12. (also for MSYS insns)
    166 ; f-imm16: 16 bit immediate value when not an offset.
    167 ; f-imm16a: 16 bit immediate value when it's a pc-rel offset.
    168 ; f-uu4a: unused 4 bit field.
    169 ; f-uu4b: second unsed 4 bit field.
    170 ; f-uu1: unused 1 bit field
    171 ; f-uu12: unused 12 bit field.
    172 ; f-uu16: unused 16 bit field.
    173 ; f-uu24: unused 24 bit field.
    174 
    175 (dnf f-msys      "morphosys insn flag"  	() 31 1)
    176 (dnf f-opc       "opcode field"			() 30 6)
    177 (dnf f-imm       "immedate flag"		() 24 1)
    178 (dnf f-uu24      "unused 24 bits"               () 23 24)
    179 (dnf f-sr1       "sr1 register field"	(ABS-ADDR) 23 4)
    180 (dnf f-sr2       "sr2 register field"	(ABS-ADDR) 19 4)
    181 (dnf f-dr        "dr register field"	(ABS-ADDR) 19 4)
    182 (dnf f-drrr      "drrr register field"	(ABS-ADDR) 15 4)
    183 (dnf f-imm16u    "unsigned 16 bit immediate"    () 15 16)
    184 (df  f-imm16s    "signed 16 bit immediate"      () 15 16 INT ((value pc) (add HI value 0)) ((value pc) (add HI value 0)))
    185 (dnf f-imm16a	 "pc-rel offset"      (PCREL-ADDR) 15 16)
    186 (dnf f-uu4a      "unused 4 bit field"		() 19 4)
    187 (dnf f-uu4b      "unused 4 bit field"		() 23 4)
    188 (dnf f-uu12      "unused 12 bit field"	        () 11 12)
    189 (dnf f-uu8       "unused 8 bit field"           () 15 8)
    190 (dnf f-uu16      "unused 16 bit field" 	        () 15 16)
    191 (dnf f-uu1       "unused 1 bit field" 	        ()  7 1)
    192 
    193 ; The following ifields are used exclusively for the MorphoSys instructions.
    194 ; In a few cases, a bit field is used for something in addition to what its
    195 ; name suggests.  For the most part, the names are meaningful though.
    196 
    197 (dnf f-msopc     "opcode field"			() 30 5)
    198 (dnf f-uu-26-25  "unused 26 bits"               () 25 26)
    199 (dnf f-mask      "mask"	                        () 25 16)
    200 (dnf f-bankaddr  "bank address"	                () 25 13)
    201 (dnf f-rda       "rda"	                        () 25 1)
    202 (dnf f-uu-2-25   "unused bits  25 & 24"		() 25 2)
    203 (dnf f-rbbc      "Omega network configuration"	() 25 2)
    204 (dnf f-perm	 "perm"				() 25 2)
    205 (dnf f-mode      "mode"                         () 25 2)
    206 (dnf f-uu-1-24   "testing" 			() 24 1)
    207 (dnf f-wr        "wr"	                        () 24 1)
    208 (dnf f-fbincr    "fb incr"                      () 23 4)
    209 (dnf f-uu-2-23   "unused bits 23 and 22"	() 23 2)
    210 (dnf f-xmode     "xmode"	                () 23 1)
    211 (dnf f-a23	 "a23"				() 23 1)
    212 (dnf f-mask1     "mask1"	                () 22 3)
    213 (dnf f-cr 	 "cr"				() 22 3)
    214 (dnf f-type      "type"	                        () 21 2)
    215 (dnf f-incamt    "increment amount"             () 19 8)
    216 (dnf f-cbs	 "cbs"				() 19 2)
    217 (dnf f-uu-1-19   "unused bit 19"		() 19 1)
    218 (dnf f-ball      "b_all"	                () 19 1)
    219 (dnf f-colnum    "column number"		() 18 3)
    220 (dnf f-brc       "b_r_c"	                () 18 3)
    221 (dnf f-incr	 "incr"				() 17 6)
    222 (dnf f-fbdisp    "frame buffer displacement"	() 15 6)
    223 (dnf f-uu-4-15   "unused bits 15,14,13,12"	() 15 4)
    224 (dnf f-length	 "length"			() 15 3)
    225 (dnf f-uu-1-15   "unused bit 15"         	() 15 1)
    226 (dnf f-rc        "row/column context"		() 15 1)
    227 (dnf f-rcnum     "starting cell of cntxt mem."	() 14 3)
    228 (dnf f-rownum    "row number"		        () 14 3)
    229 (dnf f-cbx	 "cbx"				() 14 3)
    230 (dnf f-id        "id"                           () 14 1)
    231 (dnf f-size      "size"                         () 13 14)
    232 (dnf f-rownum1   "row number"		        () 12 3)
    233 (dnf f-uu-3-11   "unused 3 bits (11-9)"         () 11 3)
    234 (dnf f-rc1       "row/column context"		() 11 1)
    235 (dnf f-ccb	 "ccb"				() 11 1)
    236 (dnf f-cbrb      "data-bus orientation"		() 10 1)
    237 (dnf f-cdb	 "cdb"				() 10 1)
    238 (dnf f-rownum2   "row number"		        ()  9 3)
    239 (dnf f-cell      "cell"         		()  9 3)
    240 (dnf f-uu-3-9    "unused 3 bits (9-7)"          ()  9 3)
    241 (dnf f-contnum   "context number"		()  8 9)
    242 (dnf f-uu-1-6    "unused bit 6"                 ()  6 1)
    243 (dnf f-dup       "dup"           		()  6 1)
    244 (dnf f-rc2       "rc2"           		()  6 1)
    245 (dnf f-ctxdisp   "context displacement"		()  5 6)
    246 
    247 ; additional fields in ms2
    248 (dnf f-imm16l    "loop count"                   () 23 16)
    249 (df  f-loopo	 "loop offset"			() 7 8 UINT
    250     ((value pc) (srl SI value 2))
    251     ((value pc) (add SI (sll value 2) 8))
    252  )
    253 (dnf f-cb1sel    "cb1 select"                   () 25 3)
    254 (dnf f-cb2sel    "cb2 select"                   () 22 3)
    255 (dnf f-cb1incr   "cb1 increment"                (SIGNED) 19 6)
    256 (dnf f-cb2incr   "cb2 increment"                (SIGNED) 13 6)
    257 (dnf f-rc3       "row/colum context"            ()  7 1)
    258 
    259 ; The following is just for a test
    260 (dnf f-msysfrsr2 "sr2 for msys"			() 19 4)
    261 (dnf f-brc2      "b_r_c2"                       () 14 3)
    262 (dnf f-ball2     "b_all2"                       () 15 1)
    263 
    264 
    266 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    267 ;; Enumerations Of Instruction Fields ;;
    268 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    269 
    270 ; insn-msys: bit 31.  1 for Morphosys Insns, 0 if not.
    271 (define-normal-insn-enum insn-msys "msys enums" () MSYS_ f-msys
    272   (NO YES)
    273 )
    274 
    275 ; insn-opc: bits 30 through 25 .  Non-MorphoSys Instructions
    276 ; Note - the documentation is wrong for the encoding of the DBNZ
    277 ; instruction.  It is actually 011110.  See Issue 67699.
    278 (define-normal-insn-enum insn-opc "opc enums" () OPC_ f-opc
    279   (ADD  ADDU SUB  SUBU MUL   -      -    -
    280    AND  OR   XOR  NAND NOR   XNOR   LDUI -
    281    LSL  LSR  ASR  -    -     -      -    -
    282    BRLT BRLE BREQ JMP  JAL   BRNEQ  DBNZ LOOP
    283    LDW  STW  -    -    -     -      -    -
    284    -    -    -    -    -     -      -    -
    285    EI   DI   SI   RETI BREAK IFLUSH -    -
    286   )
    287 )
    288 
    289 ; insn-msopc: bits 30 through 26 .  MorphoSys Instructions
    290 (define-normal-insn-enum insn-msopc "msopc enums" () MSOPC_ f-msopc
    291   (LDCTXT LDFB      STFB    FBCB     MFBCB    FBCCI     FBRCI     FBCRI
    292    FBRRI  MFBCCI    MFBRCI  MFBCRI   MFBRRI   FBCBDR    RCFBCB    MRCFBCB
    293    CBCAST DUPCBCAST WFBI    WFB      RCRISC   FBCBINC   RCXMODE   INTLVR
    294    WFBINC MWFBINC   WFBINCR MWFBINCR FBCBINCS MFBCBINCS FBCBINCRS MFBCBINCRS
    295    -      -         -       -        -        -         -         -
    296   )
    297 )
    298 
    299 ; insn-imm: bit 24.  Immediate operand indicator.
    300 (define-normal-insn-enum insn-imm "imm enums" () IMM_ f-imm
    301   ; This bit specifies whether and immediate operand will be present.
    302   ; It's 1 if there is, 0 if there is not.
    303   (NO YES)
    304 )
    305 ;;;;;;;;;;;;;;;;
    306 ;; Attributes ;;
    307 ;;;;;;;;;;;;;;;;
    308 
    309 ; Might not need this.  Keep if for the sim just in case.
    310 ;(define-attr
    311 ;  (for insn)
    312 ;  (type boolean)
    313 ;  (name EXT-SKIP-INSN)
    314 ;  (comment "instruction is a PAGE, LOADL or LOADH instruction")
    315 ;)
    316   
    317 (define-attr
    318   (for insn)
    319   (type boolean)
    320   (name LOAD-DELAY)
    321   (comment "insn has a load delay")
    322 )
    323   
    324 (define-attr
    325   (for insn)
    326   (type boolean)
    327   (name MEMORY-ACCESS)
    328   (comment "insn performs a memory access")
    329 )
    330 
    331 (define-attr
    332   (for insn)
    333   (type boolean)
    334   (name AL-INSN)
    335   (comment "insn is an arithmetic or logic insn.")
    336 )
    337 
    338 (define-attr
    339   (for insn)
    340   (type boolean)
    341   (name IO-INSN)
    342   (comment "insn performs an I/O operation")
    343 )
    344 
    345 (define-attr
    346   (for insn)
    347   (type boolean)
    348   (name BR-INSN)
    349   (comment "insn performs an I/O operation")
    350 )
    351 
    352 (define-attr
    353   (for insn)
    354   (type boolean)
    355   (name JAL-HAZARD)
    356   (comment "insn has jal-like hazard")
    357 )
    358 
    359 (define-pmacro (define-reg-use-attr regfield)
    360   (define-attr
    361     (for insn)
    362     (type boolean)
    363     (name (.sym "USES-" (.upcase regfield)))
    364     (comment ("insn accesses register operand " regfield))))
    365 
    366 (define-reg-use-attr "frdr")
    367 (define-reg-use-attr "frdrrr")
    368 (define-reg-use-attr "frsr1")
    369 (define-reg-use-attr "frsr2")
    370 
    371 
    372 ; Might not need this.  Keep it for the sim just in case.
    373 (define-attr
    374   (for insn)
    375   (type boolean)
    376   (name SKIPA)
    377   (comment "instruction is a SKIP instruction")
    378 )
    379 
    380  
    381 ;;;;;;;;;;;;;;;;;;;;; 
    382 ;; Hardware Pieces ;;
    383 ;;;;;;;;;;;;;;;;;;;;;
    384 
    385 ;(define-pmacro (build-reg-name n) (.splice (.str "$" n) n))
    386 
    387 ; These are the 16 registers that the chip has.  In later versions
    388 ; where there will be more registers, this will need to be expanded.
    389 ; Note that there are two entries for the registers with two names.
    390 (define-hardware
    391   (name h-spr)
    392   (comment "special-purpose registers")
    393   (type register SI (16))
    394   (indices keyword "" (("R0" 0) ("R1" 1) ("R2" 2) ("R3" 3) ("R4" 4) ("R5" 5)
    395   ("R6" 6) ("R7" 7) ("R8" 8) ("R9" 9) ("R10" 10) ("R11" 11) ("R12" 12) ("fp" 12)
    396   ("R13" 13) ("sp" 13) ("R14" 14) ("ra" 14) ("R15" 15) ("ira" 15)))
    397 ;  (get (index) (and (raw-reg h-spr) #xffffffff))
    398 ;  (set (index value) (set (raw-reg h-spr) (and value #xffffffff)))
    399 )
    400 
    401 ; This is the  program counter.
    402 (dnh h-pc "program counter" (PC PROFILE) (pc) () () ())
    403 
    404 (define-keyword
    405    (name msys-syms)
    406    (print-name h-nil)
    407    (prefix "")
    408    (values (DUP 1) (XX 0))
    409 )
    410 
    411 ;;;;;;;;;;;;;;
    412 ;; Operands ;;
    413 ;;;;;;;;;;;;;;
    414 
    415 (define-operand (name frsr1) (comment "register") (attrs) 
    416   (type h-spr) (index f-sr1) )
    417 (define-operand (name frsr2) (comment "register") (attrs) 
    418   (type h-spr) (index f-sr2) )
    419 (define-operand (name frdr) (comment "register") (attrs) 
    420   (type h-spr) (index f-dr) )
    421 (define-operand (name frdrrr) (comment "register") (attrs) 
    422   (type h-spr) (index f-drrr) )
    423 (define-operand (name imm16) (comment "immediate value - sign extd") (attrs) 
    424   (type h-sint) (index f-imm16s) (handlers (parse "imm16") (print "dollarhex")))
    425 (define-operand (name imm16z) (comment "immediate value - zero extd") (attrs) 
    426   (type h-uint) (index f-imm16u) (handlers (parse "imm16") (print "dollarhex")))
    427 (define-operand (name imm16o) (comment "immediate value") (attrs PCREL-ADDR) 
    428   (type h-uint) (index f-imm16s) (handlers (parse "imm16") (print "pcrel")))
    429 
    430 ; Operands for MorphoSys Instructions
    431 
    432 (define-operand (name rc) (comment "rc") (attrs) 
    433   (type h-uint) (index f-rc) (handlers (parse "rc") (print "dollarhex")))
    434 
    435 (define-operand (name rcnum) (comment "rcnum") (attrs) 
    436   (type h-uint) (index f-rcnum) (handlers (print "dollarhex")))
    437 
    438 (define-operand (name contnum) (comment "context number") (attrs) 
    439   (type h-uint) (index f-contnum) (handlers (print "dollarhex")))
    440 
    441 (define-operand (name rbbc) (comment "omega network configuration") (attrs) 
    442   (type h-uint) (index f-rbbc) (handlers (parse "rbbc") (print "dollarhex")))
    443 
    444 (define-operand (name colnum) (comment "column number") (attrs) 
    445   (type h-uint) (index f-colnum) (handlers (print "dollarhex")))
    446 
    447 (define-operand (name rownum) (comment "row number") (attrs) 
    448   (type h-uint) (index f-rownum) (handlers (print "dollarhex")))
    449 
    450 (define-operand (name rownum1) (comment "row number") (attrs) 
    451   (type h-uint) (index f-rownum1) (handlers (print "dollarhex")))
    452 
    453 (define-operand (name rownum2) (comment "row number") (attrs) 
    454   (type h-uint) (index f-rownum2) (handlers (print "dollarhex")))
    455 
    456 (define-operand (name rc1) (comment "rc1") (attrs) 
    457   (type h-uint) (index f-rc1) (handlers (parse "rc") (print "dollarhex")))
    458 
    459 (define-operand (name rc2) (comment "rc2") (attrs) 
    460   (type h-uint) (index f-rc2) (handlers (parse "rc") (print "dollarhex")))
    461 
    462 (define-operand (name cbrb) (comment "data-bus orientation") (attrs) 
    463   (type h-uint) (index f-cbrb) (handlers (parse "cbrb") (print "dollarhex")))
    464 
    465 (define-operand (name cell) (comment "cell") (attrs) 
    466   (type h-uint) (index f-cell) (handlers (print "dollarhex")))
    467 
    468 (define-operand (name dup) (comment "dup") (attrs) 
    469   (type h-uint) (index f-dup) (handlers (parse "dup") (print "dollarhex")))
    470 
    471 (define-operand (name ctxdisp) (comment "context displacement") (attrs) 
    472   (type h-uint) (index f-ctxdisp) (handlers (print "dollarhex")))
    473 
    474 (define-operand (name fbdisp) (comment "frame buffer displacement") (attrs) 
    475   (type h-uint) (index f-fbdisp) (handlers (print "dollarhex")))
    476 
    477 (define-operand (name type) (comment "type") (attrs) 
    478   (type h-uint) (index f-type) (handlers (parse "type") (print "dollarhex")))
    479 
    480 (define-operand (name mask) (comment "mask") (attrs) 
    481   (type h-uint) (index f-mask) (handlers (print "dollarhex")))
    482 
    483 (define-operand (name bankaddr) (comment "bank address") (attrs) 
    484   (type h-uint) (index f-bankaddr) (handlers (print "dollarhex")))
    485 
    486 (define-operand (name incamt) (comment "increment amount") (attrs) 
    487   (type h-uint) (index f-incamt) (handlers (print "dollarhex")))
    488 
    489 (define-operand (name xmode) (comment "xmode") (attrs) 
    490   (type h-uint) (index f-xmode) (handlers (parse "xmode") (print "dollarhex")))
    491 
    492 (define-operand (name mask1) (comment "mask1") (attrs) 
    493   (type h-uint) (index f-mask1) (handlers (print "dollarhex")))
    494 
    495 (define-operand (name ball) (comment "b_all") (attrs) 
    496   (type h-uint) (index f-ball) (handlers (parse "ball") (print "dollarhex")))
    497 
    498 (define-operand (name brc) (comment "b_r_c") (attrs) 
    499   (type h-uint) (index f-brc) (handlers (print "dollarhex")))
    500 
    501 (define-operand (name rda) (comment "rd") (attrs) 
    502   (type h-uint) (index f-rda) (handlers (print "dollarhex")))
    503 
    504 (define-operand (name wr) (comment "wr") (attrs) 
    505   (type h-uint) (index f-wr) (handlers (print "dollarhex")))
    506 
    507 (define-operand (name ball2) (comment "b_all2") (attrs)
    508   (type h-uint) (index f-ball2) (handlers (parse "ball") (print "dollarhex")))
    509 
    510 (define-operand (name brc2) (comment "b_r_c2") (attrs)
    511   (type h-uint) (index f-brc2) (handlers (print "dollarhex")))
    512 (define-operand (name perm) (comment "perm") (attrs)
    513   (type h-uint) (index f-perm) (handlers (print "dollarhex")))
    514 (define-operand (name a23)   (comment "a23") (attrs)
    515   (type h-uint) (index f-a23) (handlers (print "dollarhex")))
    516 (define-operand (name cr)   (comment "c-r") (attrs)
    517   (type h-uint) (index f-cr) (handlers (print "dollarhex")))
    518 (define-operand (name cbs)	(comment "cbs") (attrs)
    519   (type h-uint) (index f-cbs) (handlers (print "dollarhex")))
    520 (define-operand (name incr)	(comment "incr") (attrs)
    521   (type h-uint) (index f-incr) (handlers (print "dollarhex")))
    522 (define-operand (name length)	(comment "length") (attrs)
    523   (type h-uint) (index f-length) (handlers (print "dollarhex")))
    524 (define-operand (name cbx)	(comment "cbx") (attrs)
    525   (type h-uint) (index f-cbx) (handlers (print "dollarhex")))
    526 (define-operand (name ccb)	(comment "ccb") (attrs)
    527   (type h-uint) (index f-ccb) (handlers (print "dollarhex")))
    528 (define-operand (name cdb)	(comment "cdb") (attrs)
    529   (type h-uint) (index f-cdb) (handlers (print "dollarhex")))
    530 
    531 ; For the INTLVR insn
    532 (define-operand (name mode) (comment "mode") (attrs)
    533   (type h-uint) (index f-mode) (handlers (print "dollarhex")))
    534 (define-operand (name id) (comment "i/d") (attrs)
    535   (type h-uint) (index f-id) (handlers (print "dollarhex")))
    536 (define-operand (name size) (comment "size") (attrs)
    537   (type h-uint) (index f-size) (handlers (print "dollarhex")))
    538 
    539 (define-operand (name fbincr)	(comment "fb incr") (attrs)
    540   (type h-uint) (index f-fbincr) (handlers (print "dollarhex")))
    541 
    542 ; For the ms2 insns
    543 (define-operand (name loopsize) (comment "immediate value")
    544   (attrs (MACH ms2) PCREL-ADDR)
    545   (type h-uint) (index f-loopo) (handlers (parse "loopsize") (print "pcrel")))
    546 (define-operand (name imm16l) (comment "immediate value")
    547   (attrs (MACH ms2))
    548   (type h-uint) (index f-imm16l) (handlers (print "dollarhex")))
    549 (define-operand (name rc3) (comment "rc3") (attrs (MACH ms2))
    550   (type h-uint) (index f-rc3) (handlers (parse "rc") (print "dollarhex")))
    551 (define-operand (name cb1sel) (comment "cb1sel") (attrs (MACH ms2))
    552   (type h-uint) (index f-cb1sel) (handlers (print "dollarhex")))
    553 (define-operand (name cb2sel) (comment "cb2sel") (attrs (MACH ms2))
    554   (type h-uint) (index f-cb2sel) (handlers (print "dollarhex")))
    555 (define-operand (name cb1incr) (comment "cb1incr") (attrs (MACH ms2))
    556   (type h-sint) (index f-cb1incr) (handlers (print "dollarhex")))
    557 (define-operand (name cb2incr) (comment "cb2incr") (attrs (MACH ms2))
    558   (type h-sint) (index f-cb2incr) (handlers (print "dollarhex")))
    559 
    560 ; Probaby won't need most of these.
    561 (define-pmacro r0    (reg h-spr #x0))
    562 (define-pmacro r1    (reg h-spr #x01))
    563 (define-pmacro r2    (reg h-spr #x02))
    564 (define-pmacro r3    (reg h-spr #x03))
    565 (define-pmacro r4    (reg h-spr #x04))
    566 (define-pmacro r5    (reg h-spr #x05))
    567 (define-pmacro r6    (reg h-spr #x06))
    568 (define-pmacro r7    (reg h-spr #x07))
    569 (define-pmacro r8    (reg h-spr #x08))
    570 (define-pmacro r9    (reg h-spr #x09))
    571 (define-pmacro r10   (reg h-spr #xA))
    572 (define-pmacro r11   (reg h-spr #xB))
    573 (define-pmacro r12   (reg h-spr #xC))
    574 (define-pmacro fp    (reg h-spr #xC))
    575 (define-pmacro r13   (reg h-spr #xD))
    576 (define-pmacro sp    (reg h-spr #xD))
    577 (define-pmacro r14   (reg h-spr #xE))
    578 (define-pmacro ra    (reg h-spr #xE))
    579 (define-pmacro r15   (reg h-spr #xF))
    580 (define-pmacro ira   (reg h-spr #xF))
    581 
    582 ; delayed set
    583 (define-pmacro (dset dest src) (set (delay 1 dest) src))
    584 
    585 
    586 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    587 ;; Instructions As Defined In the MorphoRisc ISA Document ;;
    588 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    589 
    590 ; Arithmetic Instructions
    591 
    592 (dni add "ADD DstReg, SrcReg1, SrcReg2"
    593      (AL-INSN USES-FRDRRR USES-FRSR1 USES-FRSR2)
    594      "add $frdrrr,$frsr1,$frsr2"
    595      (+ MSYS_NO OPC_ADD IMM_NO frsr1 frsr2 frdrrr (f-uu12 0))
    596      (set frdrrr (add SI frsr1 frsr2))
    597      ()
    598 )
    599 
    600 (dni addu "ADDU DstReg, SrcReg1, SrcReg2"
    601      (AL-INSN USES-FRDRRR USES-FRSR1 USES-FRSR2)
    602      "addu $frdrrr,$frsr1,$frsr2"
    603      (+ MSYS_NO OPC_ADDU IMM_NO frsr1 frsr2 frdrrr (f-uu12 0))
    604      (set frdrrr (add USI frsr1 frsr2))
    605      ()
    606 )
    607 
    608 (dni addi "ADDI DstReg, SrcReg1 UnsImm"
    609      (AL-INSN USES-FRDR USES-FRSR1)
    610      "addi $frdr,$frsr1,#$imm16"
    611      (+ MSYS_NO OPC_ADD IMM_YES frsr1 frdr imm16)
    612      (sequence((HI tmp))
    613         (set HI tmp (and imm16 #xffff))
    614 	(set frdr (add SI frsr1 (ext SI tmp)))
    615      )
    616      ()
    617 )
    618 
    619 (dni addui "ADDUI DstReg, SrcReg1, UnsImm"
    620      (AL-INSN USES-FRDR USES-FRSR1)
    621      "addui $frdr,$frsr1,#$imm16z"
    622      (+ MSYS_NO OPC_ADDU IMM_YES frsr1 frdr imm16z)
    623      (set frdr (add USI frsr1 (ext USI imm16z)))
    624      ()
    625 )
    626 
    627 (dni sub "SUB DstReg, SrcReg1, SrcReg2"
    628      (AL-INSN USES-FRDRRR USES-FRSR1 USES-FRSR2)
    629      "sub $frdrrr,$frsr1,$frsr2"
    630      (+ MSYS_NO OPC_SUB IMM_NO frsr1 frsr2 frdrrr (f-uu12 0))
    631      (set frdrrr (sub SI frsr1 frsr2))
    632      ()
    633 )
    634 
    635 (dni subu "SUBU DstReg, SrcReg1, SrcReg2"
    636      (AL-INSN USES-FRDRRR USES-FRSR1 USES-FRSR2)
    637      "subu $frdrrr,$frsr1,$frsr2"
    638      (+ MSYS_NO OPC_SUBU IMM_NO frsr1 frsr2 frdrrr (f-uu12 0))
    639      (set frdrrr (sub USI frsr1 frsr2))
    640      ()
    641 )
    642 
    643 (dni subi "SUBI DstReg, SrcReg1, UnsImm"
    644      (AL-INSN USES-FRDR USES-FRSR1)
    645      "subi $frdr,$frsr1,#$imm16"
    646      (+ MSYS_NO OPC_SUB IMM_YES frsr1 frdr imm16)
    647      (sequence((HI tmp))
    648         (set HI tmp (and imm16 #xffff))
    649 	(set frdr (sub SI frsr1 (ext SI tmp)))
    650      )
    651      ;(set frdr (sub SI frsr1 (ext SI imm16)))
    652      ()
    653 )
    654 
    655 (dni subui "SUBUI DstReg, SrcReg1, UnsImm"
    656      (AL-INSN USES-FRDR USES-FRSR1)
    657      "subui $frdr,$frsr1,#$imm16z"
    658      (+ MSYS_NO OPC_SUBU IMM_YES frsr1 frdr imm16z)
    659      (set frdr (sub USI frsr1 (ext USI imm16z)))
    660      ()
    661 )
    662 
    663 (dni mul "MUL DstReg, SrcReg1, SrcReg2"
    664      ((MACH ms1-003,ms2) AL-INSN USES-FRDRRR USES-FRSR1 USES-FRSR2)
    665      "mul $frdrrr,$frsr1,$frsr2"
    666      (+ MSYS_NO OPC_MUL IMM_NO frsr1 frsr2 frdrrr (f-uu12 0))
    667      (sequence((HI op1) (HI op2))
    668 	 (set op1 (and frsr1 #xffff))
    669          (if (or (lt op1 (const -32768)) (gt op1 (const 32767)))
    670             (error "operand out of range")
    671          )
    672 	 (set op2 (and frsr2 #xffff))
    673          (if (or (lt op2 (const -32768)) (gt op2 (const 32767)))
    674             (error "operand out of range")
    675          )
    676 	 (set frdrrr (mul SI (ext SI op1) (ext SI op2)))
    677      )
    678      ()
    679 )
    680 
    681 (dni muli "MULI DstReg, SrcReg1, UnsImm"
    682      ((MACH ms1-003,ms2) AL-INSN USES-FRDR USES-FRSR1)
    683      "muli $frdr,$frsr1,#$imm16"
    684      (+ MSYS_NO OPC_MUL IMM_YES frsr1 frdr imm16)
    685      (sequence((HI op1) (HI op2))
    686 	 (set op1 (and frsr1 #xffff))
    687          (if (or (lt op1 (const -32768)) (gt op1 (const 32767)))
    688             (error "operand out of range")
    689          )
    690          (set op2 (and imm16 #xffff))
    691          (if (eq op1 (const 0))
    692           (error "op1 is 0")
    693          )
    694          (if (eq op2 (const 0))
    695           (error "op2 is 0")
    696          )
    697 	 (set frdr (mul SI (ext SI op1) (ext SI op2)))
    698      )
    699      ()
    700 )
    701 
    702 ; Logical Instructions
    703 
    704 (dni and "AND DstReg, SrcReg1, SrcReg2"
    705      (AL-INSN USES-FRDRRR USES-FRSR1 USES-FRSR2)
    706      "and $frdrrr,$frsr1,$frsr2"
    707      (+ MSYS_NO OPC_AND IMM_NO frsr1 frsr2 frdrrr (f-uu12 0))
    708      (set frdrrr (and frsr1 frsr2))
    709      ()
    710 )
    711 
    712 (dni andi "ANDI DstReg, SrcReg1, UnsImm"
    713      (AL-INSN USES-FRDR USES-FRSR1)
    714      "andi $frdr,$frsr1,#$imm16z"
    715      (+ MSYS_NO OPC_AND IMM_YES frsr1 frdr imm16z)
    716      (set frdr (and frsr1 (ext USI imm16z)))
    717      ()
    718 )
    719 
    720 (dni or "OR DstReg, SrcReg1, SrcReg2"
    721      (AL-INSN USES-FRDRRR USES-FRSR1 USES-FRSR2)
    722      "or $frdrrr,$frsr1,$frsr2"
    723      (+ MSYS_NO OPC_OR IMM_NO frsr1 frsr2 frdrrr (f-uu12 0))
    724      (set frdrrr (or frsr1 frsr2))
    725      ()
    726 )
    727 
    728 (dni nop "nop"
    729      ()
    730      "nop"
    731      (+ MSYS_NO OPC_OR IMM_NO (f-uu24 0))
    732      (nop)
    733      ()
    734 )
    735 
    736 (dni ori "ORI DstReg, SrcReg1, UnsImm"
    737      (AL-INSN USES-FRDR USES-FRSR1)
    738      "ori $frdr,$frsr1,#$imm16z"
    739      (+ MSYS_NO OPC_OR IMM_YES frsr1 frdr imm16z)
    740      (set frdr (or frsr1 (ext USI imm16z)))
    741      ()
    742 )
    743 
    744 (dni xor "XOR DstReg, SrcReg1, SrcReg2"
    745      (AL-INSN USES-FRDRRR USES-FRSR1 USES-FRSR2)
    746      "xor $frdrrr,$frsr1,$frsr2"
    747      (+ MSYS_NO OPC_XOR IMM_NO frsr1 frsr2 frdrrr (f-uu12 0))
    748      (set frdrrr (xor frsr1 frsr2))
    749      ()
    750 )
    751 
    752 (dni xori "XORI DstReg, SrcReg1, UnsImm"
    753      (AL-INSN USES-FRDR USES-FRSR1)
    754      "xori $frdr,$frsr1,#$imm16z"
    755      (+ MSYS_NO OPC_XOR IMM_YES frsr1 frdr imm16z)
    756      (set frdr (xor frsr1 (ext USI imm16z)))
    757      ()
    758 )
    759 
    760 (dni nand "NAND DstReg, SrcReg1, SrcReg2"
    761      (AL-INSN USES-FRDRRR USES-FRSR1 USES-FRSR2)
    762      "nand $frdrrr,$frsr1,$frsr2"
    763      (+ MSYS_NO OPC_NAND IMM_NO frsr1 frsr2 frdrrr (f-uu12 0))
    764      (set frdrrr (inv (and frsr1 frsr2)))
    765      ()
    766 )
    767 
    768 (dni nandi "NANDI DstReg, SrcReg1, UnsImm"
    769      (AL-INSN USES-FRDR USES-FRSR1)
    770      "nandi $frdr,$frsr1,#$imm16z"
    771      (+ MSYS_NO OPC_NAND IMM_YES frsr1 frdr imm16z)
    772      (set frdr (inv (and frsr1 (ext USI imm16z))))
    773      ()
    774 )
    775 
    776 (dni nor "NOR DstReg, SrcReg1, SrcReg2"
    777      (AL-INSN USES-FRDRRR USES-FRSR1 USES-FRSR2)
    778      "nor $frdrrr,$frsr1,$frsr2"
    779      (+ MSYS_NO OPC_NOR IMM_NO frsr1 frsr2 frdrrr (f-uu12 0))
    780      (set frdrrr (inv (or frsr1 frsr2)))
    781      ()
    782 )
    783 
    784 (dni nori "NORI DstReg, SrcReg1, UnsImm"
    785      (AL-INSN USES-FRDR USES-FRSR1)
    786      "nori $frdr,$frsr1,#$imm16z"
    787      (+ MSYS_NO OPC_NOR IMM_YES frsr1 frdr imm16z)
    788      (set frdr (inv (or frsr1 (ext USI imm16z))))
    789      ()
    790 )
    791 
    792 (dni xnor "XNOR DstReg, SrcReg1, SrcReg2"
    793      (AL-INSN USES-FRDRRR USES-FRSR1 USES-FRSR2)
    794      "xnor $frdrrr,$frsr1,$frsr2"
    795      (+ MSYS_NO OPC_XNOR IMM_NO frsr1 frsr2 frdrrr (f-uu12 0))
    796      (set frdrrr (inv (xor frsr1 frsr2)))
    797      ()
    798 )
    799 
    800 (dni xnori "XNORI DstReg, SrcReg1, UnsImm"
    801      (AL-INSN USES-FRDR USES-FRSR1)
    802      "xnori $frdr,$frsr1,#$imm16z"
    803      (+ MSYS_NO OPC_XNOR IMM_YES frsr1 frdr imm16z)
    804      (set frdr (inv (xor frsr1 (ext USI imm16z))))
    805      ()
    806 )
    807 
    808 (dni ldui "LDUI DstReg, UnsImm"
    809      (AL-INSN USES-FRDR)
    810      "ldui $frdr,#$imm16z"
    811      (+ MSYS_NO OPC_LDUI IMM_YES (f-uu4b 0) frdr imm16z)
    812      (set frdr (and (sll imm16z 16) #xffff0000))
    813      ()
    814 )
    815 
    816 ; Shift Instructions
    817 
    818 (dni lsl "LSL DstReg, SrcReg1, SrcReg2"
    819      (USES-FRDRRR USES-FRSR1 USES-FRSR2)
    820      "lsl $frdrrr,$frsr1,$frsr2"
    821      (+ MSYS_NO OPC_LSL IMM_NO frsr1 frsr2 frdrrr (f-uu12 0))
    822      (set frdrrr (sll frsr1 frsr2))
    823      ()
    824 )
    825 
    826 (dni lsli "LSLI DstReg, SrcReg1, UnsImm"
    827      (USES-FRDR USES-FRSR1)
    828      "lsli $frdr,$frsr1,#$imm16"
    829      (+ MSYS_NO OPC_LSL IMM_YES frsr1 frdr imm16)
    830      (set frdr (sll frsr1 imm16))
    831      ()
    832 )
    833 
    834 (dni lsr "LSR DstReg, SrcReg1, SrcReg2"
    835      (USES-FRDRRR USES-FRSR1 USES-FRSR2)
    836      "lsr $frdrrr,$frsr1,$frsr2"
    837      (+ MSYS_NO OPC_LSR IMM_NO frsr1 frsr2 frdrrr (f-uu12 0))
    838      (set frdrrr (srl frsr1 frsr2))
    839      ()
    840 )
    841 
    842 (dni lsri "LSRI DstReg, SrcReg1, UnsImm"
    843      (USES-FRDR USES-FRSR1)
    844      "lsri $frdr,$frsr1,#$imm16"
    845      (+ MSYS_NO OPC_LSR IMM_YES frsr1 frdr imm16)
    846      (set frdr (srl frsr1 imm16))
    847      ()
    848 )
    849 
    850 (dni asr "ASR DstReg, SrcReg1, SrcReg2"
    851      (USES-FRDRRR USES-FRSR1 USES-FRSR2)
    852      "asr $frdrrr,$frsr1,$frsr2"
    853      (+ MSYS_NO OPC_ASR IMM_NO frsr1 frsr2 frdrrr (f-uu12 0))
    854      (set frdrrr (sra frsr1 frsr2))
    855      ()
    856 )
    857 
    858 (dni asri "ASRI DstReg, SrcReg1, UnsImm"
    859      (USES-FRDR USES-FRSR1)
    860      "asri $frdr,$frsr1,#$imm16"
    861      (+ MSYS_NO OPC_ASR IMM_YES frsr1 frdr imm16)
    862      (set frdr (sra frsr1 imm16))
    863      ()
    864 )
    865 
    866 ; Control Transfer Instructions
    867 
    868 (dni brlt "BRLT SrcReg1, SrcReg2, label"
    869      (BR-INSN DELAY-SLOT USES-FRDRRR USES-FRSR1 USES-FRSR2)
    870      "brlt $frsr1,$frsr2,$imm16o"
    871      (+ MSYS_NO OPC_BRLT IMM_YES frsr1 frsr2 imm16o)
    872      (sequence()
    873         (if (lt USI frsr1 frsr2)
    874             (dset pc (add pc (ext SI imm16o))))
    875      )
    876      ()
    877 )
    878 
    879 (dni brle "BRLE SrcReg1, SrcReg2, label"
    880      (BR-INSN DELAY-SLOT USES-FRSR1 USES-FRSR2)
    881      "brle $frsr1,$frsr2,$imm16o"
    882      (+ MSYS_NO OPC_BRLE IMM_YES frsr1 frsr2 imm16o)
    883      (sequence()
    884         (if (le USI frsr1 frsr2)
    885             (dset pc (add pc (ext SI imm16o))))
    886      )
    887      ()
    888 )
    889 
    890 (dni breq "BREQ SrcReg1, SrcReg2, label"
    891      (BR-INSN DELAY-SLOT USES-FRSR1 USES-FRSR2)
    892      "breq $frsr1,$frsr2,$imm16o"
    893      (+ MSYS_NO OPC_BREQ IMM_YES frsr1 frsr2 imm16o)
    894      (sequence()
    895         (if (eq USI frsr1 frsr2)
    896             (dset pc (add pc (ext SI imm16o))))
    897      )
    898      ()
    899 )
    900 
    901 (dni brne "BRNE SrcReg1, SrcReg2, label"
    902      (BR-INSN DELAY-SLOT USES-FRSR1 USES-FRSR2)
    903      "brne $frsr1,$frsr2,$imm16o"
    904      (+ MSYS_NO OPC_BRNEQ IMM_YES frsr1 frsr2 imm16o)
    905      (sequence()
    906         (if (not (eq USI frsr1 frsr2))
    907             (dset pc (add pc (ext SI imm16o))))
    908      )
    909      ()
    910 )
    911 
    912 (dni jmp "JMP, label"
    913      (DELAY-SLOT BR-INSN)
    914      "jmp $imm16o"
    915      (+ MSYS_NO OPC_JMP IMM_YES (f-uu4b 0) (f-uu4a 0) imm16o)
    916      (dset pc (add pc (ext SI imm16o)))
    917      ()
    918 )
    919 
    920 (dni jal "JAL DstReg, SrcReg1"
    921      (BR-INSN DELAY-SLOT BR-INSN USES-FRDR USES-FRSR1 JAL-HAZARD)
    922      "jal $frdrrr,$frsr1"
    923      (+ MSYS_NO OPC_JAL IMM_NO frsr1 (f-uu4a 0) frdrrr (f-uu12 0))
    924      (sequence()
    925          (if (eq frsr1 #x0)
    926 	    (c-call VOID "do_syscall" pc)
    927 	    (sequence()   ; else part.  Do non-syscall stuff here.
    928 		(dset frdrrr (add pc #x8))
    929 		(dset pc frsr1)
    930             ) 
    931          )
    932      )
    933      ()
    934 )
    935 
    936 (dni dbnz "DBNZ SrcReg1, label"
    937      ((MACH ms1-003,ms2) BR-INSN DELAY-SLOT USES-FRSR1)
    938      "dbnz $frsr1,$imm16o"
    939      (+ MSYS_NO OPC_DBNZ IMM_YES frsr1 (f-uu4a 0) imm16o)
    940      (sequence()
    941 	 (if (not (eq USI frsr1 0))
    942             (dset pc (add pc (ext SI imm16o))))
    943      )
    944      ()
    945 )
    946 
    947 ; Interrupt Control Instructions
    948 
    949 (dni ei "EI - Enable Interrupt Processing"
    950      ()
    951      "ei"
    952      (+ MSYS_NO OPC_EI IMM_NO (f-uu4b 0) (f-uu4a 0) (f-uu16 0))
    953      (c-call VOID "enable_interrupts")
    954      ()
    955 )
    956 
    957 (dni di "DI - Disable Interrupt Processing"
    958      ()
    959      "di"
    960      (+ MSYS_NO OPC_DI IMM_NO (f-uu4b 0) (f-uu4a 0) (f-uu16 0))
    961      (c-call VOID "disable_interrupts")
    962      ()
    963 )
    964 
    965 (dni si "SI - Send software Interrupt"
    966      (DELAY-SLOT BR-INSN USES-FRDR)
    967      "si $frdrrr"
    968      (+ MSYS_NO OPC_SI IMM_NO (f-uu4b 0) (f-uu4a 0) frdrrr (f-uu12 0))
    969      ;(sequence() 
    970      ;   (dset frdr (add pc #x4))
    971      ;   (c-call VOID "do_syscall1" pc)
    972      ;   ; (dset pc frsr1) Do this later when we have the address.
    973      ;)
    974      (sequence() 
    975         (set frdrrr (add pc #x4))
    976         (c-call VOID "do_syscall" pc)
    977         ; (set pc frsr1) Do this later when we have the address.
    978      )
    979      ()
    980 )
    981 
    982 (dni reti "RETI SrcReg1"
    983      (DELAY-SLOT BR-INSN USES-FRSR1 JAL-HAZARD)
    984      "reti $frsr1"
    985      (+ MSYS_NO OPC_RETI IMM_NO frsr1 (f-uu4a 0) (f-uu16 0))
    986      (sequence()
    987        (c-call VOID "enable_interrupts")
    988        (dset pc frsr1)
    989      )
    990      ()
    991 )
    992 
    993 ; Memory Access Instructions
    994 
    995 (dni ldw "LDW DstReg, SrcReg1, Imm"
    996      (LOAD-DELAY MEMORY-ACCESS USES-FRDR USES-FRSR1)
    997      "ldw $frdr,$frsr1,#$imm16"
    998      (+ MSYS_NO OPC_LDW IMM_YES frsr1 frdr imm16)
    999      (sequence((USI ea) (HI tmp))
   1000       (set HI tmp (and imm16 #xffff))
   1001       (set ea (and (add SI frsr1 (ext SI tmp)) #xfffffffc))
   1002       (set frdr (mem SI ea))
   1003      )
   1004      ()
   1005 )
   1006 
   1007 (dni stw "STW SrcReg2, SrcReg1, Imm"
   1008      (MEMORY-ACCESS USES-FRSR1 USES-FRSR2)
   1009      "stw $frsr2,$frsr1,#$imm16"
   1010      (+ MSYS_NO OPC_STW IMM_YES frsr1 frsr2 imm16)
   1011      (sequence((USI ea) (HI tmp))
   1012       (set HI tmp (and imm16 #xffff))
   1013       (set ea (and (add SI frsr1 (ext SI tmp)) #xfffffffc))
   1014       (set (mem SI ea) frsr2)
   1015      )
   1016      ()
   1017 )
   1018 
   1019 ; Break Instruction
   1020 
   1021 (dni break "BREAK"
   1022      ()
   1023      "break"
   1024      (+ MSYS_NO OPC_BREAK (f-imm 0) (f-uu24 0))
   1025      (c-call VOID "do_break" pc)
   1026      ()
   1027 )
   1028 
   1029 ; Cache Flush Instruction
   1030 
   1031 (dni iflush "IFLUSH"
   1032      ((MACH ms1-003,ms2))
   1033      "iflush"
   1034      (+ MSYS_NO OPC_IFLUSH (f-imm 0) (f-uu24 0))
   1035      (nop)
   1036      ()
   1037 )
   1038 
   1039 ; MorphoSys Instructions
   1040 
   1041 (dni ldctxt "LDCTXT SRC1, SRC2, r/c, r/c#, context#"
   1042      ((MACH ms1))
   1043      "ldctxt $frsr1,$frsr2,#$rc,#$rcnum,#$contnum"
   1044      (+ MSYS_YES MSOPC_LDCTXT (f-uu-2-25 0) frsr1 frsr2 rc rcnum (f-uu-3-11 0)
   1045 	contnum )
   1046      (nop)
   1047      ()
   1048 )
   1049 
   1050 (dni ldfb "LDFB SRC1, byte#"
   1051      ((MACH ms1))
   1052      "ldfb $frsr1,$frsr2,#$imm16z"
   1053      (+ MSYS_YES MSOPC_LDFB (f-uu-2-25 0) frsr1 frsr2 imm16z)
   1054      (nop)
   1055      ()
   1056 )
   1057 
   1058 (dni stfb "STFB SRC1, SRC2, byte "
   1059      ((MACH ms1))
   1060      "stfb $frsr1,$frsr2,#$imm16z"
   1061      (+ MSYS_YES MSOPC_STFB (f-uu-2-25 0) frsr1 frsr2 imm16z)
   1062      (nop)
   1063      ()
   1064 )
   1065 
   1066 (dni fbcb "FBCB SRC1, RT/BR1/BR2/CS, B_all, B_r_c, r/c, CB/RB, cell, dup, ctx_disp"
   1067      ((MACH ms1,ms1-003))
   1068      "fbcb $frsr1,#$rbbc,#$ball,#$brc,#$rc1,#$cbrb,#$cell,#$dup,#$ctxdisp"
   1069      (+ MSYS_YES MSOPC_FBCB rbbc frsr1 ball brc (f-uu-4-15 0) rc cbrb cell dup ctxdisp)
   1070      (nop)
   1071      ()
   1072 )
   1073 
   1074 (dni mfbcb "MFBCB SRC1, RT/BR1/BR2/CS, SRC2, r/c, CB/RB, cell, dup, ctx_disp"
   1075      ()
   1076      "mfbcb $frsr1,#$rbbc,$frsr2,#$rc1,#$cbrb,#$cell,#$dup,#$ctxdisp"
   1077      (+ MSYS_YES MSOPC_MFBCB rbbc frsr1 frsr2 (f-uu-4-15 0) rc1 cbrb cell dup ctxdisp)
   1078      (nop)
   1079      ()
   1080 )
   1081 
   1082 (dni fbcci "FBCCI SRC1, RT/BR1/BR2/CS, B_all, B_r_c, FB_disp, cell, dup, ctx_disp"
   1083      ()
   1084      "fbcci $frsr1,#$rbbc,#$ball,#$brc,#$fbdisp,#$cell,#$dup,#$ctxdisp"
   1085      (+ MSYS_YES MSOPC_FBCCI rbbc frsr1 ball brc fbdisp cell dup ctxdisp)
   1086      (nop)
   1087      ()
   1088 )
   1089 
   1090 (dni fbrci "FBRCI SRC1, RT/BR1/BR2/CS, B_all, B_r_c, FB_disp, cell, dup, ctx_disp"
   1091      ()
   1092      "fbrci $frsr1,#$rbbc,#$ball,#$brc,#$fbdisp,#$cell,#$dup,#$ctxdisp"
   1093      (+ MSYS_YES MSOPC_FBRCI rbbc frsr1 ball brc fbdisp cell dup ctxdisp)
   1094      (nop)
   1095      ()
   1096 )
   1097 
   1098 (dni fbcri "FBCRI SRC1, RT/BR1/BR2/CS, B_all, B_r_c, FB_disp, cell, dup, ctx_disp"
   1099      ()
   1100      "fbcri $frsr1,#$rbbc,#$ball,#$brc,#$fbdisp,#$cell,#$dup,#$ctxdisp"
   1101      (+ MSYS_YES MSOPC_FBCRI rbbc frsr1 ball brc fbdisp cell dup ctxdisp)
   1102      (nop)
   1103      ()
   1104 )
   1105 
   1106 (dni fbrri "FBRRI SRC1, RT/BR1/BR2/CS, B_all, B_r_c, FB_disp, cell, dup, ctx_disp"
   1107      ()
   1108      "fbrri $frsr1,#$rbbc,#$ball,#$brc,#$fbdisp,#$cell,#$dup,#$ctxdisp"
   1109      (+ MSYS_YES MSOPC_FBRRI rbbc frsr1 ball brc fbdisp cell dup ctxdisp)
   1110      (nop)
   1111      ()
   1112 )
   1113 
   1114 (dni mfbcci "MFBCCI SRC1, RT/BR1/BR2/CS, SRC2, FB_disp, cell, dup, ctx_disp"
   1115      ()
   1116      "mfbcci $frsr1,#$rbbc,$frsr2,#$fbdisp,#$cell,#$dup,#$ctxdisp"
   1117      (+ MSYS_YES MSOPC_MFBCCI rbbc frsr1 frsr2 fbdisp cell dup ctxdisp)
   1118      (nop)
   1119      ()
   1120 )
   1121 
   1122 (dni mfbrci "MFBRCI SRC1, RT/BR1/BR2/CS, SRC2, FB_disp, cell, dup, ctx_disp"
   1123      ()
   1124      "mfbrci $frsr1,#$rbbc,$frsr2,#$fbdisp,#$cell,#$dup,#$ctxdisp"
   1125      (+ MSYS_YES MSOPC_MFBRCI rbbc frsr1 frsr2 fbdisp cell dup ctxdisp)
   1126      (nop)
   1127      ()
   1128 )
   1129 
   1130 (dni mfbcri "MFBCRI SRC1, RT/BR1/BR2/CS, SRC2, FB_disp, cell, dup, ctx_disp"
   1131      ()
   1132      "mfbcri $frsr1,#$rbbc,$frsr2,#$fbdisp,#$cell,#$dup,#$ctxdisp"
   1133      (+ MSYS_YES MSOPC_MFBCRI rbbc frsr1 frsr2 fbdisp cell dup ctxdisp)
   1134      (nop)
   1135      ()
   1136 )
   1137 
   1138 (dni mfbrri "MFBRRI SRC1, RT/BR1/BR2/CS, SRC2, FB_disp, cell, dup, ctx_disp"
   1139      ()
   1140      "mfbrri $frsr1,#$rbbc,$frsr2,#$fbdisp,#$cell,#$dup,#$ctxdisp"
   1141      (+ MSYS_YES MSOPC_MFBRRI rbbc frsr1 frsr2 fbdisp cell dup ctxdisp)
   1142      (nop)
   1143      ()
   1144 )
   1145 
   1146 (dni fbcbdr "FBCBDR SRC1, RT/BR1/BR2/CS, SRC2, B_all, B_r_c, r/c, CB/RB, cell, dup, ctx_disp"
   1147      ()
   1148      "fbcbdr $frsr1,#$rbbc,$frsr2,#$ball2,#$brc2,#$rc1,#$cbrb,#$cell,#$dup,#$ctxdisp"
   1149      (+ MSYS_YES MSOPC_FBCBDR rbbc frsr1 frsr2 ball2 brc2 rc1 cbrb cell dup ctxdisp)
   1150      (nop)
   1151      ()
   1152 )
   1153 
   1154 (dni rcfbcb "RCFBCB RT/BR1/BR2/CS, type, B_all, B_r_c, row#, r/c, CB/RB, cell, dup, ctx_disp"
   1155      ()
   1156      "rcfbcb #$rbbc,#$type,#$ball,#$brc,#$rownum,#$rc1,#$cbrb,#$cell,#$dup,#$ctxdisp"
   1157      (+ MSYS_YES MSOPC_RCFBCB rbbc (f-uu-2-23 0) type ball brc (f-uu-1-15 0) rownum rc1 cbrb cell dup ctxdisp)
   1158      (nop)
   1159      ()
   1160 )
   1161 
   1162 (dni mrcfbcb "MRCFBCB SRC2, RT/BR1/BR2/CS, type, row#, r/c, CB/RB, cell, dup, ctx_disp"
   1163      ()
   1164      "mrcfbcb $frsr2,#$rbbc,#$type,#$rownum,#$rc1,#$cbrb,#$cell,#$dup,#$ctxdisp"
   1165      (+ MSYS_YES MSOPC_MRCFBCB rbbc (f-uu-2-23 0) type frsr2 (f-uu-1-15 0) rownum rc1 cbrb cell dup ctxdisp)
   1166      (nop)
   1167      ()
   1168 )
   1169 
   1170 (dni cbcast "CBCAST mask, r/c, ctx_disp "
   1171      ()
   1172      "cbcast #$mask,#$rc2,#$ctxdisp"
   1173      (+ MSYS_YES MSOPC_CBCAST mask (f-uu-3-9 0) rc2 ctxdisp)
   1174      (nop)
   1175      ()
   1176 )
   1177 
   1178 (dni dupcbcast "DUPCBCAST mask, cell, r/c, ctx_disp "
   1179      ()
   1180      "dupcbcast #$mask,#$cell,#$rc2,#$ctxdisp"
   1181      (+ MSYS_YES MSOPC_DUPCBCAST mask cell rc2 ctxdisp)
   1182      (nop)
   1183      ()
   1184 )
   1185 
   1186 (dni wfbi "WFBI Bank_address, row#, cell, dup, ctx_disp "
   1187      ()
   1188     "wfbi #$bankaddr,#$rownum1,#$cell,#$dup,#$ctxdisp"
   1189      (+ MSYS_YES MSOPC_WFBI bankaddr rownum1 cell dup ctxdisp)
   1190      (nop)
   1191      ()
   1192 )
   1193 
   1194 ;(dni wfb "WFB SRC1, SRC2, FB_disp, row#, ctx_disp"
   1195 ;     ()
   1196 ;     "wfb $frsr1,$frsr2,#$fbdisp,#$rownum,#$ctxdisp"
   1197 ;     (+ MSYS_YES MSOPC_WFB (f-uu-2-25 0) frsr1 frsr2 fbdisp rownum (f-uu-1-6 0) ctxdisp)
   1198 ;     (nop)
   1199 ;     ()
   1200 ;)
   1201 
   1202 (dni wfb "WFB, DRC1,SRC2,FB_disp,row#,ctx_disp"
   1203       ()
   1204       "wfb $frsr1,$frsr2,#$fbdisp,#$rownum2,#$ctxdisp"
   1205       (+ MSYS_YES MSOPC_WFB (f-uu-2-25 0) frsr1 frsr2 fbdisp rownum2 (f-uu-1-6 0) ctxdisp)
   1206       (nop)
   1207       ()
   1208 )
   1209 
   1210 
   1211 (dni rcrisc "RCRISC DEST, RT/BR1/BR2/CS, SRC1, column#, r/c, CB/RB, cell, dup, ctx_disp"
   1212      ()
   1213      "rcrisc $frdrrr,#$rbbc,$frsr1,#$colnum,#$rc1,#$cbrb,#$cell,#$dup,#$ctxdisp"
   1214      (+ MSYS_YES MSOPC_RCRISC rbbc frsr1 (f-uu-1-19 0) colnum frdrrr rc1 cbrb cell dup ctxdisp)
   1215      (nop)
   1216      ()
   1217 )
   1218 
   1219 (dni fbcbinc "FBCBINC SRC1, RT/BR1/BR2/CS, Incr_amount, r/c, CB/RB, cell, dup, ctx_disp "
   1220      ()
   1221      "fbcbinc $frsr1,#$rbbc,#$incamt,#$rc1,#$cbrb,#$cell,#$dup,#$ctxdisp"
   1222      (+ MSYS_YES MSOPC_FBCBINC rbbc frsr1 incamt rc1 cbrb cell dup ctxdisp)
   1223      (nop)
   1224      ()
   1225 )
   1226 
   1227 (dni rcxmode "RCXMODE SRC2, rd, wr, xmode, mask, FB_disp, row#, r/c, ctx_disp"
   1228      ()
   1229      "rcxmode $frsr2,#$rda,#$wr,#$xmode,#$mask1,#$fbdisp,#$rownum2,#$rc2,#$ctxdisp"
   1230      (+ MSYS_YES MSOPC_RCXMODE rda wr xmode mask1 frsr2 fbdisp rownum2 rc2 ctxdisp)
   1231      (nop)
   1232      ()
   1233 )
   1234 
   1235 (dni interleaver "INTLVR ireg, mode, ireg, i/d, size"
   1236      ()
   1237      "intlvr $frsr1,#$mode,$frsr2,#$id,#$size"
   1238      (+ MSYS_YES MSOPC_INTLVR mode frsr1 frsr2 (f-uu-1-15 0) id size)
   1239      (nop)
   1240      ()
   1241 )
   1242 
   1243 ;; Issue 66262: The documenatation gives the wrong order for 
   1244 ;;               the arguments to the WFBINC instruction.
   1245 (dni wfbinc "WFBINC type, ccb/rcb, incr, all, c/r, length, rca_row, word, dup, ctxt_disp"
   1246      ((MACH ms1-003,ms2))
   1247      "wfbinc #$rda,#$wr,#$fbincr,#$ball,#$colnum,#$length,#$rownum1,#$rownum2,#$dup,#$ctxdisp"
   1248      (+ MSYS_YES MSOPC_WFBINC rda wr fbincr ball colnum length rownum1 rownum2 dup ctxdisp)
   1249      (nop)
   1250      ()
   1251 )
   1252 
   1253 (dni mwfbinc "MWFBINC mreg, type, ccb/rcb, incr, length, rca_row, word, dup, ctxt_disp"
   1254      ((MACH ms1-003,ms2))
   1255      "mwfbinc $frsr2,#$rda,#$wr,#$fbincr,#$length,#$rownum1,#$rownum2,#$dup,#$ctxdisp"
   1256      (+ MSYS_YES MSOPC_MWFBINC rda wr fbincr frsr2 length rownum1 rownum2 dup ctxdisp)
   1257      (nop)
   1258      ()
   1259 )
   1260 
   1261 (dni wfbincr "WFBINCR ireg, type, ccb/rcb, all, c/r, length, rca_row, word, dup, ctxt_disp"
   1262      ((MACH ms1-003,ms2))
   1263      "wfbincr $frsr1,#$rda,#$wr,#$ball,#$colnum,#$length,#$rownum1,#$rownum2,#$dup,#$ctxdisp"
   1264      (+ MSYS_YES MSOPC_WFBINCR rda wr frsr1 ball colnum length rownum1 rownum2 dup ctxdisp)
   1265      (nop)
   1266      ()
   1267 )
   1268 
   1269 (dni mwfbincr "MWFBINCR ireg, mreg, type, ccb/rcb, length, rca_row, word, dup, ctxt_disp"
   1270      ((MACH ms1-003,ms2))
   1271      "mwfbincr $frsr1,$frsr2,#$rda,#$wr,#$length,#$rownum1,#$rownum2,#$dup,#$ctxdisp"
   1272      (+ MSYS_YES MSOPC_MWFBINCR rda wr frsr1 frsr2 length rownum1 rownum2 dup ctxdisp)
   1273      (nop)
   1274      ()
   1275 )
   1276 
   1277 (dni fbcbincs "FBCBINCS	     perm, all, c/r, cbs, incr, ccb/rcb, cdb/rdb, word, dup, ctxt_disp"
   1278      ((MACH ms1-003,ms2))
   1279      "fbcbincs #$perm,#$a23,#$cr,#$cbs,#$incr,#$ccb,#$cdb,#$rownum2,#$dup,#$ctxdisp"
   1280      (+ MSYS_YES MSOPC_FBCBINCS perm a23 cr cbs incr ccb cdb rownum2 dup ctxdisp)
   1281      (nop)
   1282      ()
   1283 )
   1284 
   1285 (dni mfbcbincs "MFBCBINCS		ireg, perm, cbs, incr, ccb/rcb, cdb/rdb, word, dup, ctxt_disp"
   1286      ((MACH ms1-003,ms2))
   1287      "mfbcbincs $frsr1,#$perm,#$cbs,#$incr,#$ccb,#$cdb,#$rownum2,#$dup,#$ctxdisp"
   1288      (+ MSYS_YES MSOPC_MFBCBINCS perm frsr1 cbs incr ccb cdb rownum2 dup ctxdisp)
   1289      (nop)
   1290      ()
   1291 )
   1292 
   1293 (dni fbcbincrs "FBCBINCRS	     ireg, perm, all, c/r, cbs, ccb/rcb, cdb/rdb, word, dup, ctxt_disp"
   1294      ((MACH ms1-003,ms2))
   1295      "fbcbincrs $frsr1,#$perm,#$ball,#$colnum,#$cbx,#$ccb,#$cdb,#$rownum2,#$dup,#$ctxdisp"
   1296      (+ MSYS_YES MSOPC_FBCBINCRS perm frsr1 ball colnum (f-uu-1-15 0) cbx ccb cdb rownum2 dup ctxdisp)
   1297      (nop)
   1298      ()
   1299 )
   1300 
   1301 (dni mfbcbincrs "MFBCBINCRS ireg, mreg, perm, cbs, ccb/rcb, cdb/rdb, word, dup, ctxt_disp"
   1302      ((MACH ms1-003,ms2))
   1303      "mfbcbincrs $frsr1,$frsr2,#$perm,#$cbx,#$ccb,#$cdb,#$rownum2,#$dup,#$ctxdisp"
   1304      (+ MSYS_YES MSOPC_MFBCBINCRS perm frsr1 frsr2 (f-uu-1-15 0) cbx ccb cdb rownum2 dup ctxdisp)
   1305      (nop)
   1306      ()
   1307 )
   1308 
   1309 ; MS2 instructions
   1310 (dni loop "LOOP SrcReg1, label"
   1311      ((MACH ms2) DELAY-SLOT USES-FRSR1)
   1312      "loop $frsr1,$loopsize"
   1313      (+ MSYS_NO OPC_LOOP IMM_NO frsr1 (f-uu4a 0) (f-uu8 0) loopsize)
   1314      (nop)      ;; to be filled in
   1315      ()
   1316 )
   1317 
   1318 (dni loopi "LOOPI niter, label"
   1319      ((MACH ms2) DELAY-SLOT)
   1320      "loopi #$imm16l,$loopsize"
   1321      (+ MSYS_NO OPC_LOOP IMM_YES imm16l loopsize)
   1322      (nop)      ;; to be filled in
   1323      ()
   1324 )
   1325 
   1326 (dni dfbc "dfbc cb1sel,cb2sel,cb1inc,cb2inc,dr/c,cr/c,ctxdisp"
   1327      ((MACH ms2))
   1328      "dfbc #$cb1sel,#$cb2sel,#$cb1incr,#$cb2incr,#$rc3,#$rc2,#$ctxdisp"
   1329      (+ MSYS_YES MSOPC_LDCTXT cb1sel cb2sel cb1incr cb2incr rc3 rc2 ctxdisp)
   1330      (nop)
   1331      ()
   1332 )
   1333 
   1334 (dni dwfb "dwfb cb1sel,cb2sel,cb1inc,cb2inc,cr/c,ctxdisp"
   1335      ((MACH ms2))
   1336      "dwfb #$cb1sel,#$cb2sel,#$cb1incr,#$cb2incr,#$rc2,#$ctxdisp"
   1337      (+ MSYS_YES MSOPC_LDFB cb1sel cb2sel cb1incr cb2incr (f-uu1 0) rc2 ctxdisp)
   1338      (nop)
   1339      ()
   1340 )
   1341 
   1342 (dni fbwfb "fbwfb cb1sel,cb2sel,cb1inc,cb2inc,r0/1,cr/c,ctxdisp"
   1343      ((MACH ms2))
   1344      "fbwfb #$cb1sel,#$cb2sel,#$cb1incr,#$cb2incr,#$rc3,#$rc2,#$ctxdisp"
   1345      (+ MSYS_YES MSOPC_STFB cb1sel cb2sel cb1incr cb2incr rc3 rc2 ctxdisp)
   1346      (nop)
   1347      ()
   1348 )
   1349 
   1350 (dni dfbr "dfbr cb1sel,cb2sel,reg,W/O1,W/O2,mode,cr/c,ctxdisp"
   1351      ((MACH ms2) USES-FRSR2)
   1352      "dfbr #$cb1sel,#$cb2sel,$frsr2,#$length,#$rownum1,#$rownum2,#$rc2,#$ctxdisp"
   1353      (+ MSYS_YES MSOPC_FBCB cb1sel cb2sel frsr2 length rownum1 rownum2 rc2 ctxdisp)
   1354      (nop)
   1355      ()
   1356 )
   1357