mt.cpu 42 KB

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