OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [binutils-2.20.1/] [cpu/] [xc16x.cpu] - Blame information for rev 326

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 205 julius
; Infineon XC16X CPU description.  -*- Scheme -*-
2
;
3
; Copyright 2006, 2007, 2009 Free Software Foundation, Inc.
4
;
5
; Contributed by KPIT Cummins Infosystems Ltd.; developed under contract
6
; from Infineon Systems, GMBH , Germany.
7
;
8
; This file is part of the GNU Binutils.
9
;
10
; This program is free software; you can redistribute it and/or modify
11
; it under the terms of the GNU General Public License as published by
12
; the Free Software Foundation; either version 3 of the License, or
13
; (at your option) any later version.
14
;
15
; This program is distributed in the hope that it will be useful,
16
; but WITHOUT ANY WARRANTY; without even the implied warranty of
17
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
; GNU General Public License for more details.
19
;
20
; You should have received a copy of the GNU General Public License
21
; along with this program; if not, write to the Free Software
22
; Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
23
; 02110-1301, USA.
24
 
25
(include "simplify.inc")
26
 
27
; define-arch appears first
28
 
29
(define-arch
30
  (name xc16x) ; name of cpu family
31
  (comment "Infineon XC16X")
32
  (default-alignment aligned)
33
  (insn-lsb0? #t)
34
  (machs xc16x)
35
  (isas xc16x)
36
)
37
 
38
; Attributes.
39
; An attribute to describe which pipeline an insn runs in generally OS.
40
(define-attr
41
  (for insn)
42
  (type enum)
43
  (name PIPE)
44
  (comment "parallel execution pipeline selection")
45
  (values NONE OS)
46
)
47
 
48
; Instruction set parameters.
49
 
50
(define-isa
51
  (name xc16x)
52
  (default-insn-bitsize 32)
53
  (base-insn-bitsize 32)
54
  (default-insn-word-bitsize 16)
55
  (decode-assist (15 14 13 12))
56
  ; The XC16X fetches 1 insn at a time.
57
  (liw-insns 1)
58
  (parallel-insns 1)
59
)
60
 
61
; Cpu family definitions.
62
 
63
(define-cpu
64
  ; cpu names must be distinct from the architecture name and machine names.
65
  ; The "b" suffix stands for "base" and is the convention.
66
  ; The "f" suffix stands for "family" and is the convention.
67
  (name xc16xbf)
68
  (comment "Infineon XC16X base family")
69
  (endian little)
70
  (insn-chunk-bitsize 32)
71
  (word-bitsize 16)
72
  (parallel-insns 1)
73
)
74
 
75
(define-mach
76
  (name xc16x)
77
  (comment "Infineon XC16X cpu")
78
  (cpu xc16xbf)
79
)
80
 
81
; Model descriptions.
82
 
83
(define-model
84
  (name xc16x) (comment "XC16X") (attrs)
85
  (mach xc16x)
86
 
87
  (pipeline p-mem "" () ((prefetch) (fetch) (decode) (address) (memory) (execute) (writeback)))
88
 
89
    ; `state' is a list of variables for recording model state
90
    (state
91
     ; bit mask of h-gr registers, =1 means value being loaded from memory
92
     (h-gr UINT)
93
    )
94
 
95
  (unit u-exec "Execution Unit" ()
96
        1 1 ; issue done
97
        () ; state
98
        ((dr INT -1) (sr INT -1)) ; inputs
99
        ((dr INT -1)) ; outputs
100
        () ; profile action (default)
101
        )
102
  (unit u-cmp "Compare Unit" ()
103
        1 1 ; issue done
104
        () ; state
105
        ((src1 INT -1) (src2 INT -1)) ; inputs
106
        () ; outputs
107
        () ; profile action (default)
108
        )
109
  (unit u-cti "Jump & Call Unit" ()
110
        1 1 ; issue done
111
        () ; state
112
        ((condbit) (sr INT -1)) ; inputs
113
        ((pc)) ; outputs
114
        () ; profile action (default)
115
        )
116
  (unit u-mov "Data Movement Unit" ()
117
        1 1 ; issue done
118
        () ;state
119
        ((dr INT -1) (sr INT -1)) ; inputs
120
        ((dr INT -1)) ; output
121
        () ; profile action (default)
122
        )
123
 )
124
 
125
; Instruction fields.
126
;
127
; Attributes:
128
; PCREL-ADDR: pc relative value (for reloc and disassembly purposes)
129
; ABS-ADDR: absolute address (for reloc and disassembly purposes)
130
; RELOC: there is a relocation associated with this field (experiment)
131
 
132
(define-attr
133
  (for ifield operand)
134
  (type boolean)
135
  (name RELOC)
136
  (comment "there is a reloc associated with this field (experiment)")
137
)
138
 
139
(dnf f-op1       "op1"                 () 7  4)
140
(dnf f-op2       "op2"                 () 3  4)
141
(dnf f-condcode  "condcode"            () 7  4)  ;condition code required in other jmps and calls
142
(dnf f-icondcode "indrct condcode"     () 15 4)  ;condition code required in other jmpi and calli
143
(dnf f-rcond     "relative-cond"       () 7  4)  ;condition code required in JMPR
144
(dnf f-qcond     "qbit"                () 7  4)  ;used in enum of bset/bclear macro
145
(dnf f-extccode  "extended condcode"   () 15 5)  ;condition code required in other jmpa and calla
146
(dnf f-r0        "r0"                  () 9  2)  ;required where 2 bit register used(only R0-R3)
147
(dnf f-r1        "r1"                  () 15 4)
148
(dnf f-r2        "r2"                  () 11 4)
149
(dnf f-r3        "r3"                  () 12 4)
150
(dnf f-r4        "r4"                  () 11 4)
151
(dnf f-uimm2     "uimm2"               () 13 2)  ;used for immediate data,eg in ADD,MOV insns
152
(dnf f-uimm3     "uimm3"               () 10 3)  ;used for immediate data,eg in ADD,SUB insns
153
(dnf f-uimm4     "uimm4"               () 15 4)  ;used for immediate data,eg in MOV insns
154
(dnf f-uimm7     "uimm7"               (PCREL-ADDR RELOC) 15 7) ;used in TRAP
155
(dnf f-uimm8     "uimm8"               () 23 8)  ;used in immediate byte data,eg in ADDB,MOVB insns
156
(dnf f-uimm16    "uimm16"              () 31 16) ;used for immediate word data
157
(dnf f-memory    "memory"              () 31 16) ; used for memory operands
158
(dnf f-memgr8    "memory"              () 31 16) ; memory location of gr
159
(dnf f-rel8      "rel8"                (PCREL-ADDR RELOC) 15 8) ;used in JMPR,CALLR
160
(dnf f-relhi8    "relhi8"              (PCREL-ADDR RELOC) 23 8) ;used in JB,JBC,JNB,JNBS
161
(dnf f-reg8      "reg8"                () 15 8) ;required where 8bit gp register used
162
(dnf f-regmem8   "regmem8"             () 15 8) ;required where 8bit register used
163
(dnf f-regoff8   "regoff8"             () 15 8) ;required for offset calc
164
(dnf f-reghi8    "reghi8"              () 23 8) ;required where 8bit register number used
165
(dnf f-regb8     "regb8"               () 15 8) ;required for byte registers RL0,RH0, till RL8,RH8
166
(dnf f-seg8      "seg8"                () 15 8) ;used as segment number in JMPS,CALLS
167
(dnf f-segnum8   "segnum8"             () 23 8) ;used in EXTS,EXTSR
168
(dnf f-mask8     "mask8"               () 23 8) ;used as mask in BFLDH,BFLDL insns
169
(dnf f-pagenum   "page num"            () 25 10);used in EXTP,EXTPR
170
(dnf f-datahi8   "datahi8"             () 31 8) ;used for filling with const data
171
(dnf f-data8     "data8"               () 23 8) ;used for filling with const data
172
(dnf f-offset16  "address offset16"    (ABS-ADDR RELOC) 31 16) ;used in JMPS,JMPA,CALLA,CALLS
173
(dnf f-op-bit1   "gap of 1 bit"        () 11 1) ;used for filling with const data
174
(dnf f-op-bit2   "gap of 2 bits"       () 11 2) ;used for filling with const data
175
(dnf f-op-bit4   "gap of 4 bits"       () 11 4) ;used for filling with const data
176
(dnf f-op-bit3   "gap of 3 bits"       () 10 3) ;used in CALLA, JMPA
177
(dnf f-op-2bit   "gap of 2 bits"       () 10 2) ;used in CALLA
178
(dnf f-op-bitone "gap of 1 bit "       () 10 1) ;used in JMPA
179
(dnf f-op-onebit "gap of 1 bit "       () 9  1) ;used in JMPA
180
(dnf f-op-1bit   "gap of 1 bit "       () 8  1) ;used in JMPA, CALLA
181
(dnf f-op-lbit4  "gap of 4 bits"       () 15 4) ;used for filling with const data
182
(dnf f-op-lbit2  "gap of 2 bits"       () 15 2) ;used for filling with const data
183
(dnf f-op-bit8   "gap of 8 bits"       () 31 8) ;used for filling with const data
184
(dnf f-op-bit16  "gap of 16 bits"      () 31 16) ;used for filling with const data
185
(dnf f-qbit      "qbit"                () 7  4) ;used in bit field of bset/bclear
186
(dnf f-qlobit    "qlobit"              () 31 4) ;used for filling with const data
187
(dnf f-qhibit    "qhibit"              () 27 4) ;used for filling with const data
188
(dnf f-qlobit2   "qlobit2"             () 27 2) ;used for filling with const data
189
(dnf f-pof    "upof16"                 () 31 16) ; used for memory operands
190
 
191
; Enums.
192
; insn-op1: bits 0-3
193
(define-normal-insn-enum insn-op1 "insn format enums" () OP1_ f-op1
194
  ("0" "1" "2" "3" "4" "5" "6" "7"
195
   "8" "9" "10" "11" "12" "13" "14" "15")
196
)
197
 
198
; insn-op2: bits 4-7
199
(define-normal-insn-enum insn-op2 "op2 enums" () OP2_ f-op2
200
  ("0" "1" "2" "3" "4" "5" "6" "7"
201
   "8" "9" "10" "11" "12" "13" "14" "15")
202
)
203
 
204
;/*for bclr/bset*/
205
; insn-rcond: bits 0-3
206
(define-normal-insn-enum insn-qcond "bit set/clear enums" () QBIT_ f-qcond
207
  (("0" 0) ("1" 1) ("2" 2) ("3" 3) ("4" 4) ("5" 5) ("6" 6) ("7" 7) ("8" 8) ("9" 9) ("10" 10)
208
   ("11" 11) ("12" 12) ("13" 13) ("14" 14) ("15" 15))
209
)
210
;/************/
211
; insn-rcond: bits 0-3
212
(define-normal-insn-enum insn-rcond "relative jump condition code op2 enums" () COND_ f-rcond
213
  (("UC" 0) ("NET" 1) ("Z" 2) ("NE_NZ" 3) ("V" 4)  ("NV" 5) ("N" 6) ("NN" 7)
214
   ("C" 8) ("NC" 9) ("SGT" 10) ("SLE" 11) ("SLT" 12) ("SGE" 13) ("UGT" 14) ("ULE" 15)
215
   ("EQ" 2) ("NE" 3) ("ULT" 8) ("UGE" 9))
216
)
217
 
218
 
219
 
220
; Hardware pieces.
221
; These entries list the elements of the raw hardware.
222
; They're also used to provide tables and other elements of the assembly
223
; language.
224
 
225
(dnh h-pc "program counter" (PC) (pc) () () ())
226
 
227
(define-keyword
228
  (name gr-names)
229
  (print-name h-gr)
230
  (prefix "")
231
  (values (r0 0) (r1 1) (r2 2) (r3 3) (r4 4) (r5 5) (r6 6) (r7 7)
232
          (r8 8) (r9 9) (r10 10) (r11 11) (r12 12) (r13 13) (r14 14) (r15 15))
233
 
234
)
235
(define-hardware
236
  (name h-gr)
237
  (comment "general registers")
238
  (attrs PROFILE CACHE-ADDR)
239
  (type register HI (16))
240
  (indices extern-keyword gr-names)
241
)
242
 
243
(define-keyword
244
  (name ext-names)
245
  (print-name h-ext)
246
  (prefix "")
247
  (values (0x1 0) (0x2 1) (0x3 2) (0x4 3)
248
          ("1" 0) ("2" 1) ("3" 2) ("4" 3))
249
 
250
)
251
 
252
(define-hardware
253
  (name h-ext)
254
  (comment "ext values")
255
  (attrs PROFILE CACHE-ADDR)
256
  (type register HI (8))
257
  (indices extern-keyword ext-names)
258
)
259
 
260
(define-keyword
261
  (name psw-names)
262
  (print-name h-psw)
263
  (prefix "")
264
  (values ("IEN" 136) ("r0.11" 240) ("r1.11" 241) ("r2.11" 242) ("r3.11" 243) ("r4.11" 244)
265
                      ("r5.11" 245) ("r6.11" 246) ("r7.11" 247) ("r8.11" 248)
266
                      ("r9.11" 249) ("r10.11" 250) ("r11.11" 251) ("r12.11" 252)
267
                      ("r13.11" 253) ("r14.11" 254) ("r15.11" 255))
268
)
269
 
270
(define-hardware
271
  (name h-psw)
272
  (comment "ext values")
273
  (attrs PROFILE CACHE-ADDR)
274
  (type register HI (1))
275
  (indices extern-keyword psw-names)
276
)
277
 
278
(define-keyword
279
  (name grb-names)
280
  (print-name h-grb)
281
  (prefix "")
282
  (values (rl0 0) (rh0 1) (rl1 2) (rh1 3) (rl2 4) (rh2 5) (rl3 6) (rh3 7)
283
          (rl4 8) (rh4 9) (rl5 10) (rh5 11) (rl6 12) (rh6 13) (rl7 14) (rh7 15))
284
)
285
 
286
(define-hardware
287
  (name h-grb)
288
  (comment "general registers")
289
  (attrs PROFILE CACHE-ADDR)
290
  (type register QI (16))
291
  (indices extern-keyword grb-names)
292
)
293
 
294
(define-keyword
295
  (name conditioncode-names)
296
  (print-name h-cc)
297
  (prefix "")
298
  (values (cc_UC 0) (cc_NET 1) (cc_Z 2) (cc_EQ 2) (cc_NZ 3) (cc_NE 3) (cc_V 4) (cc_NV 5) (cc_N 6)  (cc_NN 7) (cc_ULT 8)  (cc_UGE 9)
299
          (cc_C 8) (cc_NC 9) (cc_SGT 10) (cc_SLE 11) (cc_SLT 12) (cc_SGE 13) (cc_UGT 14)
300
          (cc_ULE 15))
301
)
302
(define-hardware
303
  (name h-cc)
304
  (comment "condition codes")
305
  (attrs PROFILE CACHE-ADDR)
306
  (type register QI (16))
307
  (indices extern-keyword conditioncode-names)
308
)
309
 
310
(define-keyword
311
  (name extconditioncode-names)
312
  (print-name h-ecc)
313
  (prefix "")
314
  (values(cc_UC 0) (cc_NET 2) (cc_Z 4) (cc_EQ 4) (cc_NZ 6) (cc_NE 6) (cc_V 8) (cc_NV 10) (cc_N 12)  (cc_NN 14) (cc_ULT 16)  (cc_UGE 18) (cc_C 16) (cc_NC 18) (cc_SGT 20)
315
         (cc_SLE 22) (cc_SLT 24) (cc_SGE 26) (cc_UGT 28) (cc_ULE 30) (cc_nusr0 1)
316
         (cc_nusr1 3) (cc_usr0 5) (cc_usr1 7))
317
)
318
(define-hardware
319
  (name h-ecc)
320
  (comment "extended condition codes")
321
  (attrs PROFILE CACHE-ADDR)
322
  (type register QI (4))
323
  (indices extern-keyword extconditioncode-names)
324
)
325
 
326
(define-keyword
327
  (name grb8-names)
328
  (print-name h-grb8)
329
  (prefix "")
330
  (values (dpp0 0)  (dpp1 1)  (dpp2 2)  (dpp3 3)
331
          (psw 136)   (cp 8)    (mdl 7)   (mdh  6)
332
          (mdc 135)   (sp 9)    (csp 4)  (vecseg 137)
333
          (stkov 10)  (stkun 11) (cpucon1 12) (cpucon2 13)
334
          (zeros 142)  (ones 143) (spseg 134) (tfr 214)
335
          (rl0 240) (rh0 241) (rl1 242) (rh1 243) (rl2 244) (rh2 245) (rl3 246) (rh3 247)
336
          (rl4 248) (rh4 249) (rl5 250) (rh5 251) (rl6 252) (rh6 253) (rl7 254) (rh7 255))
337
)
338
 
339
(define-hardware
340
  (name h-grb8)
341
  (comment "general byte registers")
342
  (attrs PROFILE CACHE-ADDR)
343
  (type register QI (36))
344
  (indices extern-keyword grb8-names)
345
)
346
 
347
(define-keyword
348
  (name r8-names)
349
  (print-name h-r8)
350
  (prefix "")
351
  (values (dpp0 0)  (dpp1 1)  (dpp2 2)  (dpp3 3)
352
          (psw 136)   (cp 8)    (mdl 7)   (mdh  6)
353
          (mdc 135)   (sp 9)    (csp 4)  (vecseg 137)
354
          (stkov 10)  (stkun 11) (cpucon1 12) (cpucon2 13)
355
          (zeros 142)  (ones 143) (spseg 134) (tfr 214)
356
          (r0 240) (r1 241) (r2 242) (r3 243) (r4 244) (r5 245) (r6 246) (r7 247)
357
          (r8 248) (r9 249) (r10 250) (r11 251) (r12 252) (r13 253) (r14 254) (r15 255))
358
)
359
 
360
(define-hardware
361
  (name h-r8)
362
  (comment "registers")
363
  (attrs PROFILE CACHE-ADDR)
364
  (type register HI (36))
365
  (indices extern-keyword r8-names)
366
)
367
 
368
(define-keyword
369
  (name regmem8-names)
370
  (print-name h-regmem8)
371
  (prefix "")
372
  (values (dpp0 0)  (dpp1 1)  (dpp2 2)  (dpp3 3)
373
          (psw 136)   (cp 8)    (mdl 7)   (mdh  6)
374
          (mdc 135)   (sp 9)    (csp 4)  (vecseg 137)
375
          (stkov 10)  (stkun 11) (cpucon1 12) (cpucon2 13)
376
          (zeros 142)  (ones 143) (spseg 134) (tfr 214)
377
          (r0 240) (r1 241) (r2 242) (r3 243) (r4 244) (r5 245) (r6 246) (r7 247)
378
          (r8 248) (r9 249) (r10 250) (r11 251) (r12 252) (r13 253) (r14 254) (r15 255))
379
)
380
 
381
(define-hardware
382
  (name h-regmem8)
383
  (comment "registers")
384
  (attrs )
385
  (type register HI (16))
386
  (indices extern-keyword regmem8-names)
387
)
388
 
389
(define-keyword
390
  (name regdiv8-names)
391
  (print-name h-regdiv8)
392
  (prefix "")
393
  (values (r0 0) (r1 17) (r2 34) (r3 51) (r4 68) (r5 85) (r6 102) (r7 119)
394
          (r8 136) (r9 153) (r10 170) (r11 187) (r12 204) (r13 221) (r14 238) (r15 255))
395
)
396
 
397
(define-hardware
398
  (name h-regdiv8)
399
  (comment "division insn registers")
400
  (attrs PROFILE CACHE-ADDR)
401
  (type register HI (16))
402
  (indices extern-keyword regdiv8-names)
403
)
404
 
405
(define-keyword
406
  (name reg0-name)
407
  (print-name h-reg0)
408
  (prefix "")
409
  (values (0x1 1) (0x2 2) (0x3 3) (0x4 4) (0x5 5) (0x6 6) (0x7 7) (0x8 8) (0x9 9) (0xa 10) (0xb 11)
410
          (0xc 12) (0xd 13) (0xe 14) (0xf 15)
411
          ("1" 1) ("2" 2) ("3" 3) ("4" 4) ("5" 5) ("6" 6) ("7" 7) ("8" 8) ("9" 9) ("10" 10) ("11" 11)
412
          ("12" 12) ("13" 13) ("14" 14) ("15" 15))
413
)
414
 
415
(define-hardware
416
  (name h-r0)
417
  (comment "for 4-bit data excuding 0")
418
  (attrs PROFILE CACHE-ADDR)
419
  (type register HI (30))
420
  (indices extern-keyword reg0-name)
421
)
422
 
423
(define-keyword
424
  (name reg0-name1)
425
  (print-name h-reg01)
426
  (prefix "")
427
  (values (0x1 1) (0x2 2) (0x3 3) (0x4 4) (0x5 5) (0x6 6) (0x7 7)
428
          ("1" 1) ("2" 2) ("3" 3) ("4" 4) ("5" 5) ("6" 6) ("7" 7))
429
)
430
 
431
(define-hardware
432
  (name h-r01)
433
  (comment "for 4-bit data excuding 0")
434
  (attrs PROFILE CACHE-ADDR)
435
  (type register HI (14))
436
  (indices extern-keyword reg0-name1)
437
)
438
 
439
(define-keyword
440
  (name regbmem8-names)
441
  (print-name h-regbmem8)
442
  (prefix "")
443
  (values (dpp0 0)  (dpp1 1)  (dpp2 2)  (dpp3 3)
444
          (psw 136)   (cp 8)    (mdl 7)   (mdh  6)
445
          (mdc 135)   (sp 9)    (csp 4)  (vecseg 137)
446
          (stkov 10)  (stkun 11) (cpucon1 12) (cpucon2 13)
447
          (zeros 142)  (ones 143) (spseg 134) (tfr 214)
448
          (rl0 240) (rh0 241) (rl1 242) (rh1 243) (rl2 244) (rh2 245) (rl3 246) (rh3 247)
449
          (rl4 248) (rh4 249) (rl5 250) (rh5 251) (rl6 252) (rh6 253) (rl7 254) (rh7 255))
450
)
451
 
452
(define-hardware
453
  (name h-regbmem8)
454
  (comment "registers")
455
  (attrs PROFILE CACHE-ADDR)
456
  (type register HI (36))
457
  (indices extern-keyword regbmem8-names)
458
)
459
 
460
(define-keyword
461
  (name memgr8-names)
462
  (print-name h-memgr8)
463
  (prefix "")
464
  (values (dpp0 65024)  (dpp1 65026)  (dpp2 65028)  (dpp3 65030)
465
          (psw 65296)   (cp 65040)    (mdl 65038)   (mdh  65036)
466
          (mdc 65294)   (sp 65042)    (csp 65032)  (vecseg 65298)
467
          (stkov 65044)  (stkun 65046) (cpucon1 65048) (cpucon2 65050)
468
          (zeros 65308)  (ones 65310) (spseg 65292) (tfr 65452) )
469
)
470
 
471
(define-hardware
472
  (name h-memgr8)
473
  (comment "memory location of registers")
474
  (attrs )
475
  (type register HI (20))
476
  (indices extern-keyword memgr8-names)
477
)
478
 
479
(dsh h-cond "condition bit" () (register BI))   ;any bit from PSW while comparison
480
; This bit is part of the PSW register
481
(dsh h-cbit  "carry bit"                () (register BI))
482
 
483
(dsh h-sgtdis "segmentation enable bit" () (register BI)) ;0 means segmentation enabled
484
 
485
;Instruction operands
486
; -- layer between the assembler and the raw hardware description
487
; -- the main means of manipulating instruction fields in the semantic code
488
 
489
; XC16X specific operand attributes:
490
 
491
(define-attr
492
  (for operand)
493
  (type boolean)
494
  (name HASH-PREFIX)
495
  (comment "immediates have an optional '#' prefix")
496
)
497
 
498
(define-attr
499
  (for operand)
500
  (type boolean)
501
  (name DOT-PREFIX)
502
  (comment "bit addr have an optional '.' prefix")
503
)
504
 
505
(define-attr
506
  (for operand)
507
  (type boolean)
508
  (name POF-PREFIX)
509
  (comment "page offset ")
510
)
511
 
512
(define-attr
513
  (for operand)
514
  (type boolean)
515
  (name PAG-PREFIX)
516
  (comment "page ")
517
)
518
 
519
(define-attr
520
  (for operand)
521
  (type boolean)
522
  (name SOF-PREFIX)
523
  (comment "segment offset selection")
524
)
525
 
526
(define-attr
527
  (for operand)
528
  (type boolean)
529
  (name SEG-PREFIX)
530
  (comment "segment")
531
)
532
 
533
(dnop sr      "source register"              () h-gr    f-r2)
534
(dnop dr      "destination register"         () h-gr    f-r1)
535
(dnop dri     "destination register"         () h-gr    f-r4)
536
(dnop srb     "source register"              () h-grb   f-r2)
537
(dnop drb     "destination register"         () h-grb   f-r1)
538
(dnop sr2     "2 bit source register"        () h-gr    f-r0)
539
(dnop src1    "source register 1"            () h-gr   f-r1)
540
(dnop src2    "source register 2"            () h-gr   f-r2)
541
(dnop srdiv   "source register 2"            () h-regdiv8   f-reg8)
542
(dnop RegNam  "PSW bits"                     () h-psw f-reg8)
543
(dnop uimm2   "2 bit unsigned number"        (HASH-PREFIX) h-ext f-uimm2)
544
(dnop uimm3   "3 bit unsigned number"        (HASH-PREFIX) h-r01 f-uimm3)
545
(dnop uimm4   "4 bit unsigned number"        (HASH-PREFIX) h-uint f-uimm4)
546
(dnop uimm7   "7 bit trap number"            (HASH-PREFIX) h-uint f-uimm7)
547
(dnop uimm8   "8 bit unsigned immediate"     (HASH-PREFIX) h-uint f-uimm8)
548
(dnop uimm16  "16 bit unsigned immediate"    (HASH-PREFIX) h-uint f-uimm16)
549
(dnop upof16  "16 bit unsigned immediate"    (POF-PREFIX) h-addr f-memory)
550
(dnop reg8    "8 bit word register number"   () h-r8 f-reg8)
551
(dnop regmem8 "8 bit word register number"   () h-regmem8 f-regmem8)
552
(dnop regbmem8 "8 bit byte register number"  () h-regbmem8 f-regmem8)
553
(dnop regoff8 "8 bit word register number"   () h-r8 f-regoff8)
554
(dnop reghi8  "8 bit word register number"   () h-r8 f-reghi8)
555
(dnop regb8   "8 bit byte register number"   () h-grb8 f-regb8)
556
(dnop genreg  "8 bit word register number"   () h-r8 f-regb8)
557
(dnop seg     "8 bit segment number"         () h-uint f-seg8)
558
(dnop seghi8  "8 bit hi segment number"      () h-uint f-segnum8)
559
(dnop caddr   "16 bit address offset"        () h-addr f-offset16)
560
(dnop rel     "8 bit signed relative offset" () h-sint f-rel8)
561
(dnop relhi   "hi 8 bit signed relative offset" () h-sint f-relhi8)
562
(dnop condbit "condition bit"                (SEM-ONLY) h-cond f-nil)
563
(dnop bit1    "gap of 1 bit"                 () h-uint f-op-bit1)
564
(dnop bit2    "gap of 2 bits"                () h-uint f-op-bit2)
565
(dnop bit4    "gap of 4 bits"                () h-uint f-op-bit4)
566
(dnop lbit4   "gap of 4 bits"                () h-uint f-op-lbit4)
567
(dnop lbit2   "gap of 2 bits"                () h-uint f-op-lbit2)
568
(dnop bit8    "gap of 8 bits"                () h-uint f-op-bit8)
569
(dnop u4      "gap of 4 bits"                () h-r0   f-uimm4)
570
(dnop bitone  "field of 1 bit"               () h-uint f-op-onebit)
571
(dnop bit01   "field of 1 bit"               () h-uint f-op-1bit)
572
(dnop cond    "condition code"               () h-cc   f-condcode)
573
(dnop icond   "indirect condition code"      () h-cc   f-icondcode)
574
(dnop extcond "extended condition code"      () h-ecc  f-extccode)
575
(dnop memory  "16 bit memory"                () h-addr f-memory)
576
(dnop memgr8  "16 bit memory"                () h-memgr8 f-memgr8)
577
(dnop cbit    "carry bit"                    (SEM-ONLY) h-cbit  f-nil)
578
(dnop qbit    "bit addr"                     (DOT-PREFIX) h-uint  f-qbit)
579
(dnop qlobit  "bit addr"                     (DOT-PREFIX) h-uint  f-qlobit)
580
(dnop qhibit  "bit addr"                     (DOT-PREFIX) h-uint  f-qhibit)
581
(dnop mask8   "8 bit mask"                   (HASH-PREFIX) h-uint f-mask8)
582
(dnop masklo8 "8 bit mask"                   (HASH-PREFIX) h-uint f-datahi8)
583
(dnop pagenum "10 bit page number"           (HASH-PREFIX) h-uint f-pagenum)
584
(dnop data8   "8 bit data"                   (HASH-PREFIX) h-uint f-data8)
585
(dnop datahi8 "8 bit data"                   (HASH-PREFIX) h-uint f-datahi8)
586
(dnop sgtdisbit "segmentation enable bit"    (SEM-ONLY) h-sgtdis f-nil)
587
(dnop upag16  "16 bit unsigned immediate"    (PAG-PREFIX) h-uint f-uimm16)
588
(dnop useg8   "8 bit segment "               (SEG-PREFIX) h-uint f-seg8)
589
(dnop useg16  "16 bit address offset"        (SEG-PREFIX) h-uint f-offset16)
590
(dnop usof16  "16 bit address offset"        (SOF-PREFIX) h-uint f-offset16)
591
 
592
; define hash operator
593
(define-operand (name hash) (comment "# prefix") (attrs)
594
  (type h-sint)
595
  (index f-nil)
596
  (handlers (parse "hash") (print "hash"))
597
)
598
 
599
; define dot operator
600
(define-operand (name dot) (comment ". prefix") (attrs)
601
  (type h-sint)
602
  (index f-nil)
603
  (handlers (parse "dot") (print "dot"))
604
)
605
 
606
; define pof operator
607
(define-operand (name pof) (comment "pof: prefix") (attrs)
608
  (type h-sint)
609
  (index f-nil)
610
  (handlers (parse "pof") (print "pof"))
611
)
612
 
613
; define pag operator
614
(define-operand (name pag) (comment "pag: prefix") (attrs)
615
  (type h-sint)
616
  (index f-nil)
617
  (handlers (parse "pag") (print "pag"))
618
)
619
 
620
; define sof operator
621
(define-operand (name sof) (comment "sof: prefix") (attrs)
622
  (type h-sint)
623
  (index f-nil)
624
  (handlers (parse "sof") (print "sof"))
625
)
626
 
627
; define seg operator
628
(define-operand (name segm) (comment "seg: prefix") (attrs)
629
  (type h-sint)
630
  (index f-nil)
631
  (handlers (parse "seg") (print "seg"))
632
)
633
 
634
; IDOC attribute for instruction documentation.
635
(define-attr
636
  (for insn)
637
  (type enum)
638
  (name IDOC)
639
  (comment "insn kind for documentation")
640
  (attrs META)
641
  (values
642
   (MOVE - () "Data Movement")
643
   (ALU  - () "Arithmatic & logical")
644
   (CMP  - () "Compare")
645
   (JMP  - () "Jump & Call")
646
   (MISC - () "Miscellaneous")
647
   (SYSC - () "System control")
648
  )
649
)
650
 
651
; Include the instruction set descriptions from their respective
652
; source files.
653
 
654
;Arithmatic insns
655
;******************************************************************
656
 
657
;add/sub register and immediate
658
(define-pmacro (arithmetic16 name insn insn1 opc1 opc2 op1 op2 mode dir)
659
  (dni name
660
       (.str name "arithmetic" )
661
       ((PIPE OS) (IDOC ALU))
662
       (.str insn " $"op1 ",$"dir"$"op2)
663
       (+ opc1 opc2 op1 op2)
664
       (set mode op1 (insn1 mode op1 (mem HI op2)))
665
       ()
666
  )
667
)
668
(arithmetic16 addrpof add add OP1_0 OP2_2 reg8 upof16 HI "pof")
669
(arithmetic16 subrpof sub sub OP1_2 OP2_2 reg8 upof16 HI "pof")
670
(arithmetic16 addbrpof addb add OP1_0 OP2_3 regb8 upof16 QI "pof")
671
(arithmetic16 subbrpof subb sub OP1_2 OP2_3 regb8 upof16 QI "pof")
672
(arithmetic16 addrpag add add OP1_0 OP2_2 reg8 upag16 HI "pag")
673
(arithmetic16 subrpag sub sub OP1_2 OP2_2 reg8 upag16 HI "pag")
674
(arithmetic16 addbrpag addb add OP1_0 OP2_3 regb8 upag16 QI "pag")
675
(arithmetic16 subbrpag subb sub OP1_2 OP2_3 regb8 upag16 QI "pag")
676
 
677
;add/sub register and immediate
678
(define-pmacro (arithmetic17 name insn insn1 opc1 opc2 op1 op2 mode dir)
679
  (dni name
680
       (.str name "arithmetic" )
681
       ((PIPE OS) (IDOC ALU))
682
       (.str insn " $"op1 ",$"dir"$"op2)
683
       (+ opc1 opc2 op1 op2)
684
       (set mode op1 (insn1 mode op1 (mem HI op2) cbit))
685
       ()
686
  )
687
)
688
(arithmetic17 addcrpof addc addc OP1_1 OP2_2 reg8 upof16 HI "pof")
689
(arithmetic17 subcrpof subc subc OP1_3 OP2_2 reg8 upof16 HI "pof")
690
(arithmetic17 addcbrpof addcb addc OP1_1 OP2_3 regb8 upof16 QI "pof")
691
(arithmetic17 subcbrpof subcb subc OP1_3 OP2_3 regb8 upof16 QI "pof")
692
(arithmetic17 addcrpag addc addc OP1_1 OP2_2 reg8 upag16 HI "pag")
693
(arithmetic17 subcrpag subc subc OP1_3 OP2_2 reg8 upag16 HI "pag")
694
(arithmetic17 addcbrpag addcb addc OP1_1 OP2_3 regb8 upag16 QI "pag")
695
(arithmetic17 subcbrpag subcb subc OP1_3 OP2_3 regb8 upag16 QI "pag")
696
 
697
;add/sub register and immediate
698
(define-pmacro (arithmetic18 name insn insn1 opc1 opc2 op1 op2 mode dir)
699
  (dni name
700
       (.str name "arithmetic" )
701
       ((PIPE OS) (IDOC ALU))
702
       (.str insn " $"dir"$"op1 ",$"op2)
703
       (+ opc1 opc2 op2 op1)
704
       (set (mem HI op1) (insn1 (mem HI op1) op2 ))
705
       ()
706
  )
707
)
708
(arithmetic18 addrpofr add add OP1_0 OP2_4 upof16 reg8 HI "pof")
709
(arithmetic18 subrpofr sub sub OP1_2 OP2_4 upof16 reg8 HI "pof")
710
(arithmetic18 addbrpofr addb add OP1_0 OP2_5 upof16 regb8 QI "pof")
711
(arithmetic18 subbrpofr subb sub OP1_2 OP2_5 upof16 regb8 QI "pof")
712
 
713
;add/sub register and immediate
714
(define-pmacro (arithmetic19 name insn insn1 opc1 opc2 op1 op2 mode dir)
715
  (dni name
716
       (.str name "arithmetic" )
717
       ((PIPE OS) (IDOC ALU))
718
       (.str insn " $"dir"$"op1 ",$"op2)
719
       (+ opc1 opc2 op2 op1)
720
       (set (mem HI op1) (insn1 mode (mem HI op1) op2 cbit))
721
       ()
722
  )
723
)
724
(arithmetic19 addcrpofr addc addc OP1_1 OP2_4 upof16 reg8 HI "pof")
725
(arithmetic19 subcrpofr subc subc OP1_3 OP2_4 upof16 reg8 HI "pof")
726
(arithmetic19 addcbrpofr addcb addc OP1_1 OP2_5 upof16 regb8 QI "pof")
727
(arithmetic19 subcbrpofr subcb subc OP1_3 OP2_5 upof16 regb8 QI "pof")
728
 
729
;add/sub register and immediate
730
(define-pmacro (arithmetic20 name insn insn1 opc1 opc2 op1 op2 mode dir)
731
  (dni name
732
       (.str name "arithmetic" )
733
       ((PIPE OS) (IDOC ALU))
734
       (.str insn " $"op1 ",$hash$"dir"$"op2)
735
       (+ opc1 opc2 op1 op2)
736
       (set mode op1 (insn1 mode op1 op2))
737
       ()
738
  )
739
)
740
(arithmetic20 addrhpof add add OP1_0 OP2_6 reg8 uimm16 HI "pof")
741
(arithmetic20 subrhpof sub sub OP1_2 OP2_6 reg8 uimm16 HI "pof")
742
(arithmetic20 addbrhpof add add OP1_0 OP2_6 reg8 uimm16 HI "pag")
743
(arithmetic20 subbrhpof sub sub OP1_2 OP2_6 reg8 uimm16 HI "pag")
744
 
745
;add/sub register and immediate
746
(define-pmacro (arithmetic21 name insn insn1 opc1 opc2 op1 op2 mode dir)
747
  (dni name
748
       (.str name "arithmetic" )
749
       ((PIPE OS) (IDOC ALU))
750
       (.str insn " $"op1 ",$hash$"dir"$"op2)
751
       (+ opc1 opc2 op1 (f-op-bit1 0) op2)
752
       (set mode op1 (insn1 mode op1 op2))
753
       ()
754
  )
755
)
756
(arithmetic21 addrhpof3 add add OP1_0 OP2_8 dr uimm3 HI "pof")
757
(arithmetic21 subrhpof3 sub sub OP1_2 OP2_8 dr uimm3 HI "pof")
758
(arithmetic21 addbrhpag3 addb add OP1_0 OP2_9 drb uimm3 QI "pag")
759
(arithmetic21 subbrhpag3 subb sub OP1_2 OP2_9 drb uimm3 QI "pag")
760
(arithmetic21 addrhpag3 add add OP1_0 OP2_8 dr uimm3 HI "pag")
761
(arithmetic21 subrhpag3 sub sub OP1_2 OP2_8 dr uimm3 HI "pag")
762
(arithmetic21 addbrhpof3 addb add OP1_0 OP2_9 drb uimm3 QI "pof")
763
(arithmetic21 subbrhpof3 subb sub OP1_2 OP2_9 drb uimm3 QI "pof")
764
 
765
;add/sub register and immediate
766
(define-pmacro (arithmetic22 name insn insn1 opc1 opc2 op1 op2 mode dir)
767
  (dni name
768
       (.str name "arithmetic" )
769
       ((PIPE OS) (IDOC ALU))
770
       (.str insn " $"op1 ",$hash$"dir"$"op2)
771
       (+ opc1 opc2 op1 op2 (f-op-bit8 0))
772
       (set mode op1 (insn1 mode op1 op2))
773
       ()
774
  )
775
)
776
(arithmetic22 addrbhpof addb add OP1_0 OP2_7 regb8 uimm8 QI "pof")
777
(arithmetic22 subrbhpof subb sub OP1_2 OP2_7 regb8 uimm8 QI "pof")
778
(arithmetic22 addbrhpag addb add OP1_0 OP2_7 regb8 uimm8 QI "pag")
779
(arithmetic22 subbrhpag subb sub OP1_2 OP2_7 regb8 uimm8 QI "pag")
780
 
781
;add/sub register and immediate
782
(define-pmacro (arithmetic23 name insn insn1 opc1 opc2 op1 op2 mode dir)
783
  (dni name
784
       (.str name "arithmetic" )
785
       ((PIPE OS) (IDOC ALU))
786
       (.str insn " $"op1 ",$hash$"dir"$"op2)
787
       (+ opc1 opc2 op1 op2)
788
       (set mode op1 (insn1 mode op1 op2 cbit))
789
       ()
790
  )
791
)
792
(arithmetic23 addcrhpof addc addc OP1_1 OP2_6 reg8 uimm16 HI "pof")
793
(arithmetic23 subcrhpof subc subc OP1_3 OP2_6 reg8 uimm16 HI "pof")
794
(arithmetic23 addcbrhpof addc addc OP1_1 OP2_6 reg8 uimm16 HI "pag")
795
(arithmetic23 subcbrhpof subc subc OP1_3 OP2_6 reg8 uimm16 HI "pag")
796
 
797
;add/sub register and immediate
798
(define-pmacro (arithmetic24 name insn insn1 opc1 opc2 op1 op2 mode dir)
799
  (dni name
800
       (.str name "arithmetic" )
801
       ((PIPE OS) (IDOC ALU))
802
       (.str insn " $"op1 ",$hash$"dir"$"op2)
803
       (+ opc1 opc2 op1 (f-op-bit1 0) op2)
804
       (set mode op1 (insn1 mode op1 op2 cbit))
805
       ()
806
  )
807
)
808
(arithmetic24 addcrhpof3 addc addc OP1_1 OP2_8 dr uimm3 HI "pof")
809
(arithmetic24 subcrhpof3 subc subc OP1_3 OP2_8 dr uimm3 HI "pof")
810
(arithmetic24 addcbrhpag3 addcb addc OP1_1 OP2_9 drb uimm3 QI "pag")
811
(arithmetic24 subcbrhpag3 subcb subc OP1_3 OP2_9 drb uimm3 QI "pag")
812
(arithmetic24 addcrhpag3 addc addc OP1_1 OP2_8 dr uimm3 HI "pag")
813
(arithmetic24 subcrhpag3 subc subc OP1_3 OP2_8 dr uimm3 HI "pag")
814
(arithmetic24 addcbrhpof3 addcb addc OP1_1 OP2_9 drb uimm3 QI "pof")
815
(arithmetic24 subcbrhpof3 subcb subc OP1_3 OP2_9 drb uimm3 QI "pof")
816
 
817
;add/sub register and immediate
818
(define-pmacro (arithmetic25 name insn insn1 opc1 opc2 op1 op2 mode dir)
819
  (dni name
820
       (.str name "arithmetic" )
821
       ((PIPE OS) (IDOC ALU))
822
       (.str insn " $"op1 ",$hash$"dir"$"op2)
823
       (+ opc1 opc2 op1 op2 (f-op-bit8 0))
824
       (set mode op1 (insn1 mode op1 op2 cbit))
825
       ()
826
  )
827
)
828
(arithmetic25 addcrbhpof addcb addc OP1_1 OP2_7 regb8 uimm8 QI "pof")
829
(arithmetic25 subcrbhpof subcb subc OP1_3 OP2_7 regb8 uimm8 QI "pof")
830
(arithmetic25 addcbrhpag addcb addc OP1_1 OP2_7 regb8 uimm8 QI "pag")
831
(arithmetic25 subcbrhpag subcb subc OP1_3 OP2_7 regb8 uimm8 QI "pag")
832
 
833
;add/sub register and immediate
834
(define-pmacro (arithmetic10 name insn insn1 opc1 opc2 op1 op2 mode)
835
  (dni name
836
       (.str name "arithmetic" )
837
       ((PIPE OS) (IDOC ALU))
838
       (.str insn " $"op1 ",$hash$"op2)
839
       (+ opc1 opc2 op1 (f-op-bit1 0) op2)
840
       (set mode op1 (insn1 mode op1 op2))
841
       ()
842
  )
843
)
844
(arithmetic10 addri add add OP1_0 OP2_8 dr uimm3 HI)
845
(arithmetic10 subri sub sub OP1_2 OP2_8 dr uimm3 HI)
846
(arithmetic10 addbri addb add OP1_0 OP2_9 drb uimm3 QI)
847
(arithmetic10 subbri subb sub OP1_2 OP2_9 drb uimm3 QI)
848
 
849
;add/sub register and immediate
850
(define-pmacro (arithmetic11 name insn insn1 opc1 opc2 op1 op2 mode)
851
  (dni name
852
       (.str name "arithmetic" )
853
       ((PIPE OS) (IDOC ALU))
854
       (.str insn " $"op1 ",$hash$"op2)
855
       (+ opc1 opc2 op1 op2)
856
       (set mode op1 (insn1 mode op1 op2))
857
       ()
858
  )
859
)
860
(arithmetic11 addrim add add OP1_0 OP2_6 reg8 uimm16 HI)
861
(arithmetic11 subrim sub sub OP1_2 OP2_6 reg8 uimm16 HI)
862
 
863
;add/sub register and immediate
864
(define-pmacro (arithmetic12 name insn insn1 opc1 opc2 op1 op2 mode)
865
  (dni name
866
       (.str name "arithmetic" )
867
       ((PIPE OS) (IDOC ALU))
868
       (.str insn " $"op1 ",$hash$"op2)
869
       (+ opc1 opc2 op1 op2 (f-op-bit8 0))
870
       (set mode op1 (insn1 mode op1 op2))
871
       ()
872
  )
873
)
874
(arithmetic12 addbrim addb add OP1_0 OP2_7 regb8 uimm8 QI)
875
(arithmetic12 subbrim subb sub OP1_2 OP2_7 regb8 uimm8 QI)
876
 
877
;add/sub register and immediate with carry
878
(define-pmacro (arithmetic13 name insn insn1 opc1 opc2 op1 op2 mode)
879
  (dni name
880
       (.str name "arithmetic" )
881
       ((PIPE OS) (IDOC ALU))
882
       (.str insn " $"op1 ",$hash$"op2)
883
       (+ opc1 opc2 op1 (f-op-bit1 0) op2)
884
       (set mode op1 (insn1 mode op1 op2 cbit))
885
       ()
886
  )
887
)
888
(arithmetic13 addcri addc addc OP1_1 OP2_8 dr uimm3 HI)
889
(arithmetic13 subcri subc subc OP1_3 OP2_8 dr uimm3 HI)
890
(arithmetic13 addcbri addcb addc OP1_1 OP2_9 drb uimm3 QI)
891
(arithmetic13 subcbri subcb subc OP1_3 OP2_9 drb uimm3 QI)
892
 
893
;add/sub register and immediate with carry
894
(define-pmacro (arithmetic14 name insn insn1 opc1 opc2 op1 op2 mode)
895
  (dni name
896
       (.str name "arithmetic" )
897
       ((PIPE OS) (IDOC ALU))
898
       (.str insn " $"op1 ",$hash$"op2)
899
       (+ opc1 opc2 op1 op2)
900
       (set mode op1 (insn1 mode op1 op2 cbit))
901
       ()
902
  )
903
)
904
(arithmetic14 addcrim addc addc OP1_1 OP2_6 reg8 uimm16 HI)
905
(arithmetic14 subcrim subc subc OP1_3 OP2_6 reg8 uimm16 HI)
906
 
907
;add/sub register and immediate with carry
908
(define-pmacro (arithmetic15 name insn insn1 opc1 opc2 op1 op2 mode)
909
  (dni name
910
       (.str name "arithmetic" )
911
       ((PIPE OS) (IDOC ALU))
912
       (.str insn " $"op1 ",$hash$"op2)
913
       (+ opc1 opc2 op1 op2 (f-op-bit8 0))
914
       (set mode op1 (insn1 mode op1 op2 cbit))
915
       ()
916
  )
917
)
918
(arithmetic15 addcbrim addcb addc OP1_1 OP2_7 regb8 uimm8 QI)
919
(arithmetic15 subcbrim subcb subc OP1_3 OP2_7 regb8 uimm8 QI)
920
 
921
 
922
;add/sub registers
923
(define-pmacro (arithmetic name insn insn1 opc1 opc2 op1 op2 mode)
924
  (dni name
925
       (.str name "arithmetic" )
926
       ((PIPE OS) (IDOC ALU))
927
       (.str insn " $"op1 ",$"op2)
928
       (+ opc1 opc2 op1 op2)
929
       (set mode op1 (insn1 mode op1 op2))
930
       ()
931
  )
932
)
933
(arithmetic addr add add OP1_0 OP2_0 dr sr HI)
934
(arithmetic subr sub sub OP1_2 OP2_0 dr sr HI)
935
(arithmetic addbr addb add OP1_0 OP2_1 drb srb QI)
936
(arithmetic subbr subb sub OP1_2 OP2_1 drb srb QI)
937
 
938
;add/sub register and indirect memory
939
(define-pmacro (arithmetic1 name insn insn1 opc1 opc2 op1 op2 mode)
940
  (dni name
941
       (.str name "arithmetic" )
942
       ((PIPE OS) (IDOC ALU))
943
       (.str insn " $"op1 ",[$"op2"]")
944
       (+ opc1 opc2 op1 (f-op-bit2 2) op2)
945
       (set mode op1 (insn1 mode op1 (mem HI op2)))
946
       ()
947
  )
948
)
949
(arithmetic1 add2 add add OP1_0 OP2_8 dr sr2 HI)
950
(arithmetic1 sub2 sub sub OP1_2 OP2_8 dr sr2 HI)
951
(arithmetic1 addb2 addb add OP1_0 OP2_9 drb sr2 QI)
952
(arithmetic1 subb2 subb sub OP1_2 OP2_9 drb sr2 QI)
953
 
954
;add/sub register and indirect memory post increment
955
(define-pmacro (arithmetic2 name insn insn1 opc1 opc2 op1 op2 mode)
956
  (dni name
957
       (.str name "arithmetic" )
958
       ((PIPE OS) (IDOC ALU))
959
       (.str insn " $"op1 ",[$"op2"+]")
960
       (+ opc1 opc2 op1 (f-op-bit2 3) op2)
961
       (sequence ()
962
           (set mode op1 (insn1 mode op1 (mem HI op2)))
963
           (set HI op2 (add HI op2 (const 2)))
964
       )
965
       ()
966
  )
967
)
968
(arithmetic2 add2i add add OP1_0 OP2_8 dr sr2 HI)
969
(arithmetic2 sub2i sub sub OP1_2 OP2_8 dr sr2 HI)
970
(arithmetic2 addb2i addb add OP1_0 OP2_9 drb sr2 QI)
971
(arithmetic2 subb2i subb sub OP1_2 OP2_9 drb sr2 QI)
972
 
973
;add/sub registers with carry
974
(define-pmacro (arithmetic3 name insn insn1 opc1 opc2 op1 op2 mode)
975
  (dni name
976
       (.str name "arithmetic" )
977
       ((PIPE OS) (IDOC ALU))
978
       (.str insn " $"op1 ",$"op2)
979
       (+ opc1 opc2 op1 op2)
980
       (set mode op1 (insn1 mode op1 op2 cbit))
981
       ()
982
  )
983
)
984
(arithmetic3 addcr addc addc OP1_1 OP2_0 dr sr HI)
985
(arithmetic3 subcr subc subc OP1_3 OP2_0 dr sr HI)
986
(arithmetic3 addbcr addcb addc OP1_1 OP2_1 drb srb QI)
987
(arithmetic3 subbcr subcb subc OP1_3 OP2_1 drb srb QI)
988
 
989
 
990
;add/sub register and indirect memory
991
(define-pmacro (arithmetic4 name insn insn1 opc1 opc2 op1 op2 mode)
992
  (dni name
993
       (.str name "arithmetic" )
994
       ((PIPE OS) (IDOC ALU))
995
       (.str insn " $"op1 ",[$"op2"]")
996
       (+ opc1 opc2 op1 (f-op-bit2 2) op2)
997
       (set mode op1 (insn1 mode op1 (mem HI op2) cbit))
998
       ()
999
  )
1000
)
1001
(arithmetic4 addcr2 addc addc OP1_1 OP2_8 dr sr2 HI)
1002
(arithmetic4 subcr2 subc subc OP1_3 OP2_8 dr sr2 HI)
1003
(arithmetic4 addbcr2 addcb addc OP1_1 OP2_9 drb sr2 QI)
1004
(arithmetic4 subbcr2 subcb subc OP1_3 OP2_9 drb sr2 QI)
1005
 
1006
;add/sub register and indirect memory post increment
1007
(define-pmacro (arithmetic5 name insn insn1 opc1 opc2 op1 op2 mode)
1008
  (dni name
1009
       (.str name "arithmetic" )
1010
       ((PIPE OS) (IDOC ALU))
1011
       (.str insn " $"op1 ",[$"op2"+]")
1012
       (+ opc1 opc2 op1 (f-op-bit2 3) op2)
1013
       (sequence ()
1014
           (set mode op1 (insn1 mode op1 (mem HI op2) cbit))
1015
           (set HI op2 (add HI op2 (const 2)))
1016
       )
1017
       ()
1018
  )
1019
)
1020
(arithmetic5 addcr2i addc addc OP1_1 OP2_8 dr sr2 HI)
1021
(arithmetic5 subcr2i subc subc OP1_3 OP2_8 dr sr2 HI)
1022
(arithmetic5 addbcr2i addcb addc OP1_1 OP2_9 drb sr2 QI)
1023
(arithmetic5 subbcr2i subcb subc OP1_3 OP2_9 drb sr2 QI)
1024
 
1025
;add/sub register and direct memory
1026
(define-pmacro (arithmetic6 name insn insn1 opc1 opc2 op1 op2 mode)
1027
  (dni name
1028
       (.str name "arithmetic" )
1029
       ((PIPE OS) (IDOC ALU))
1030
       (.str insn " $"op1 ",$"op2)
1031
       (+ opc1 opc2 op1 op2)
1032
       (set mode op1 (insn1 mode op1 op2))
1033
       ()
1034
  )
1035
)
1036
 
1037
;add/sub register and direct memory
1038
(define-pmacro (arithmetic7 name insn insn1 opc1 opc2 op1 op2 mode)
1039
  (dni name
1040
       (.str name "arithmetic" )
1041
       ((PIPE OS) (IDOC ALU))
1042
       (.str insn " $"op1 ",$"op2)
1043
       (+ opc1 opc2 op2 op1)
1044
       (set (mem HI op1) (insn1 (mem HI op1) op2))
1045
       ()
1046
  )
1047
)
1048
(arithmetic6 addrm2 add add OP1_0 OP2_2 regmem8 memgr8 HI)
1049
(arithmetic7 addrm3 add add OP1_0 OP2_4 memgr8 regmem8 HI)
1050
(arithmetic6 addrm add add OP1_0 OP2_2 reg8 memory HI)
1051
(arithmetic7 addrm1 add add OP1_0 OP2_4 memory reg8 HI)
1052
(arithmetic6 subrm3 sub sub OP1_2 OP2_2 regmem8 memgr8 HI)
1053
(arithmetic7 subrm2 sub sub OP1_2 OP2_4 memgr8 regmem8 HI)
1054
(arithmetic6 subrm1 sub sub OP1_2 OP2_2 reg8 memory HI)
1055
(arithmetic7 subrm sub sub OP1_2 OP2_4 memory reg8 HI)
1056
(arithmetic6 addbrm2 addb add OP1_0 OP2_3 regbmem8 memgr8 QI)
1057
(arithmetic7 addbrm3 addb add OP1_0 OP2_5 memgr8 regbmem8 QI)
1058
(arithmetic6 addbrm addb add OP1_0 OP2_3 regb8 memory QI)
1059
(arithmetic7 addbrm1 addb add OP1_0 OP2_5 memory regb8 QI)
1060
(arithmetic6 subbrm3 subb sub OP1_2 OP2_3 regbmem8 memgr8 QI)
1061
(arithmetic7 subbrm2 subb sub OP1_2 OP2_5 memgr8 regbmem8 QI)
1062
(arithmetic6 subbrm1 subb sub OP1_2 OP2_3 regb8 memory QI)
1063
(arithmetic7 subbrm subb sub OP1_2 OP2_5 memory regb8 QI)
1064
 
1065
;add/sub registers with carry
1066
(define-pmacro (arithmetic8 name insn insn1 opc1 opc2 op1 op2 mode)
1067
  (dni name
1068
       (.str name "arithmetic" )
1069
       ((PIPE OS) (IDOC ALU))
1070
       (.str insn " $"op1 ",$"op2)
1071
       (+ opc1 opc2 op1 op2)
1072
       (set mode op1 (insn1 mode op1 op2 cbit))
1073
       ()
1074
  )
1075
)
1076
 
1077
;add/sub registers with carry
1078
(define-pmacro (arithmetic9 name insn insn1 opc1 opc2 op1 op2 mode)
1079
  (dni name
1080
       (.str name "arithmetic" )
1081
       ((PIPE OS) (IDOC ALU))
1082
       (.str insn " $"op1 ",$"op2)
1083
       (+ opc1 opc2 op2 op1)
1084
       (set (mem HI op1) (insn1 (mem HI op1) op2 cbit))
1085
       ()
1086
  )
1087
)
1088
(arithmetic8 addcrm2 addc addc OP1_1 OP2_2 regmem8 memgr8 HI)
1089
(arithmetic9 addcrm3 addc addc OP1_1 OP2_4  memgr8 regmem8 HI)
1090
(arithmetic8 addcrm addc addc OP1_1 OP2_2 reg8 memory HI)
1091
(arithmetic9 addcrm1 addc addc OP1_1 OP2_4  memory reg8 HI)
1092
(arithmetic8 subcrm3 subc subc OP1_3 OP2_2  regmem8 memgr8 HI)
1093
(arithmetic9 subcrm2 subc subc OP1_3 OP2_4 memgr8 regmem8 HI)
1094
(arithmetic8 subcrm1 subc subc OP1_3 OP2_2  reg8 memory HI)
1095
(arithmetic9 subcrm subc subc OP1_3 OP2_4 memory reg8 HI)
1096
(arithmetic8 addcbrm2 addcb addc OP1_1 OP2_3 regbmem8 memgr8 QI)
1097
(arithmetic9 addcbrm3 addcb addc OP1_1 OP2_5  memgr8 regbmem8 QI)
1098
(arithmetic8 addcbrm addcb addc OP1_1 OP2_3 regb8 memory QI)
1099
(arithmetic9 addcbrm1 addcb addc OP1_1 OP2_5  memory regb8 QI)
1100
(arithmetic8 subcbrm3 subcb subc OP1_3 OP2_3  regbmem8 memgr8 QI)
1101
(arithmetic9 subcbrm2 subcb subc OP1_3 OP2_5 memgr8 regbmem8 QI)
1102
(arithmetic8 subcbrm1 subcb subc OP1_3 OP2_3  regb8 memory QI)
1103
(arithmetic9 subcbrm subcb subc OP1_3 OP2_5 memory regb8 QI)
1104
 
1105
; MUL Rwn,Rwm
1106
(dni muls "signed multiplication"
1107
     ((PIPE OS) (IDOC ALU))
1108
     "mul $src1,$src2"
1109
     (+ OP1_0 OP2_11 src1 src2)
1110
     (reg SI h-md 0)
1111
     ()
1112
)
1113
; MULU Rwn,Rwm
1114
(dni mulu "unsigned multiplication"
1115
     ((PIPE OS) (IDOC ALU))
1116
     "mulu $src1,$src2"
1117
     (+ OP1_1 OP2_11 src1 src2)
1118
     (reg SI h-md 0)
1119
     ()
1120
)
1121
; DIV Rwn
1122
(dni div "16-by-16 signed division"
1123
     ((PIPE OS) (IDOC ALU))
1124
     "div $srdiv"
1125
     (+ OP1_4 OP2_11 srdiv )
1126
     (sequence ()
1127
         (set HI (reg HI h-cr 6) (div HI (reg HI h-cr 6) srdiv))
1128
         (set HI (reg HI h-cr 7) (mod HI (reg HI h-cr 6) srdiv))
1129
     )
1130
     ()
1131
)
1132
; DIVL Rwn
1133
(dni divl "32-by16 signed division"
1134
     ((PIPE OS) (IDOC ALU))
1135
     "divl $srdiv"
1136
     (+ OP1_6 OP2_11 srdiv )
1137
     (sequence ()
1138
         (set HI (reg HI h-cr 6) (div SI (reg SI h-md 0) srdiv))
1139
         (set HI (reg HI h-cr 7) (mod SI (reg SI h-md 0) srdiv))
1140
     )
1141
     ()
1142
)
1143
; DIVLU Rwn
1144
(dni divlu "32-by16 unsigned division"
1145
     ((PIPE OS) (IDOC ALU))
1146
     "divlu $srdiv"
1147
     (+ OP1_7 OP2_11 srdiv )
1148
     (sequence ()
1149
         (set HI (reg HI h-cr 6) (udiv SI (reg SI h-md 0) srdiv))
1150
         (set HI (reg HI h-cr 7) (umod SI (reg SI h-md 0) srdiv))
1151
     )
1152
     ()
1153
)
1154
; DIVU Rwn
1155
(dni divu "16-by-16 unsigned division"
1156
     ((PIPE OS) (IDOC ALU))
1157
     "divu $srdiv"
1158
     (+ OP1_5 OP2_11 srdiv )
1159
     (sequence ()
1160
         (set HI (reg HI h-cr 6) (udiv HI (reg HI h-cr 6) srdiv))
1161
         (set HI (reg HI h-cr 7) (umod HI (reg HI h-cr 6) srdiv))
1162
     )
1163
     ()
1164
)
1165
 
1166
;Integer one's complement
1167
; CPL Rwn
1168
(dni cpl "Integer Ones complement"
1169
     ((PIPE OS) (IDOC MISC))
1170
     "cpl $dr"
1171
     (+ OP1_9 OP2_1 dr (f-op-bit4 0))
1172
     (set dr (inv HI dr))
1173
     ()
1174
)
1175
 
1176
;Bytes one's complement
1177
; CPLB Rbn
1178
(dni cplb "Byte Ones complement"
1179
     ((PIPE OS) (IDOC MISC))
1180
     "cplb $drb"
1181
     (+ OP1_11 OP2_1 drb (f-op-bit4 0))
1182
     (set drb (inv QI drb))
1183
     ()
1184
)
1185
;Integer two's complement
1186
; NEG Rwn
1187
(dni neg "Integer two's complement"
1188
     ((PIPE OS) (IDOC MISC))
1189
     "neg $dr"
1190
     (+ OP1_8 OP2_1 dr (f-op-bit4 0))
1191
     (set dr (neg HI dr))
1192
     ()
1193
)
1194
;Bytes two's complement
1195
; NEGB Rbn
1196
(dni negb "byte twos complement"
1197
     ((PIPE OS) (IDOC MISC))
1198
     "negb $drb"
1199
     (+ OP1_10 OP2_1 drb (f-op-bit4 0))
1200
     (set drb (neg QI drb))
1201
     ()
1202
)
1203
 
1204
;****************************************************************
1205
;logical insn
1206
;****************************************************************
1207
;and/or/xor registers
1208
(define-pmacro (logical name insn insn1 opc1 opc2 op1 op2 mode)
1209
  (dni name
1210
       (.str name "logical" )
1211
       ((PIPE OS) (IDOC ALU))
1212
       (.str insn " $"op1 ",$"op2)
1213
       (+ opc1 opc2 op1 op2)
1214
       (set mode op1 (insn1 mode op1 op2))
1215
       ()
1216
  )
1217
)
1218
 
1219
(logical andr and and OP1_6 OP2_0 dr sr HI)
1220
(logical orr or or OP1_7 OP2_0 dr sr HI)
1221
(logical xorr xor xor OP1_5 OP2_0 dr sr HI)
1222
(logical andbr andb and OP1_6 OP2_1 drb srb QI)
1223
(logical orbr orb or OP1_7 OP2_1 drb srb QI)
1224
(logical xorbr xorb xor OP1_5 OP2_1 drb srb QI)
1225
 
1226
;and/or/xor register and immediate
1227
(define-pmacro (logical1 name insn insn1 opc1 opc2 op1 op2 mode)
1228
  (dni name
1229
       (.str name "logical" )
1230
       ((PIPE OS) (IDOC ALU))
1231
       (.str insn " $"op1 ",$hash$"op2)
1232
       (+ opc1 opc2 op1 (f-op-bit1 0) op2)
1233
       (set mode op1 (insn1 mode op1 op2))
1234
       ()
1235
  )
1236
)
1237
(logical1 andri and and OP1_6 OP2_8 dr uimm3 HI)
1238
(logical1 orri or or OP1_7 OP2_8 dr uimm3 HI)
1239
(logical1 xorri xor xor OP1_5 OP2_8 dr uimm3 HI)
1240
(logical1 andbri andb and OP1_6 OP2_9 drb uimm3 QI)
1241
(logical1 orbri orb or OP1_7 OP2_9 drb uimm3 QI)
1242
(logical1 xorbri xorb xor OP1_5 OP2_9 drb uimm3 QI)
1243
 
1244
;and/or/xor register and immediate
1245
(define-pmacro (logical2 name insn insn1 opc1 opc2 op1 op2 mode)
1246
  (dni name
1247
       (.str name "logical" )
1248
       ((PIPE OS) (IDOC ALU))
1249
       (.str insn " $"op1 ",$hash$"op2)
1250
       (+ opc1 opc2 op1 op2)
1251
       (set mode op1 (insn1 mode op1 op2))
1252
       ()
1253
  )
1254
)
1255
(logical2 andrim and and OP1_6 OP2_6 reg8 uimm16 HI)
1256
(logical2 orrim or or OP1_7 OP2_6 reg8 uimm16 HI)
1257
(logical2 xorrim xor xor OP1_5 OP2_6 reg8 uimm16 HI)
1258
 
1259
;and/or/xor register and immediate
1260
(define-pmacro (logical3 name insn insn1 opc1 opc2 op1 op2 mode)
1261
  (dni name
1262
       (.str name "logical" )
1263
       ((PIPE OS) (IDOC ALU))
1264
       (.str insn " $"op1 ",$hash$"op2)
1265
       (+ opc1 opc2 op1 op2 (f-op-bit8 0))
1266
       (set mode op1 (insn1 mode op1 op2))
1267
       ()
1268
  )
1269
)
1270
(logical3 andbrim andb and OP1_6 OP2_7 regb8 uimm8 QI)
1271
(logical3 orbrim orb or OP1_7 OP2_7 regb8 uimm8 QI)
1272
(logical3 xorbrim xorb xor OP1_5 OP2_7 regb8 uimm8 QI)
1273
 
1274
;and/or/xor register and indirect memory
1275
(define-pmacro (logical4 name insn insn1 opc1 opc2 op1 op2 mode)
1276
  (dni name
1277
       (.str name "logical" )
1278
       ((PIPE OS) (IDOC ALU))
1279
       (.str insn " $"op1 ",[$"op2"]")
1280
       (+ opc1 opc2 op1 (f-op-bit2 2) op2)
1281
       (set mode op1 (insn1 mode op1 (mem HI op2)))
1282
       ()
1283
  )
1284
)
1285
(logical4 and2 and and OP1_6 OP2_8 dr sr2 HI)
1286
(logical4 or2 or or OP1_7 OP2_8 dr sr2 HI)
1287
(logical4 xor2 xor xor OP1_5 OP2_8 dr sr2 HI)
1288
(logical4 andb2 andb and OP1_6 OP2_9 drb sr2 QI)
1289
(logical4 orb2 orb or OP1_7 OP2_9 drb sr2 QI)
1290
(logical4 xorb2 xorb xor OP1_5 OP2_9 drb sr2 QI)
1291
 
1292
;and/or/xor register and indirect memory post increment
1293
(define-pmacro (logical5 name insn insn1 opc1 opc2 op1 op2 mode)
1294
  (dni name
1295
       (.str name "logical" )
1296
       ((PIPE OS) (IDOC ALU))
1297
       (.str insn " $"op1 ",[$"op2"+]")
1298
       (+ opc1 opc2 op1 (f-op-bit2 3) op2)
1299
       (sequence ()
1300
           (set mode op1 (insn1 mode op1 (mem HI op2)))
1301
           (set HI op2 (add HI op2 (const 2)))
1302
       )
1303
       ()
1304
  )
1305
)
1306
(logical5 and2i and and OP1_6 OP2_8 dr sr2 HI)
1307
(logical5 or2i or or OP1_7 OP2_8 dr sr2 HI)
1308
(logical5 xor2i xor xor OP1_5 OP2_8 dr sr2 HI)
1309
(logical5 andb2i andb and OP1_6 OP2_9 drb sr2 QI)
1310
(logical5 orb2i orb or OP1_7 OP2_9 drb sr2 QI)
1311
(logical5 xorb2i xorb xor OP1_5 OP2_9 drb sr2 QI)
1312
 
1313
;add/sub register and immediate
1314
(define-pmacro (logical7 name insn insn1 opc1 opc2 op1 op2 mode dir)
1315
  (dni name
1316
       (.str name "arithmetic" )
1317
       ((PIPE OS) (IDOC ALU))
1318
       (.str insn " $"dir"$"op1 ",$"op2)
1319
       (+ opc1 opc2 op1 op2)
1320
       (set (mem HI op1) (insn1 (mem HI op1) op2 ))
1321
       ()
1322
  )
1323
)
1324
(logical7 andpofr and and OP1_6 OP2_2 reg8 upof16 HI "pof")
1325
(logical7 orpofr or or OP1_7 OP2_2 reg8 upof16 HI "pof")
1326
(logical7 xorpofr xor xor OP1_5 OP2_2 reg8 upof16 HI "pof")
1327
(logical7 andbpofr andb and OP1_6 OP2_3 regb8 upof16 QI "pof")
1328
(logical7 orbpofr orb or OP1_7 OP2_3 regb8 upof16 QI "pof")
1329
(logical7 xorbpofr xorb xor OP1_5 OP2_3 regb8 upof16 QI "pof")
1330
 
1331
;add/sub register and immediate
1332
(define-pmacro (logical8 name insn insn1 opc1 opc2 op1 op2 mode dir)
1333
  (dni name
1334
       (.str name "arithmetic" )
1335
       ((PIPE OS) (IDOC ALU))
1336
       (.str insn " $"dir"$"op1 ",$"op2)
1337
       (+ opc1 opc2 op1 op2)
1338
       (set (mem HI op1) (insn1 (mem HI op1) op2 ))
1339
       ()
1340
  )
1341
)
1342
(logical8 andrpofr and and OP1_6 OP2_4 upof16 reg8 HI "pof")
1343
(logical8 orrpofr or or OP1_7 OP2_4 upof16 reg8 HI "pof")
1344
(logical8 xorrpofr xor xor OP1_5 OP2_4 upof16 reg8 HI "pof")
1345
(logical8 andbrpofr andb and OP1_6 OP2_5 upof16 regb8 QI "pof")
1346
(logical8 orbrpofr orb or OP1_7 OP2_5 upof16 regb8 QI "pof")
1347
(logical8 xorbrpofr xorb xor OP1_5 OP2_5 upof16 regb8 QI "pof")
1348
 
1349
;and/or/xor register and direct memory
1350
(define-pmacro (logical6 name insn insn1 opc1 opc2 op1 op2 mode)
1351
  (dni name
1352
       (.str name "arithmetic" )
1353
       ((PIPE OS) (IDOC ALU))
1354
       (.str insn " $"op1 ",$"op2)
1355
       (+ opc1 opc2 op1 op2)
1356
       (set mode op1 (insn1 mode op1 op2))
1357
       ()
1358
  )
1359
)
1360
 
1361
;and/or/xor register and direct memory
1362
(define-pmacro (logical7 name insn insn1 opc1 opc2 op1 op2 mode)
1363
  (dni name
1364
       (.str name "arithmetic" )
1365
       ((PIPE OS) (IDOC ALU))
1366
       (.str insn " $"op1 ",$"op2)
1367
       (+ opc1 opc2 op2 op1)
1368
       (set (mem HI op1) (insn1 (mem HI op1) op2))
1369
       ()
1370
  )
1371
)
1372
(logical6 andrm2 and and OP1_6 OP2_2 regmem8 memgr8 HI)
1373
(logical7 andrm3 and and OP1_6 OP2_4 memgr8 regmem8 HI)
1374
(logical6 andrm and and OP1_6 OP2_2 reg8 memory HI)
1375
(logical7 andrm1 and and OP1_6 OP2_4 memory reg8 HI)
1376
(logical6 orrm3 or or OP1_7 OP2_2 regmem8 memgr8 HI)
1377
(logical7 orrm2 or or OP1_7 OP2_4 memgr8 regmem8 HI)
1378
(logical6 orrm1 or or OP1_7 OP2_2 reg8 memory HI)
1379
(logical7 orrm or or OP1_7 OP2_4 memory reg8 HI)
1380
(logical6 xorrm3 xor xor OP1_5 OP2_2 regmem8 memgr8 HI)
1381
(logical7 xorrm2 xor xor OP1_5 OP2_4 memgr8 regmem8 HI)
1382
(logical6 xorrm1 xor xor OP1_5 OP2_2 reg8 memory HI)
1383
(logical7 xorrm xor xor OP1_5 OP2_4 memory reg8 HI)
1384
(logical6 andbrm2 andb and OP1_6 OP2_3 regbmem8 memgr8 QI)
1385
(logical7 andbrm3 andb and OP1_6 OP2_5 memgr8 regbmem8 QI)
1386
(logical6 andbrm andb and OP1_6 OP2_3 regb8 memory QI)
1387
(logical7 andbrm1 andb and OP1_6 OP2_5 memory regb8 QI)
1388
(logical6 orbrm3 orb or OP1_7 OP2_3 regbmem8 memgr8 QI)
1389
(logical7 orbrm2 orb or OP1_7 OP2_5 memgr8 regbmem8 QI)
1390
(logical6 orbrm1 orb or OP1_7 OP2_3 regb8 memory QI)
1391
(logical7 orbrm orb or OP1_7 OP2_5 memory regb8 QI)
1392
(logical6 xorbrm3 xorb xor OP1_5 OP2_3 regbmem8 memgr8 QI)
1393
(logical7 xorbrm2 xorb xor OP1_5 OP2_5 memgr8 regbmem8 QI)
1394
(logical6 xorbrm1 xorb xor OP1_5 OP2_3 regb8 memory QI)
1395
(logical7 xorbrm xorb xor OP1_5 OP2_5 memory regb8 QI)
1396
 
1397
;****************************************************************
1398
;logical insn
1399
;****************************************************************
1400
;mov registers
1401
(define-pmacro (move name insn opc1 opc2 op1 op2 mode)
1402
  (dni name
1403
       (.str name "mov registers" )
1404
       ((PIPE OS) (IDOC MOVE))
1405
       (.str insn " $"op1 ",$"op2)
1406
       (+ opc1 opc2 op1 op2)
1407
       (set mode op1 op2)
1408
       ()
1409
  )
1410
)
1411
(move movr mov OP1_15 OP2_0 dr sr HI)
1412
(move movrb movb OP1_15 OP2_1 drb srb HI)
1413
 
1414
;mov register and immediate
1415
(define-pmacro (move1 name insn opc1 opc2 op1 op2 mode)
1416
  (dni name
1417
       (.str name "move" )
1418
       ((PIPE OS) (IDOC MOVE))
1419
       (.str insn " $"op1 ",$hash$"op2)
1420
       (+ opc1 opc2 op2 op1)
1421
       (set mode op1 op2)
1422
       ()
1423
  )
1424
)
1425
(move1 movri mov  OP1_14 OP2_0 dri u4 HI)
1426
(move1 movbri movb  OP1_14 OP2_1 srb u4 QI)
1427
 
1428
; MOV Rwn,#data16
1429
(dni movi "move immediate to register"
1430
     ((PIPE OS) (IDOC MOVE))
1431
     "mov $reg8,$hash$uimm16"
1432
     (+ OP1_14 OP2_6 reg8 uimm16)
1433
     (set HI reg8 uimm16)
1434
     ()
1435
)
1436
 
1437
; MOVB reg,#data8
1438
(dni movbi "move immediate to register"
1439
     ((PIPE OS) (IDOC MOVE))
1440
     "movb $regb8,$hash$uimm8"
1441
     (+ OP1_14 OP2_7 regb8 uimm8 (f-op-bit8 0))
1442
     (set QI regb8 uimm8)
1443
     ()
1444
)
1445
 
1446
;move and indirect memory
1447
(define-pmacro (mov2 name insn opc1 opc2 op1 op2 mode)
1448
  (dni name
1449
       (.str name "move" )
1450
       ((PIPE OS) (IDOC MOVE))
1451
       (.str insn " $"op1 ",[$"op2"]")
1452
       (+ opc1 opc2 op1 op2)
1453
       (set mode op1 (mem HI op2))
1454
       ()
1455
  )
1456
)
1457
(mov2 movr2 mov OP1_10 OP2_8 dr sr HI)
1458
(mov2 movbr2 movb OP1_10 OP2_9 drb sr QI)
1459
 
1460
;move and indirect memory
1461
(define-pmacro (mov3 name insn opc1 opc2 op1 op2 mode)
1462
  (dni name
1463
       (.str name "move" )
1464
       ((PIPE OS) (IDOC MOVE))
1465
       (.str insn " [$"op2 "],$"op1)
1466
       (+ opc1 opc2 op1 op2)
1467
       (set mode op1 (mem HI op2))
1468
       ()
1469
  )
1470
)
1471
(mov3 movri2 mov OP1_11 OP2_8 dr sr HI)
1472
(mov3 movbri2 movb OP1_11 OP2_9 drb sr QI)
1473
 
1474
;move and indirect memory
1475
(define-pmacro (mov4 name insn opc1 opc2 op1 op2 mode)
1476
  (dni name
1477
       (.str name "move" )
1478
       ((PIPE OS) (IDOC MOVE))
1479
       (.str insn " [-$"op2 "],$"op1)
1480
       (+ opc1 opc2 op1 op2)
1481
       (sequence HI ()
1482
          (set op1 (sub op2 (const HI 2)))
1483
          (set HI (mem HI op2) op1)
1484
       )
1485
       ()
1486
  )
1487
)
1488
(mov4 movri3 mov OP1_8 OP2_8 dr sr HI)
1489
(mov4 movbri3 movb OP1_8 OP2_9 drb sr QI)
1490
 
1491
;mov register and indirect memory post increment
1492
(define-pmacro (mov5 name insn opc1 opc2 op1 op2 mode)
1493
  (dni name
1494
       (.str name "move" )
1495
       ((PIPE OS) (IDOC MOVE))
1496
       (.str insn " $"op1 ",[$"op2"+]")
1497
       (+ opc1 opc2 op1 op2)
1498
       (sequence ()
1499
           (set mode op1 (mem HI op2))
1500
           (set HI op2 (add HI op2 (const 2)))
1501
       )
1502
       ()
1503
  )
1504
)
1505
(mov5 mov2i mov OP1_9 OP2_8 dr sr HI)
1506
(mov5 movb2i movb OP1_9 OP2_9 drb sr HI)
1507
 
1508
;mov indirect memory
1509
(define-pmacro (mov6 name insn opc1 opc2 op1 op2 mode)
1510
  (dni name
1511
       (.str name "move" )
1512
       ((PIPE OS) (IDOC MOVE))
1513
       (.str insn " [$"op1 "],[$"op2"]")
1514
       (+ opc1 opc2 op1 op2)
1515
       (set HI (mem HI op1) (mem HI op2))
1516
       ()
1517
  )
1518
)
1519
(mov6 mov6i mov OP1_12 OP2_8 dr sr HI)
1520
(mov6 movb6i movb OP1_12 OP2_9 dr sr HI)
1521
 
1522
;mov indirect memory
1523
(define-pmacro (mov7 name insn opc1 opc2 op1 op2 mode)
1524
  (dni name
1525
       (.str name "move" )
1526
       ((PIPE OS) (IDOC MOVE))
1527
       (.str insn " [$"op1 "+],[$"op2"]")
1528
       (+ opc1 opc2 op1 op2)
1529
       (sequence ()
1530
          (set mode (mem mode op1) (mem mode op2))
1531
          (set mode op1 (add mode op1 (const mode 2)))
1532
       )
1533
       ()
1534
  )
1535
)
1536
(mov7 mov7i mov OP1_13 OP2_8 dr sr HI)
1537
(mov7 movb7i movb OP1_13 OP2_9 dr sr HI)
1538
 
1539
;mov indirect memory
1540
(define-pmacro (mov8 name insn opc1 opc2 op1 op2 mode)
1541
  (dni name
1542
       (.str name "move" )
1543
       ((PIPE OS) (IDOC MOVE))
1544
       (.str insn " [$"op1 "],[$"op2"+]")
1545
       (+ opc1 opc2 op1 op2)
1546
       (sequence ()
1547
          (set mode (mem mode op1) (mem mode op2))
1548
          (set mode op2 (add mode op2 (const mode 2)))
1549
       )
1550
       ()
1551
  )
1552
)
1553
(mov8 mov8i mov OP1_14 OP2_8 dr sr HI)
1554
(mov8 movb8i movb OP1_14 OP2_9 dr sr HI)
1555
 
1556
;mov indirect memory
1557
(define-pmacro (mov9 name insn opc1 opc2 op1 op2 mode)
1558
  (dni name
1559
       (.str name "move" )
1560
       ((PIPE OS) (IDOC MOVE))
1561
       (.str insn " $"op1 ",[$"op2"+$hash$"uimm16"]")
1562
       (+ opc1 opc2 op1 op2 uimm16)
1563
       (sequence mode ((mode tmp1))
1564
           (set mode tmp1 (add HI op2 uimm16))
1565
           (set mode op1 (mem HI tmp1))
1566
       )
1567
       ()
1568
  )
1569
)
1570
(mov9 mov9i mov OP1_13 OP2_4 dr sr HI)
1571
(mov9 movb9i movb OP1_15 OP2_4 drb sr QI)
1572
 
1573
;mov indirect memory
1574
(define-pmacro (mov10 name insn opc1 opc2 op1 op2 mode)
1575
  (dni name
1576
       (.str name "move" )
1577
       ((PIPE OS) (IDOC MOVE))
1578
       (.str insn " [$"op2"+$hash$"uimm16 "],$"op1)
1579
       (+ opc1 opc2 op1 op2 uimm16)
1580
       (sequence mode ((mode tmp1))
1581
           (set mode tmp1 (add HI op1 uimm16))
1582
           (set mode (mem HI tmp1) op1)
1583
       )
1584
       ()
1585
  )
1586
)
1587
(mov10 mov10i mov OP1_12 OP2_4 dr sr HI)
1588
(mov10 movb10i movb OP1_14 OP2_4 drb sr QI)
1589
 
1590
;move and indirect memory
1591
(define-pmacro (mov11 name insn opc1 opc2 op1 op2 mode)
1592
  (dni name
1593
       (.str name "move" )
1594
       ((PIPE OS) (IDOC MOVE))
1595
       (.str insn " [$"op1 "],$"op2)
1596
       (+ opc1 opc2 (f-op-lbit4 0) op1 op2)
1597
       (set (mem mode op1) (mem HI op2))
1598
       ()
1599
  )
1600
)
1601
(mov11 movri11 mov OP1_8 OP2_4 src2 memory HI)
1602
(mov11 movbri11 movb OP1_10 OP2_4 src2 memory HI)
1603
 
1604
;move and indirect memory
1605
(define-pmacro (mov12 name insn opc1 opc2 op1 op2 mode)
1606
  (dni name
1607
       (.str name "move" )
1608
       ((PIPE OS) (IDOC MOVE))
1609
       (.str insn " $"op2 ",[$"op1"]")
1610
       (+ opc1 opc2 (f-op-lbit4 0) op1 op2)
1611
       (set (mem HI op2) (mem mode op1))
1612
       ()
1613
  )
1614
)
1615
(mov12 movri12 mov OP1_9 OP2_4 src2 memory HI)
1616
(mov12 movbri12 movb OP1_11 OP2_4 src2 memory HI)
1617
 
1618
(define-pmacro (movemem3 name insn opc1 opc2 op1 op2  dir)
1619
  (dni name
1620
       (.str name "move" )
1621
       ((PIPE OS) (IDOC MOVE))
1622
       (.str insn " $"op1 ",$hash$"dir"$"op2)
1623
       (+ opc1 opc2 op1 op2)
1624
       (set HI op1 op2)
1625
       ()
1626
  )
1627
)
1628
(movemem3 movehm5 mov OP1_14 OP2_6 regoff8 upof16 "pof")
1629
(movemem3 movehm6 mov OP1_14 OP2_6 regoff8 upag16 "pag")
1630
(movemem3 movehm7 mov OP1_14 OP2_6 regoff8 useg16 "segm")
1631
(movemem3 movehm8 mov OP1_14 OP2_6 regoff8 usof16 "sof")
1632
 
1633
(define-pmacro (movemem4 name insn opc1 opc2 op1 op2 dir)
1634
  (dni name
1635
       (.str name "move" )
1636
       ((PIPE OS) (IDOC MOVE))
1637
       (.str insn " $"op1 ",$hash$"dir"$"op2)
1638
       (+ opc1 opc2 op1 op2 (f-op-bit8 0))
1639
       (set QI op1 op2)
1640
       ()
1641
  )
1642
)
1643
(movemem4 movehm9 movb OP1_14 OP2_7 regb8 uimm8 "pof")
1644
(movemem4 movehm10 movb OP1_14 OP2_7 regoff8 uimm8 "pag")
1645
 
1646
(define-pmacro (movemem name insn opc1 opc2 op1 op2 mode dir)
1647
  (dni name
1648
       (.str name "move" )
1649
       ((PIPE OS) (IDOC MOVE))
1650
       (.str insn " $"op1 ",$"dir"$"op2)
1651
       (+ opc1 opc2 op1 op2)
1652
       (set mode op1 (mem HI op2))
1653
       ()
1654
  )
1655
)
1656
(movemem movrmp mov OP1_15 OP2_2 regoff8 upof16 HI "pof")
1657
(movemem movrmp1 movb OP1_15 OP2_3 regb8 upof16 QI "pof")
1658
(movemem movrmp2 mov OP1_15 OP2_2 regoff8 upag16 HI "pag")
1659
(movemem movrmp3 movb OP1_15 OP2_3 regb8 upag16 QI "pag")
1660
 
1661
(define-pmacro (movemem1 name insn opc1 opc2 op1 op2 dir)
1662
  (dni name
1663
       (.str name "move" )
1664
       ((PIPE OS) (IDOC MOVE))
1665
       (.str insn " $"dir"$"op1 ",$"op2)
1666
       (+ opc1 opc2 op2 op1)
1667
       (set (mem HI op1) op2 )
1668
       ()
1669
  )
1670
)
1671
(movemem1 movrmp4 mov OP1_15 OP2_6  upof16 regoff8 "pof")
1672
(movemem1 movrmp5 movb OP1_15 OP2_7 upof16 regb8 "pof")
1673
 
1674
(define-pmacro (movemem2 name insn opc1 opc2 op1 op2 mode dir)
1675
  (dni name
1676
       (.str name "move" )
1677
       ((PIPE OS) (IDOC MOVE))
1678
       (.str insn " $"op1 ",$hash$"dir"$"op2)
1679
       (+ opc1 opc2 op2 op1)
1680
       (set mode op1 op2)
1681
       ()
1682
  )
1683
)
1684
(movemem2 movehm1 mov OP1_14 OP2_0 dri u4 HI "pof")
1685
(movemem2 movehm2 movb OP1_14 OP2_1 srb u4 QI "pof")
1686
(movemem2 movehm3 mov OP1_14 OP2_0 dri u4 HI "pag")
1687
(movemem2 movehm4 movb OP1_14 OP2_1 srb u4 QI "pag")
1688
 
1689
;move register and direct memory
1690
(define-pmacro (move12 name insn opc1 opc2 op1 op2 mode)
1691
  (dni name
1692
       (.str name "move" )
1693
       ((PIPE OS) (IDOC MOVE))
1694
       (.str insn " $"op1 ",$"op2)
1695
       (+ opc1 opc2 op1 op2)
1696
       (set mode op1 (mem HI op2))
1697
       ()
1698
  )
1699
)
1700
 
1701
;move register and direct memory
1702
(define-pmacro (move13 name insn opc1 opc2 op1 op2 mode)
1703
  (dni name
1704
       (.str name "move" )
1705
       ((PIPE OS) (IDOC MOVE))
1706
       (.str insn " $"op1 ",$"op2)
1707
       (+ opc1 opc2 op2 op1)
1708
       (set (mem HI op1) op2)
1709
       ()
1710
  )
1711
)
1712
(move12 mve12 mov OP1_15 OP2_2 regmem8 memgr8 HI)
1713
(move13 mve13 mov OP1_15 OP2_6 memgr8 regmem8 HI)
1714
(move12 mover12 mov OP1_15 OP2_2 reg8 memory HI)
1715
(move13 mvr13 mov OP1_15 OP2_6 memory reg8 HI)
1716
(move12 mver12 movb OP1_15 OP2_3 regbmem8 memgr8 QI)
1717
(move13 mver13 movb OP1_15 OP2_7 memgr8 regbmem8 QI)
1718
(move12 movr12 movb OP1_15 OP2_3 regb8 memory QI)
1719
(move13 movr13 movb OP1_15 OP2_7 memory regb8 QI)
1720
 
1721
; MOVBS Rw,Rb
1722
(dni movbsrr "mov byte register with sign extension to word register"
1723
     ((PIPE OS) (IDOC MOVE))
1724
     "movbs $sr,$drb"
1725
     (+ OP1_13 OP2_0 drb sr)
1726
     (sequence ()
1727
         (if QI (and QI drb (const 128))
1728
                (set HI sr (or HI (const HI 65280) drb)))
1729
         (set HI sr (and HI (const HI 255) drb))
1730
     )
1731
     ()
1732
)
1733
 
1734
; MOVBZ Rw,Rb
1735
(dni movbzrr "mov byte register with zero extension to word register"
1736
     ((PIPE OS) (IDOC MOVE))
1737
     "movbz $sr,$drb"
1738
     (+ OP1_12 OP2_0 drb sr)
1739
     (set HI sr (and HI (const HI 255) drb))
1740
     ()
1741
)
1742
 
1743
; MOVBS reg,POF mem
1744
(dni movbsrpofm "mov memory to byte register"
1745
     ((PIPE OS) (IDOC MOVE))
1746
     "movbs $regmem8,$pof$upof16"
1747
     (+ OP1_13 OP2_2 regmem8 upof16)
1748
     (set QI regmem8 (mem HI upof16))
1749
     ()
1750
)
1751
 
1752
; MOVBS pof,reg
1753
(dni movbspofmr "mov memory to byte register"
1754
     ((PIPE OS) (IDOC MOVE))
1755
     "movbs $pof$upof16,$regbmem8"
1756
     (+ OP1_13 OP2_5 upof16 regbmem8 )
1757
     (set QI  (mem HI upof16) regbmem8)
1758
     ()
1759
)
1760
 
1761
; MOVBZ reg,POF mem
1762
(dni movbzrpofm "mov memory to byte register"
1763
     ((PIPE OS) (IDOC MOVE))
1764
     "movbz $reg8,$pof$upof16"
1765
     (+ OP1_12 OP2_2 reg8 upof16)
1766
     (set QI reg8 (mem HI upof16))
1767
     ()
1768
)
1769
 
1770
; MOVBZ pof,reg
1771
(dni movbzpofmr "mov memory to byte register"
1772
     ((PIPE OS) (IDOC MOVE))
1773
     "movbz $pof$upof16,$regb8"
1774
     (+ OP1_12 OP2_5 upof16 regb8 )
1775
     (set QI  (mem HI upof16) regb8)
1776
     ()
1777
)
1778
 
1779
;move register and direct memory
1780
(define-pmacro (move14 name insn opc1 opc2 op1 op2 )
1781
  (dni name
1782
       (.str name "move" )
1783
       ((PIPE OS) (IDOC MOVE))
1784
       (.str insn " $"op1 ",$"op2)
1785
       (+ opc1 opc2 op1 op2)
1786
       (set HI op1 (and HI (const HI 255) (mem QI op2)))
1787
       ()
1788
  )
1789
)
1790
 
1791
;move register and direct memory
1792
(define-pmacro (move15 name insn opc1 opc2 op1 op2 )
1793
  (dni name
1794
       (.str name "move" )
1795
       ((PIPE OS) (IDOC MOVE))
1796
       (.str insn " $"op1 ",$"op2)
1797
       (+ opc1 opc2 op2 op1)
1798
       (set HI (mem HI op1) (and HI (const HI 255) op2))
1799
       ()
1800
  )
1801
)
1802
(move14 movebs14 movbs OP1_13 OP2_2 regmem8 memgr8 )
1803
(move15 movebs15 movbs OP1_13 OP2_5 memgr8 regbmem8 )
1804
(move14 moverbs14 movbs OP1_13 OP2_2 reg8 memory )
1805
(move15 movrbs15 movbs OP1_13 OP2_5 memory regb8 )
1806
(move14 movebz14 movbz OP1_12 OP2_2 regmem8 memgr8 )
1807
(move15 movebz15 movbz OP1_12 OP2_5 memgr8 regbmem8 )
1808
(move14 moverbz14 movbz OP1_12 OP2_2 reg8 memory )
1809
(move15 movrbz15 movbz OP1_12 OP2_5 memory regb8 )
1810
 
1811
 
1812
;mov registers
1813
(define-pmacro (moveb1 name insn opc1 opc2 op1 op2)
1814
  (dni name
1815
       (.str name "move" )
1816
       ((PIPE OS) (IDOC MOVE))
1817
       (.str insn " $"op2 ",$"op1)
1818
       (+ opc1 opc2 op1 op2)
1819
       (sequence ()
1820
           (if QI (and QI op1 (const 128))
1821
                  (set HI op2 (or HI (const HI 65280) op1)))
1822
           (set HI op2 (and HI (const HI 255) op1))
1823
       )
1824
       ()
1825
  )
1826
)
1827
(moveb1 movrbs movbs OP1_13 OP2_0 drb sr )
1828
(moveb1 movrbz movbz OP1_12 OP2_0 drb sr )
1829
 
1830
 
1831
 
1832
;jump and call insns
1833
;******************************************************************
1834
;Absolute conditional jump
1835
(define-pmacro (jmpabs name insn)
1836
  (dni name
1837
     (.str name "Absolute conditional jump" )
1838
     ((PIPE OS) (IDOC JMP))
1839
     (.str insn " $extcond,$caddr")
1840
     (+ OP1_14 OP2_10 extcond (f-op-bitone 0) bitone bit01 caddr)
1841
     (sequence ((HI tmp1) (HI tmp2))
1842
        (set tmp1 (mem HI caddr))
1843
        (set tmp2 (sub HI pc (mem HI caddr)))
1844
        (if (gt tmp2 (const 0)) (lt tmp2 (const 32)) (eq tmp2 (const 32))
1845
            (set bitone (const 1)))
1846
        (if (lt tmp2 (const 0)) (eq tmp2 (const 0)) (gt tmp2 (const 32))
1847
            (set bitone (const 0)))
1848
        (if (eq extcond (const 1) (ne extcond cc_Z))
1849
             (set bit01 (const 0))
1850
             (set HI pc (mem HI caddr)))
1851
        (if (ne extcond (const 1) (eq extcond cc_Z))
1852
             (set bit01 (const 1))
1853
             (set HI pc (add HI pc (const 2))))
1854
     )
1855
     ()
1856
  )
1857
)
1858
 
1859
(jmpabs jmpa0 jmpa+)
1860
(jmpabs jmpa1 jmpa)
1861
 
1862
; JMPA- cc,caddr
1863
(dni jmpa- "Absolute conditional jump"
1864
     (COND-CTI (PIPE OS) (IDOC JMP))
1865
     "jmpa- $extcond,$caddr"
1866
     (+ OP1_14 OP2_10 extcond (f-op-bitone 0) bitone (f-op-1bit 1) caddr)
1867
     (sequence ((HI tmp1) (HI tmp2))
1868
        (set tmp1 (mem HI caddr))
1869
        (set tmp2 (sub HI pc (mem HI caddr)))
1870
        (if (gt tmp2 (const 0)) (lt tmp2 (const 32)) (eq tmp2 (const 32))
1871
            (set bitone (const 1)))
1872
        (if (lt tmp2 (const 0)) (eq tmp2 (const 0)) (gt tmp2 (const 32))
1873
            (set bitone (const 0)))
1874
        (set HI pc (add HI pc (const 2)))
1875
     )
1876
     ()
1877
)
1878
 
1879
; JMPI cc,[Rwn]
1880
(dni jmpi "Indirect conditional jump"
1881
     (COND-CTI (PIPE OS) (IDOC JMP))
1882
     "jmpi $icond,[$sr]"
1883
     (+ OP1_9 OP2_12 icond sr)
1884
     (sequence ()
1885
        (if (eq icond (const 1))
1886
             (set HI pc (mem HI sr)))
1887
             (set HI pc (add HI pc (const 2)))
1888
     )
1889
     ()
1890
)
1891
 
1892
(define-pmacro (jmprel name insn opc1)
1893
  (dni name
1894
       (.str name "conditional" )
1895
       (COND-CTI (PIPE OS) (IDOC JMP))
1896
       (.str insn " $cond,$rel")
1897
       (+ opc1 OP2_13 rel)
1898
       (sequence ()
1899
           (if (eq cond (const 1))
1900
               (sequence ()
1901
                    (if QI (lt QI rel (const 0))
1902
                           (sequence ()
1903
                                (neg QI rel)
1904
                                (add QI rel (const 1))
1905
                                (mul QI rel (const 2))
1906
                                (set HI pc (sub HI pc rel))
1907
                           ))
1908
                    (set HI pc (add HI pc (mul QI rel (const 2))))
1909
               )
1910
            )
1911
            (set HI pc pc)
1912
       )
1913
       ()
1914
  )
1915
)
1916
 
1917
(jmprel jmpr_nenz jmpr  COND_NE_NZ )
1918
(jmprel jmpr_sgt jmpr  COND_SGT )
1919
(jmprel jmpr_z jmpr  COND_Z )
1920
(jmprel jmpr_v jmpr  COND_V )
1921
(jmprel jmpr_nv jmpr  COND_NV )
1922
(jmprel jmpr_n jmpr  COND_N )
1923
(jmprel jmpr_nn jmpr  COND_NN )
1924
(jmprel jmpr_c jmpr  COND_C )
1925
(jmprel jmpr_nc jmpr  COND_NC )
1926
(jmprel jmpr_eq jmpr  COND_EQ )
1927
(jmprel jmpr_ne jmpr  COND_NE )
1928
(jmprel jmpr_ult jmpr  COND_ULT )
1929
(jmprel jmpr_ule jmpr  COND_ULE )
1930
(jmprel jmpr_uge jmpr  COND_UGE )
1931
(jmprel jmpr_ugt jmpr  COND_UGT )
1932
(jmprel jmpr_sle jmpr  COND_SLE )
1933
(jmprel jmpr_sge jmpr  COND_SGE )
1934
(jmprel jmpr_net jmpr  COND_NET )
1935
(jmprel jmpr_uc jmpr  COND_UC )
1936
(jmprel jmpr_slt jmpr  COND_SLT )
1937
 
1938
 
1939
 
1940
 
1941
; JMPS seg,caddr
1942
(dni jmpseg "absolute inter-segment jump"
1943
     (UNCOND-CTI(PIPE OS) (IDOC JMP))
1944
     "jmps $hash$segm$useg8,$hash$sof$usof16"
1945
     (+ OP1_15 OP2_10 seg usof16)
1946
     (sequence ()
1947
          (if QI (eq BI sgtdisbit (const BI 0))
1948
                 (set QI (reg h-cr 10) useg8))
1949
                 (nop)
1950
          (set HI pc usof16)
1951
     )
1952
     ()
1953
)
1954
 
1955
; JMPS seg,caddr
1956
(dni jmps "absolute inter-segment jump"
1957
     (UNCOND-CTI(PIPE OS) (IDOC JMP))
1958
     "jmps $seg,$caddr"
1959
     (+ OP1_15 OP2_10 seg caddr)
1960
     (sequence ()
1961
          (if QI (eq BI sgtdisbit (const BI 0))
1962
                 (set QI (reg h-cr 10) seg))
1963
                 (nop)
1964
          (set HI pc caddr)
1965
     )
1966
     ()
1967
)
1968
 
1969
 
1970
;relative jump if bit set
1971
;JB bitaddrQ.q,rel
1972
(dni jb "relative jump if bit set"
1973
     ((PIPE OS) (IDOC JMP))
1974
     "jb $genreg$dot$qlobit,$relhi"
1975
     (+ OP1_8 OP2_10 genreg relhi qlobit (f-qhibit 0))
1976
     (sequence ((HI tmp1) (HI tmp2))
1977
          (set HI tmp1 genreg)
1978
          (set HI tmp2 (const 1))
1979
          (sll HI tmp2 qlobit)
1980
          (set HI tmp2 (and tmp1 tmp2))
1981
          (if (eq tmp2 (const 1))
1982
             (sequence ()
1983
                (if QI (lt QI relhi (const 0))
1984
                       (set HI pc (add HI pc (mul QI relhi (const 2)))))
1985
             ))
1986
         (set HI pc (add HI pc (const 4)))
1987
     )
1988
     ()
1989
)
1990
 
1991
;relative jump if bit set and clear bit
1992
;JBC bitaddrQ.q,rel
1993
(dni jbc "relative jump if bit set and clear bit"
1994
     ((PIPE OS) (IDOC JMP))
1995
     "jbc $genreg$dot$qlobit,$relhi"
1996
     (+ OP1_10 OP2_10 genreg relhi qlobit (f-qhibit 0))
1997
     (sequence ((HI tmp1) (HI tmp2))
1998
          (set HI tmp1 genreg)
1999
          (set HI tmp2 (const 1))
2000
          (sll HI tmp2 qlobit)
2001
          (set HI tmp2 (and tmp1 tmp2))
2002
          (if (eq tmp2 (const 1))
2003
             (sequence ()
2004
                (if QI (lt QI relhi (const 0))
2005
                       (set tmp2 (const 1))
2006
                       (set tmp1 genreg)
2007
                       (sll tmp2 qlobit)
2008
                       (inv tmp2)
2009
                       (set HI tmp1(and tmp1 tmp2))
2010
                       (set HI genreg tmp1)
2011
                       (set HI pc (add HI pc (mul QI relhi (const 2)))))
2012
             ))
2013
          (set HI pc (add HI pc (const 4)))
2014
     )
2015
     ()
2016
)
2017
 
2018
;relative jump if bit set
2019
;JNB bitaddrQ.q,rel
2020
(dni jnb "relative jump if bit not set"
2021
     ((PIPE OS) (IDOC JMP))
2022
     "jnb $genreg$dot$qlobit,$relhi"
2023
     (+ OP1_9 OP2_10 genreg relhi qlobit (f-qhibit 0))
2024
     (sequence ((HI tmp1) (HI tmp2))
2025
          (set HI tmp1 genreg)
2026
          (set HI tmp2 (const 1))
2027
          (sll HI tmp2 qlobit)
2028
          (set HI tmp2 (and tmp1 tmp2))
2029
          (if (eq tmp2 (const 0))
2030
             (sequence ()
2031
                (if QI (lt QI relhi (const 0))
2032
                       (set HI pc (add HI pc (mul QI relhi (const 2)))))
2033
             ))
2034
          (set HI pc (add HI pc (const 4)))
2035
     )
2036
     ()
2037
)
2038
 
2039
;relative jump if bit not set and set bit
2040
;JNBS bitaddrQ.q,rel
2041
(dni jnbs "relative jump if bit not set and set bit"
2042
     ((PIPE OS) (IDOC JMP))
2043
     "jnbs $genreg$dot$qlobit,$relhi"
2044
     (+ OP1_11 OP2_10 genreg relhi qlobit (f-qhibit 0))
2045
     (sequence ((HI tmp1) (HI tmp2))
2046
          (set HI tmp1 genreg)
2047
          (set HI tmp2 (const 1))
2048
          (sll HI tmp2 qlobit)
2049
          (set HI tmp2 (and tmp1 tmp2))
2050
          (if (eq tmp2 (const 0))
2051
             (sequence ()
2052
                (if QI (lt QI relhi (const 0))
2053
                       (set tmp2 (const 1))
2054
                       (set tmp1 reg8)
2055
                       (sll tmp2 qbit)
2056
                       (set BI tmp1(or tmp1 tmp2))
2057
                       (set HI reg8 tmp1)
2058
                       (set HI pc (add HI pc (mul QI relhi (const 2)))))
2059
             ))
2060
          (set HI pc (add HI pc (const 4)))
2061
     )
2062
     ()
2063
)
2064
 
2065
 
2066
;Absolute conditional call
2067
(define-pmacro (callabs name insn)
2068
  (dni name
2069
     (.str name "Absolute conditional call" )
2070
     ((PIPE OS) (IDOC JMP))
2071
     (.str insn " $extcond,$caddr")
2072
     (+ OP1_12 OP2_10 extcond (f-op-2bit 0) bit01 caddr)
2073
     (sequence ()
2074
        (if (eq extcond (const 1))
2075
          (set bit01 (const 0))
2076
          (set (reg h-cr 9) (sub HI (reg h-cr 9) (const 2)))
2077
          (set HI (mem HI (reg h-cr 9)) pc)
2078
          (set HI pc (mem HI caddr)))
2079
        (if (ne extcond (const 1))
2080
          (set bit01 (const 1))
2081
          (set HI pc (add HI pc (const 2))))
2082
     )
2083
     ()
2084
  )
2085
)
2086
 
2087
(callabs calla0 calla+)
2088
(callabs calla1 calla)
2089
 
2090
; CALLA- cc,caddr
2091
(dni calla- "Absolute conditional call"
2092
     (COND-CTI (PIPE OS) (IDOC JMP))
2093
     "calla- $extcond,$caddr"
2094
     (+ OP1_12 OP2_10 extcond (f-op-bit3 1) caddr)
2095
     (sequence ()
2096
        (if (eq extcond (const 1))
2097
          (set (reg h-cr 9) (sub HI (reg h-cr 9) (const 2)))
2098
          (set HI (mem HI (reg h-cr 9)) pc)
2099
          (set HI pc (mem HI caddr)))
2100
        (set HI pc (add HI pc (const 2)))
2101
     )
2102
     ()
2103
)
2104
 
2105
; CALLI cc,[Rwn]
2106
(dni calli "indirect subroutine call"
2107
     (COND-CTI (PIPE OS) (IDOC JMP))
2108
     "calli $icond,[$sr]"
2109
     (+ OP1_10 OP2_11 icond sr)
2110
     (sequence ()
2111
         (if (eq icond (const 1))
2112
             (sequence ()
2113
                     (set (reg h-cr 9) (sub HI (reg h-cr 9) (const 2)))
2114
                     (set HI (mem HI (reg h-cr 9)) pc)
2115
                     (set HI pc (mem HI sr))
2116
             )
2117
         )
2118
         (set HI pc (add HI pc (const 2)))
2119
     )
2120
     ()
2121
)
2122
 
2123
; CALLR rel
2124
(dni callr "Call subroutine with PC relative signed 8 bit offset"
2125
     ( COND-CTI (PIPE OS) (IDOC JMP))
2126
     "callr $rel"
2127
     (+ OP1_11 OP2_11 rel)
2128
     (sequence ()
2129
          (set (reg h-cr 9) (sub HI (reg h-cr 9) (const 2)))
2130
          (set HI (mem HI (reg h-cr 9)) pc)
2131
          (sequence ()
2132
                (if QI (lt QI rel (const 0))
2133
                       (sequence ()
2134
                           (neg QI rel)
2135
                           (add QI rel (const 1))
2136
                           (mul QI rel (const 2))
2137
                           (set HI pc (sub HI pc rel))
2138
                       ))
2139
                (set HI pc (add HI pc (mul QI rel (const 2))))
2140
          )
2141
      )
2142
      ()
2143
)
2144
 
2145
 
2146
; CALLS seg,caddr
2147
(dni callseg "call inter-segment subroutine"
2148
     (UNCOND-CTI (PIPE OS) (IDOC JMP))
2149
     "calls $hash$segm$useg8,$hash$sof$usof16"
2150
     (+ OP1_13 OP2_10 useg8 usof16)
2151
     (sequence ()
2152
          (set (reg h-cr 9) (sub HI (reg h-cr 9) (const 2)))
2153
          (set HI (mem HI (reg h-cr 9)) (reg h-cr 10))
2154
          (set (reg h-cr 9) (sub HI (reg h-cr 9) (const 2)))
2155
          (set HI (mem HI (reg h-cr 9)) pc)
2156
          (if QI (eq BI sgtdisbit (const BI 0))
2157
                 (set QI (reg h-cr 10) useg8))
2158
                 (nop)
2159
          (set HI pc usof16)
2160
     )
2161
     ()
2162
)
2163
 
2164
; CALLS seg,caddr
2165
(dni calls "call inter-segment subroutine"
2166
     (UNCOND-CTI (PIPE OS) (IDOC JMP))
2167
     "calls $seg,$caddr"
2168
     (+ OP1_13 OP2_10 seg caddr)
2169
     (sequence ()
2170
          (set (reg h-cr 9) (sub HI (reg h-cr 9) (const 2)))
2171
          (set HI (mem HI (reg h-cr 9)) (reg h-cr 10))
2172
          (set (reg h-cr 9) (sub HI (reg h-cr 9) (const 2)))
2173
          (set HI (mem HI (reg h-cr 9)) pc)
2174
          (if QI (eq BI sgtdisbit (const BI 0))
2175
                 (set QI (reg h-cr 10) seg))
2176
                 (nop)
2177
          (set HI pc caddr)
2178
     )
2179
     ()
2180
)
2181
 
2182
; PCALL reg,caddr
2183
(dni pcall "push word and call absolute subroutine"
2184
       (UNCOND-CTI (PIPE OS) (IDOC JMP))
2185
       "pcall $reg8,$caddr"
2186
       (+ OP1_14 OP2_2 reg8 caddr)
2187
       (sequence ((HI tmp1))
2188
            (set HI tmp1 reg8)
2189
            (set (reg h-cr 9) (sub HI (reg h-cr 9) (const 2)))
2190
            (set HI (mem HI (reg h-cr 9)) tmp1)
2191
            (set (reg h-cr 9) (sub HI (reg h-cr 9) (const 2)))
2192
            (set HI (mem HI (reg h-cr 9)) pc)
2193
            (set HI pc caddr)
2194
       )
2195
       ()
2196
)
2197
 
2198
; TRAP #uimm7
2199
(dni trap "software trap"
2200
       (UNCOND-CTI (PIPE OS) (IDOC JMP))
2201
       "trap $hash$uimm7"
2202
       (+ OP1_9 OP2_11 uimm7 (f-op-1bit 0))
2203
       (sequence ()
2204
            (set (reg h-cr 9) (sub HI (reg h-cr 9) (const 2)))
2205
            (set HI (mem HI (reg h-cr 9)) (reg h-cr 4))
2206
              (if QI (eq BI sgtdisbit (const BI 0))
2207
                     (set (reg h-cr 9) (sub HI (reg h-cr 9) (const 2)))
2208
                     (set HI (mem HI (reg h-cr 9)) (reg h-cr 10) )
2209
              )
2210
              (nop)
2211
            (set HI (reg h-cr 10) (reg h-cr 11))
2212
            (set (reg h-cr 9) (sub HI (reg h-cr 9) (const 2)))
2213
            (set HI (mem HI (reg h-cr 9)) pc)
2214
            (set HI pc (mul QI uimm7 (const 4)))
2215
       )
2216
       ()
2217
)
2218
 
2219
;Return insns
2220
; RET
2221
(dni ret "return from subroutine"
2222
       (UNCOND-CTI (PIPE OS) (IDOC JMP))
2223
       "ret"
2224
       (+ OP1_12 OP2_11 (f-op-bit8 0))
2225
       (sequence ()
2226
           (set HI pc (mem HI (reg h-cr 9)))
2227
           (set (reg h-cr 9) (add HI (reg h-cr 9) (const 2)))
2228
       )
2229
       ()
2230
)
2231
 
2232
; RETS
2233
(dni rets "return from inter-segment sunroutine"
2234
       (UNCOND-CTI (PIPE OS) (IDOC JMP))
2235
       "rets"
2236
       (+ OP1_13 OP2_11 (f-op-bit8 0))
2237
       (sequence ()
2238
           (set HI pc (mem HI (reg h-cr 9)))
2239
           (set (reg h-cr 9) (add HI (reg h-cr 9) (const 2)))
2240
              (if QI (eq BI sgtdisbit (const BI 0))
2241
                     (set HI (reg h-cr 10) (mem HI (reg h-cr 9)))
2242
              )
2243
              (nop)
2244
           (set (reg h-cr 9) (add HI (reg h-cr 9) (const 2)))
2245
       )
2246
       ()
2247
)
2248
 
2249
; RETP reg
2250
(dni retp "return from subroutine and pop word register"
2251
       (UNCOND-CTI (PIPE OS) (IDOC JMP))
2252
       "retp $reg8"
2253
       (+ OP1_14 OP2_11 reg8)
2254
       (sequence ((HI tmp1))
2255
            (set HI pc (mem HI (reg h-cr 9)))
2256
            (set (reg h-cr 9) (add HI (reg h-cr 9) (const 2)))
2257
            (set HI tmp1 (mem HI (reg h-cr 9)))
2258
            (set (reg h-cr 9) (add HI (reg h-cr 9) (const 2)))
2259
            (set HI reg8 tmp1)
2260
       )
2261
       ()
2262
)
2263
 
2264
; RETI
2265
(dni reti "return from ISR"
2266
       (UNCOND-CTI (PIPE OS) (IDOC JMP))
2267
       "reti"
2268
       (+ OP1_15 OP2_11 (f-op-lbit4 8) (f-op-bit4 8))
2269
       (sequence ()
2270
           (set HI pc (mem HI (reg h-cr 9)))
2271
           (set (reg h-cr 9) (add HI (reg h-cr 9) (const 2)))
2272
              (if QI (eq BI sgtdisbit (const BI 0))
2273
                  (sequence ()
2274
                       (set HI (reg h-cr 10) (mem HI (reg h-cr 9)))
2275
                       (set (reg h-cr 9) (add HI (reg h-cr 9) (const 2)))
2276
                  )
2277
              )
2278
              (nop)
2279
           (set HI (reg h-cr 4) (mem HI (reg h-cr 9)))
2280
           (set (reg h-cr 9) (add HI (reg h-cr 9) (const 2)))
2281
       )
2282
       ()
2283
)
2284
 
2285
;stack operation insn
2286
;******************************************************************
2287
; POP reg
2288
(dni pop "restore register from system stack"
2289
     ((PIPE OS) (IDOC MISC))
2290
     "pop $reg8"
2291
     (+ OP1_15 OP2_12 reg8)
2292
     (sequence ((HI tmp1))
2293
           (set HI tmp1 (mem HI (reg h-cr 9)))
2294
           (set (reg h-cr 9) (add HI (reg h-cr 9) (const 2)))
2295
           (set HI reg8 tmp1)
2296
     )
2297
     ()
2298
)
2299
 
2300
; PUSH reg
2301
(dni push "save register on system stack"
2302
     ((PIPE OS) (IDOC MISC))
2303
     "push $reg8"
2304
     (+ OP1_14 OP2_12 reg8)
2305
     (sequence ((HI tmp1))
2306
           (set HI tmp1 reg8)
2307
           (set (reg h-cr 9) (sub HI (reg h-cr 9) (const 2)))
2308
           (set HI (mem HI (reg h-cr 9)) tmp1)
2309
     )
2310
     ()
2311
)
2312
 
2313
;context switching insns
2314
; SCXT reg,#data16
2315
(dni scxti "Push word register on stack and update same with immediate data"
2316
     ((PIPE OS) (IDOC MISC))
2317
     "scxt $reg8,$hash$uimm16"
2318
     (+ OP1_12 OP2_6 reg8 uimm16)
2319
     (sequence ((HI tmp1) (HI tmp2))
2320
         (set HI tmp1 reg8)
2321
         (set HI tmp2 uimm16)
2322
         (sub HI (reg HI h-cr 9) (const 2))
2323
         (set HI (reg HI h-cr 9) tmp1)
2324
         (set HI reg8 tmp2)
2325
     )
2326
     ()
2327
)
2328
 
2329
; SCXT reg,POF mem
2330
(dni scxtrpofm "mov memory to byte register"
2331
     ((PIPE OS) (IDOC MOVE))
2332
     "scxt $reg8,$pof$upof16"
2333
     (+ OP1_13 OP2_6 reg8 upof16)
2334
     (set QI reg8 (mem HI upof16))
2335
     ()
2336
)
2337
 
2338
; SCXT regmem8,memgr8
2339
(dni scxtmg "Push word register on stack and update same with direct memory"
2340
     ((PIPE OS) (IDOC MISC))
2341
     "scxt $regmem8,$memgr8"
2342
     (+ OP1_13 OP2_6 regmem8 memgr8)
2343
     (sequence ((HI tmp1) (HI tmp2))
2344
         (set HI tmp1 regmem8)
2345
         (set HI tmp2 memgr8)
2346
         (sub HI (reg HI h-cr 9) (const 2))
2347
         (set HI (reg HI h-cr 9) tmp1)
2348
         (set HI regmem8 tmp2)
2349
     )
2350
     ()
2351
)
2352
 
2353
; SCXT reg,mem
2354
(dni scxtm "Push word register on stack and update same with direct memory"
2355
     ((PIPE OS) (IDOC MISC))
2356
     "scxt $reg8,$memory"
2357
     (+ OP1_13 OP2_6 reg8 memory)
2358
     (sequence ((HI tmp1) (HI tmp2))
2359
         (set HI tmp1 reg8)
2360
         (set HI tmp2 memory)
2361
         (sub HI (reg HI h-cr 9) (const 2))
2362
         (set HI (reg HI h-cr 9) tmp1)
2363
         (set HI reg8 tmp2)
2364
     )
2365
     ()
2366
)
2367
 
2368
;No operation
2369
; NOP
2370
(dni nop "nop"
2371
     ((PIPE OS) (IDOC MISC))
2372
     "nop"
2373
     (+ OP1_12 OP2_12 (f-op-bit8 0))
2374
     ()
2375
     ()
2376
)
2377
 
2378
;*********system control instructions *********************/
2379
 
2380
(define-pmacro (sysctrl name insn opc1 opc2 op1 op2 op3)
2381
  (dni name
2382
       (.str name "miscellaneous" )
2383
       ((PIPE OS) (IDOC MISC))
2384
       (.str insn )
2385
       (+ opc1 opc2 (f-op-lbit4 op1) (f-op-bit4 op2) (f-data8 op3) (f-op-bit8 op3))
2386
       ()
2387
       ()
2388
  )
2389
)
2390
(sysctrl srstm srst  OP1_11 OP2_7 4 8 183 )
2391
(sysctrl idlem idle  OP1_8 OP2_7 7 8 135)
2392
(sysctrl pwrdnm pwrdn  OP1_9 OP2_7 6 8 151)
2393
(sysctrl diswdtm diswdt  OP1_10 OP2_5 5 10 165)
2394
(sysctrl enwdtm enwdt  OP1_8 OP2_5 7 10 133)
2395
(sysctrl einitm einit  OP1_11 OP2_5 4 10 181)
2396
(sysctrl srvwdtm srvwdt  OP1_10 OP2_7 5 8 167 )
2397
 
2398
;s/w brk
2399
; SBRK
2400
(dni sbrk "sbrk"
2401
     ((PIPE OS) (IDOC MISC))
2402
     "sbrk"
2403
     (+ OP1_8 OP2_12 (f-op-bit8 0))
2404
     ()
2405
     ()
2406
)
2407
 
2408
; atomic sequence
2409
; ATOMIC #irang2
2410
(dni atomic "begin atomic sequence"
2411
     ((PIPE OS) (IDOC SYSC))
2412
     "atomic $hash$uimm2"
2413
     (+ OP1_13 OP2_1 (f-op-lbit2 0) uimm2 (f-op-bit4 0))
2414
     (sequence ((HI count))
2415
          (set HI count uimm2)
2416
          (cond HI
2417
            ((ne HI count (const 0))
2418
            (sequence ()
2419
               (set HI pc (add HI pc (const 2)))
2420
               (set HI count (sub HI count (const 1)))
2421
            ))
2422
          )
2423
          (set HI count (const 0))
2424
      )
2425
      ()
2426
)
2427
 
2428
;extended register sequence
2429
; EXTR #irang2
2430
(dni extr "begin extended register sequence"
2431
     ((PIPE OS) (IDOC SYSC))
2432
     "extr $hash$uimm2"
2433
     (+ OP1_13 OP2_1 (f-op-lbit2 2) uimm2 (f-op-bit4 0))
2434
     (sequence ((HI count))
2435
          (set HI count uimm2)
2436
          (cond HI
2437
            ((ne HI count (const 0))
2438
            (sequence ()
2439
               (set HI pc (add HI pc (const 2)))
2440
               (set HI count (sub HI count (const 1)))
2441
            ))
2442
          )
2443
          (set HI count (const 0))
2444
      )
2445
      ()
2446
)
2447
 
2448
;extended page sequence
2449
; EXTP Rw,#irang2
2450
(dni extp "begin extended page sequence"
2451
     ((PIPE OS) (IDOC SYSC))
2452
     "extp $sr,$hash$uimm2"
2453
     (+ OP1_13 OP2_12 (f-op-lbit2 1) uimm2 sr)
2454
     (sequence ((HI count))
2455
          (set HI count uimm2)
2456
          (cond HI
2457
            ((ne HI count (const 0))
2458
            (sequence ()
2459
               (set HI pc (add HI pc (const 2)))
2460
               (set HI count (sub HI count (const 1)))
2461
            ))
2462
          )
2463
          (set HI count (const 0))
2464
      )
2465
      ()
2466
)
2467
 
2468
;extended page sequence
2469
; EXTP #pag10,#irang2
2470
(dni extp1 "begin extended page sequence"
2471
     ((PIPE OS) (IDOC SYSC))
2472
     "extp $hash$pagenum,$hash$uimm2"
2473
     (+ OP1_13 OP2_7 (f-op-lbit2 1) uimm2 (f-op-bit4 0) pagenum (f-qlobit 0) (f-qlobit2 0))
2474
     (sequence ((HI count))
2475
          (set HI count uimm2)
2476
          (cond HI
2477
            ((ne HI count (const 0))
2478
            (sequence ()
2479
               (set HI pc (add HI pc (const 2)))
2480
               (set HI count (sub HI count (const 1)))
2481
            ))
2482
          )
2483
          (set HI count (const 0))
2484
      )
2485
      ()
2486
)
2487
 
2488
; EXTP #pag10,#irang2
2489
(dni extpg1 "begin extended page sequence"
2490
     ((PIPE OS) (IDOC SYSC))
2491
     "extp $hash$pag$upag16,$hash$uimm2"
2492
     (+ OP1_13 OP2_7 (f-op-lbit2 1) uimm2 (f-op-bit4 0) upag16 )
2493
     (sequence ((HI count))
2494
          (set HI count uimm2)
2495
          (cond HI
2496
            ((ne HI count (const 0))
2497
            (sequence ()
2498
               (set HI pc (add HI pc (const 2)))
2499
               (set HI count (sub HI count (const 1)))
2500
            ))
2501
          )
2502
          (set HI count (const 0))
2503
      )
2504
      ()
2505
)
2506
 
2507
;extended page and register sequence
2508
; EXTPR Rw,#irang2
2509
(dni extpr "begin extended page and register sequence"
2510
     ((PIPE OS) (IDOC SYSC))
2511
     "extpr $sr,$hash$uimm2"
2512
     (+ OP1_13 OP2_12 (f-op-lbit2 3) uimm2 sr)
2513
     (sequence ((HI count))
2514
          (set HI count uimm2)
2515
          (cond HI
2516
            ((ne HI count (const 0))
2517
            (sequence ()
2518
               (set HI pc (add HI pc (const 2)))
2519
               (set HI count (sub HI count (const 1)))
2520
            ))
2521
          )
2522
          (set HI count (const 0))
2523
      )
2524
      ()
2525
)
2526
 
2527
;extended page and register sequence
2528
; EXTPR #pag10,#irang2
2529
(dni extpr1 "begin extended page sequence"
2530
     ((PIPE OS) (IDOC SYSC))
2531
     "extpr $hash$pagenum,$hash$uimm2"
2532
     (+ OP1_13 OP2_7 (f-op-lbit2 3) uimm2 (f-op-bit4 0) pagenum (f-qlobit 0) (f-qlobit2 0))
2533
     (sequence ((HI count))
2534
          (set HI count uimm2)
2535
          (cond HI
2536
            ((ne HI count (const 0))
2537
            (sequence ()
2538
               (set HI pc (add HI pc (const 2)))
2539
               (set HI count (sub HI count (const 1)))
2540
            ))
2541
          )
2542
          (set HI count (const 0))
2543
      )
2544
      ()
2545
)
2546
 
2547
;extended segment sequence
2548
; EXTS Rw,#irang2
2549
(dni exts "begin extended segment sequence"
2550
     ((PIPE OS) (IDOC SYSC))
2551
     "exts $sr,$hash$uimm2"
2552
     (+ OP1_13 OP2_12 (f-op-lbit2 0) uimm2 sr)
2553
     (sequence ((HI count))
2554
          (set HI count uimm2)
2555
          (cond HI
2556
            ((ne HI count (const 0))
2557
            (sequence ()
2558
               (set HI pc (add HI pc (const 2)))
2559
               (set HI count (sub HI count (const 1)))
2560
            ))
2561
          )
2562
          (set HI count (const 0))
2563
      )
2564
      ()
2565
)
2566
 
2567
;extended segment sequence
2568
; EXTS #seg8,#irang2
2569
(dni exts1 "begin extended segment sequence"
2570
     ((PIPE OS) (IDOC SYSC))
2571
     "exts $hash$seghi8,$hash$uimm2"
2572
     (+ OP1_13 OP2_7 (f-op-lbit2 0) uimm2 (f-op-bit4 0) seghi8 (f-op-bit8 0))
2573
     (sequence ((HI count))
2574
          (set HI count uimm2)
2575
          (cond HI
2576
            ((ne HI count (const 0))
2577
            (sequence ()
2578
               (set HI pc (add HI pc (const 2)))
2579
               (set HI count (sub HI count (const 1)))
2580
            ))
2581
          )
2582
          (set HI count (const 0))
2583
      )
2584
      ()
2585
)
2586
 
2587
;extended segment register sequence
2588
; EXTSR Rwm,#irang2
2589
(dni extsr "begin extended segment and register sequence"
2590
     ((PIPE OS) (IDOC SYSC))
2591
     "extsr $sr,$hash$uimm2"
2592
     (+ OP1_13 OP2_12 (f-op-lbit2 2) uimm2 sr)
2593
     (sequence ((HI count))
2594
          (set HI count uimm2)
2595
          (cond HI
2596
            ((ne HI count (const 0))
2597
            (sequence ()
2598
               (set HI pc (add HI pc (const 2)))
2599
               (set HI count (sub HI count (const 1)))
2600
            ))
2601
          )
2602
          (set HI count (const 0))
2603
      )
2604
      ()
2605
)
2606
 
2607
;extended segment register sequence
2608
; EXTSR #pag10,#irang2
2609
(dni extsr1 "begin extended segment and register sequence"
2610
     ((PIPE OS) (IDOC SYSC))
2611
     "extsr $hash$seghi8,$hash$uimm2"
2612
     (+ OP1_13 OP2_7 (f-op-lbit2 2) uimm2 (f-op-bit4 0) seghi8 (f-op-bit8 0))
2613
     (sequence ((HI count))
2614
          (set HI count uimm2)
2615
          (cond HI
2616
            ((ne HI count (const 0))
2617
            (sequence ()
2618
               (set HI pc (add HI pc (const 2)))
2619
               (set HI count (sub HI count (const 1)))
2620
            ))
2621
          )
2622
          (set HI count (const 0))
2623
      )
2624
      ()
2625
)
2626
 
2627
;prioritize register
2628
;PRIOR Rwn,Rwm
2629
(dni prior "add registers"
2630
     ((PIPE OS) (IDOC ALU))
2631
     "prior $dr,$sr"
2632
     (+ OP1_2 OP2_11 dr sr)
2633
     (sequence ((HI count) (HI tmp1) (HI tmp2))
2634
          (set HI count (const 0))
2635
          (set HI tmp1 sr)
2636
          (set HI tmp2 (and tmp1 (const 32768)))
2637
          (cond HI
2638
            ((ne HI tmp2 (const 1)) (ne HI sr (const 0))
2639
               (sll HI tmp1 (const 1))
2640
               (set HI tmp2 (and tmp1 (const 32768)))
2641
               (set HI count (add HI count (const 1)))
2642
            )
2643
           )
2644
           (set HI dr count)
2645
      )
2646
      ()
2647
)
2648
 
2649
 
2650
;bit instructions
2651
;******************************************************************
2652
;bit clear
2653
(define-pmacro (bclear name insn opc1)
2654
  (dni name
2655
     (.str name "bit clear" )
2656
     ((PIPE OS) (IDOC ALU))
2657
     (.str insn " $reg8$dot$qbit")
2658
     (+ opc1 OP2_14 reg8)
2659
     (sequence ((HI tmp1) (HI tmp2))
2660
     (set tmp2 (const 1))
2661
     (set tmp1 reg8)
2662
     (sll tmp2 qbit)
2663
     (inv tmp2)
2664
     (set BI tmp1(and tmp1 tmp2))
2665
     (set HI reg8 tmp1))
2666
     ()
2667
  )
2668
)
2669
 
2670
;clear direct bit
2671
(dni bclr18 "bit logical MOVN"
2672
     ((PIPE OS) (IDOC ALU))
2673
     "bclr $RegNam"
2674
     (+ OP1_11 OP2_14 RegNam)
2675
     (sequence ((HI tmp1) (HI tmp2))
2676
     (set tmp2 (const 1))
2677
     (set tmp1 reg8)
2678
     (sll tmp2 qbit)
2679
     (inv tmp2)
2680
     (set BI tmp1(and tmp1 tmp2))
2681
     (set HI reg8 tmp1))
2682
     ()
2683
)
2684
 
2685
 
2686
(bclear bclr0 bclr  QBIT_0 )
2687
(bclear bclr1 bclr  QBIT_1 )
2688
(bclear bclr2 bclr  QBIT_2 )
2689
(bclear bclr3 bclr  QBIT_3 )
2690
(bclear bclr4 bclr  QBIT_4 )
2691
(bclear bclr5 bclr  QBIT_5 )
2692
(bclear bclr6 bclr  QBIT_6 )
2693
(bclear bclr7 bclr  QBIT_7 )
2694
(bclear bclr8 bclr  QBIT_8 )
2695
(bclear bclr9 bclr  QBIT_9 )
2696
(bclear bclr10 bclr  QBIT_10 )
2697
(bclear bclr11 bclr  QBIT_11 )
2698
(bclear bclr12 bclr  QBIT_12 )
2699
(bclear bclr13 bclr  QBIT_13 )
2700
(bclear bclr14 bclr  QBIT_14 )
2701
(bclear bclr15 bclr  QBIT_15 )
2702
 
2703
;set direct bit
2704
(dni bset19 "bit logical MOVN"
2705
     ((PIPE OS) (IDOC ALU))
2706
     "bset $RegNam"
2707
     (+ OP1_11 OP2_15 RegNam)
2708
     (sequence ((HI tmp1) (HI tmp2))
2709
     (set tmp2 (const 1))
2710
     (set tmp1 reg8)
2711
     (sll tmp2 qbit)
2712
     (set BI tmp1(or tmp1 tmp2))
2713
     (set HI reg8 tmp1))
2714
     ()
2715
)
2716
 
2717
;bit set
2718
(define-pmacro (bitset name insn opc1)
2719
  (dni name
2720
     (.str name "bit set" )
2721
     ((PIPE OS) (IDOC ALU))
2722
     (.str insn " $reg8$dot$qbit")
2723
     (+ opc1 OP2_15 reg8)
2724
     (sequence ((HI tmp1) (HI tmp2))
2725
     (set tmp2 (const 1))
2726
     (set tmp1 reg8)
2727
     (sll tmp2 qbit)
2728
     (set BI tmp1(or tmp1 tmp2))
2729
     (set HI reg8 tmp1))
2730
     ()
2731
  )
2732
)
2733
 
2734
 
2735
(bitset bset0 bset  QBIT_0 )
2736
(bitset bset1 bset  QBIT_1 )
2737
(bitset bset2 bset  QBIT_2 )
2738
(bitset bset3 bset  QBIT_3 )
2739
(bitset bset4 bset  QBIT_4 )
2740
(bitset bset5 bset  QBIT_5 )
2741
(bitset bset6 bset  QBIT_6 )
2742
(bitset bset7 bset  QBIT_7 )
2743
(bitset bset8 bset  QBIT_8 )
2744
(bitset bset9 bset  QBIT_9 )
2745
(bitset bset10 bset  QBIT_10 )
2746
(bitset bset11 bset  QBIT_11 )
2747
(bitset bset12 bset  QBIT_12 )
2748
(bitset bset13 bset  QBIT_13 )
2749
(bitset bset14 bset  QBIT_14 )
2750
(bitset bset15 bset  QBIT_15 )
2751
 
2752
;mov direct bit
2753
;BMOV bitaddrZ.z,bitaddrQ.q
2754
(dni bmov "bit logical MOV"
2755
     ((PIPE OS) (IDOC ALU))
2756
     "bmov $reghi8$dot$qhibit,$reg8$dot$qlobit"
2757
     (+ OP1_4 OP2_10 reg8 reghi8 qhibit qlobit)
2758
     (sequence ((HI tmp1) (HI tmp2) (HI tmp3) (HI tmp4))
2759
     (set HI tmp1 reghi8)
2760
     (set HI tmp2 reg8)
2761
     (set tmp3 (const 1))
2762
     (set tmp4 (const 1))
2763
     (sll tmp3 qlobit)
2764
     (sll tmp4 qhibit)
2765
     (and tmp1 tmp3)
2766
     (and tmp2 tmp4)
2767
     (set BI tmp1 tmp2)
2768
     (set HI reghi8 tmp1)
2769
     (set HI reg8 tmp2))
2770
     ()
2771
)
2772
 
2773
;movn direct bit
2774
;BMOVN bitaddrZ.z,bitaddrQ.q
2775
(dni bmovn "bit logical MOVN"
2776
     ((PIPE OS) (IDOC ALU))
2777
     "bmovn $reghi8$dot$qhibit,$reg8$dot$qlobit"
2778
     (+ OP1_3 OP2_10 reg8 reghi8 qhibit qlobit)
2779
     (sequence ((HI tmp1) (HI tmp2) (HI tmp3) (HI tmp4))
2780
     (set HI tmp1 reghi8)
2781
     (set HI tmp2 reg8)
2782
     (set tmp3 (const 1))
2783
     (set tmp4 (const 1))
2784
     (sll tmp3 qlobit)
2785
     (sll tmp4 qhibit)
2786
     (and tmp1 tmp3)
2787
     (and tmp2 tmp4)
2788
     (inv HI tmp2)
2789
     (set BI tmp1 tmp2)
2790
     (set HI reghi8 tmp1)
2791
     (set HI reg8 tmp2))
2792
     ()
2793
)
2794
 
2795
;and direct bit
2796
;BAND bitaddrZ.z,bitaddrQ.q
2797
(dni band "bit logical AND"
2798
     ((PIPE OS) (IDOC ALU))
2799
     "band $reghi8$dot$qhibit,$reg8$dot$qlobit"
2800
     (+ OP1_6 OP2_10 reg8 reghi8 qhibit qlobit)
2801
     (sequence ((HI tmp1) (HI tmp2) (HI tmp3) (HI tmp4))
2802
     (set HI tmp1 reghi8)
2803
     (set HI tmp2 reg8)
2804
     (set tmp3 (const 1))
2805
     (set tmp4 (const 1))
2806
     (sll tmp3 qlobit)
2807
     (sll tmp4 qhibit)
2808
     (and tmp1 tmp3)
2809
     (and tmp2 tmp4)
2810
     (set BI tmp1(and tmp1 tmp2))
2811
     (set HI reghi8 tmp1)
2812
     (set HI reg8 tmp2))
2813
     ()
2814
)
2815
 
2816
;or direct bit
2817
;BOR bitaddrZ.z,bitaddrQ.q
2818
(dni bor "bit logical OR"
2819
     ((PIPE OS) (IDOC ALU))
2820
     "bor $reghi8$dot$qhibit,$reg8$dot$qlobit"
2821
     (+ OP1_5 OP2_10 reg8 reghi8 qhibit qlobit)
2822
     (sequence ((HI tmp1) (HI tmp2) (HI tmp3) (HI tmp4))
2823
     (set HI tmp1 reghi8)
2824
     (set HI tmp2 reg8)
2825
     (set tmp3 (const 1))
2826
     (set tmp4 (const 1))
2827
     (sll tmp3 qlobit)
2828
     (sll tmp4 qhibit)
2829
     (and tmp1 tmp3)
2830
     (and tmp2 tmp4)
2831
     (set BI tmp1(or tmp1 tmp2))
2832
     (set HI reghi8 tmp1)
2833
     (set HI reg8 tmp2))
2834
     ()
2835
)
2836
 
2837
;xor direct bit
2838
;BXOR bitaddrZ.z,bitaddrQ.q
2839
(dni bxor "bit logical XOR"
2840
     ((PIPE OS) (IDOC ALU))
2841
     "bxor $reghi8$dot$qhibit,$reg8$dot$qlobit"
2842
     (+ OP1_7 OP2_10 reg8 reghi8 qhibit qlobit)
2843
     (sequence ((HI tmp1) (HI tmp2) (HI tmp3) (HI tmp4))
2844
     (set HI tmp1 reghi8)
2845
     (set HI tmp2 reg8)
2846
     (set tmp3 (const 1))
2847
     (set tmp4 (const 1))
2848
     (sll tmp3 qlobit)
2849
     (sll tmp4 qhibit)
2850
     (and tmp1 tmp3)
2851
     (and tmp2 tmp4)
2852
     (set BI tmp1(xor tmp1 tmp2))
2853
     (set HI reghi8 tmp1)
2854
     (set HI reg8 tmp2))
2855
     ()
2856
)
2857
 
2858
;cmp direct bit to bit
2859
;BCMP bitaddrZ.z,bitaddrQ.q
2860
(dni bcmp "bit to bit compare"
2861
     ((PIPE OS) (IDOC ALU))
2862
     "bcmp $reghi8$dot$qhibit,$reg8$dot$qlobit"
2863
     (+ OP1_2 OP2_10 reg8 reghi8 qhibit qlobit)
2864
     (sequence ((HI tmp1) (HI tmp2) (HI tmp3) (HI tmp4))
2865
     (set HI tmp1 reghi8)
2866
     (set HI tmp2 reg8)
2867
     (set tmp3 (const 1))
2868
     (set tmp4 (const 1))
2869
     (sll tmp3 qlobit)
2870
     (sll tmp4 qhibit)
2871
     (and tmp1 tmp3)
2872
     (and tmp2 tmp4)
2873
     (set BI tmp1(xor tmp1 tmp2))
2874
     (set HI reghi8 tmp1)
2875
     (set HI reg8 tmp2))
2876
     ()
2877
)
2878
 
2879
;bit field low byte
2880
;BFLDL op1,op2,op3
2881
(dni bfldl "bit field low byte"
2882
     ((PIPE OS) (IDOC MOVE))
2883
     "bfldl $reg8,$hash$mask8,$hash$datahi8"
2884
     (+ OP1_0 OP2_10 reg8 mask8 datahi8)
2885
     (sequence ((HI tmp1) (QI tmp2) (QI tmp3))
2886
     (set HI tmp1 reg8)
2887
     (set QI tmp2 mask8)
2888
     (set QI tmp3 datahi8)
2889
     (inv QI tmp2)
2890
     (set HI tmp1 (and tmp1 tmp2))
2891
     (set HI tmp1 (or tmp1 tmp3))
2892
     (set HI reg8 tmp1)
2893
     )
2894
     ()
2895
)
2896
 
2897
;bit field high byte
2898
;BFLDH op1,op2,op3
2899
(dni bfldh "bit field high byte"
2900
     ((PIPE OS) (IDOC MOVE))
2901
     "bfldh $reg8,$hash$masklo8,$hash$data8"
2902
     (+ OP1_1 OP2_10 reg8 masklo8 data8)
2903
     (sequence ((HI tmp1) (HI tmp2) (HI tmp3))
2904
             (set HI tmp1 reg8)
2905
             (set QI tmp2 masklo8)
2906
             (set HI tmp3 data8)
2907
             (sll tmp2 (const 8))
2908
             (inv HI tmp2)
2909
             (sll tmp3 (const 8))
2910
             (set HI tmp1 (and tmp1 tmp2))
2911
             (set HI tmp1 (or tmp1 tmp3))
2912
             (set HI reg8 tmp1)
2913
     )
2914
     ()
2915
)
2916
 
2917
;/**********compare instructions******************
2918
 
2919
;Compare register
2920
;CMP Rwn,Rwm
2921
(dni cmpr "compare two registers"
2922
     ((PIPE OS) (IDOC CMP))
2923
     "cmp $src1,$src2"
2924
     (+ OP1_4 OP2_0 src1 src2)
2925
     (set condbit (lt HI src1 src2))
2926
     ()
2927
)
2928
 
2929
;Compare byte register
2930
;CMPB Rbn,Rbm
2931
(dni cmpbr "compare two byte registers"
2932
     ((PIPE OS) (IDOC CMP))
2933
     "cmpb $drb,$srb"
2934
     (+ OP1_4 OP2_1 drb srb)
2935
     (set condbit (lt QI drb srb))
2936
     ()
2937
)
2938
 
2939
(define-pmacro (cmp1 name insn opc1 opc2 op1 op2 mode)
2940
  (dni name
2941
       (.str name "compare" )
2942
       ((PIPE OS) (IDOC CMP))
2943
       (.str insn " $"op1 ",$hash$"op2)
2944
       (+ opc1 opc2 op1 (f-op-bit1 0) op2)
2945
       (set condbit (lt mode op1 op2))
2946
       ()
2947
  )
2948
)
2949
(cmp1 cmpri cmp OP1_4 OP2_8 src1 uimm3 HI)
2950
(cmp1 cmpbri cmpb OP1_4 OP2_9 drb uimm3 QI)
2951
 
2952
; CMP Rwn,#data16
2953
(dni cmpi "compare"
2954
     ((PIPE OS) (IDOC CMP))
2955
     "cmp $reg8,$hash$uimm16"
2956
     (+ OP1_4 OP2_6 reg8 uimm16)
2957
     (set condbit (lt HI reg8 uimm16))
2958
     ()
2959
)
2960
 
2961
; CMPB reg,#data8
2962
(dni cmpbi "compare"
2963
     ((PIPE OS) (IDOC CMP))
2964
     "cmpb $regb8,$hash$uimm8"
2965
     (+ OP1_4 OP2_7 regb8 uimm8 (f-op-bit8 0))
2966
     (set condbit (lt QI regb8 uimm8))
2967
     ()
2968
)
2969
 
2970
;compare reg and indirect memory
2971
(define-pmacro (cmp2 name insn opc1 opc2 op1 op2 mode)
2972
  (dni name
2973
       (.str name "compare" )
2974
       ((PIPE OS) (IDOC CMP))
2975
       (.str insn " $"op1 ",[$"op2"]")
2976
       (+ opc1 opc2 op1 (f-op-bit2 2) op2)
2977
       (set condbit (lt mode op1 op2))
2978
       ()
2979
  )
2980
)
2981
(cmp2 cmpr2 cmp OP1_4 OP2_8 dr sr2 HI)
2982
(cmp2 cmpbr2 cmpb OP1_4 OP2_9 drb sr2 QI)
2983
 
2984
;compare register and indirect memory post increment
2985
(define-pmacro (cmp3 name insn opc1 opc2 op1 op2 mode)
2986
  (dni name
2987
       (.str name "compare" )
2988
       ((PIPE OS) (IDOC CMP))
2989
       (.str insn " $"op1 ",[$"op2"+]")
2990
       (+ opc1 opc2 op1 (f-op-bit2 3) op2)
2991
       (sequence ()
2992
          (set condbit (lt mode op1 op2))
2993
          (set HI op2 (add HI op2 (const 2)))
2994
       )
2995
       ()
2996
  )
2997
)
2998
(cmp3 cmp2i cmp OP1_4 OP2_8 dr sr2 HI)
2999
(cmp3 cmpb2i cmpb OP1_4 OP2_9 drb sr2 QI)
3000
 
3001
;compare register and direct memory
3002
(define-pmacro (cmp4 name insn opc1 opc2 op1 op2 mode)
3003
  (dni name
3004
       (.str name "compare" )
3005
       ((PIPE OS) (IDOC CMP))
3006
       (.str insn " $"op1 ",$pof$"op2)
3007
       (+ opc1 opc2 op1 op2)
3008
       (set condbit (lt HI op1 (mem HI op2)))
3009
       ()
3010
  )
3011
)
3012
(cmp4 cmp04 cmp OP1_4 OP2_2 reg8 upof16 HI)
3013
(cmp4 cmpb4 cmpb OP1_4 OP2_3 regb8 upof16 QI)
3014
 
3015
;compare register and direct memory
3016
(define-pmacro (cmp4 name insn opc1 opc2 op1 op2 mode)
3017
  (dni name
3018
       (.str name "compare" )
3019
       ((PIPE OS) (IDOC CMP))
3020
       (.str insn " $"op1 ",$"op2)
3021
       (+ opc1 opc2 op1 op2)
3022
       (set condbit (lt HI op1 (mem HI op2)))
3023
       ()
3024
  )
3025
)
3026
(cmp4 cmp004 cmp OP1_4 OP2_2 regmem8 memgr8 HI)
3027
(cmp4 cmp0004 cmp OP1_4 OP2_2 reg8 memory HI)
3028
(cmp4 cmpb04 cmpb OP1_4 OP2_3 regbmem8 memgr8 QI)
3029
(cmp4 cmpb004 cmpb OP1_4 OP2_3 regb8 memory QI)
3030
 
3031
;compare register and immediate
3032
(define-pmacro (cmp5 name insn opc1 opc2 op1 op2 mode)
3033
  (dni name
3034
       (.str name "compare" )
3035
       ((PIPE OS) (IDOC CMP))
3036
       (.str insn " $"op1 ",$hash$"op2)
3037
       (+ opc1 opc2 op2 op1)
3038
       (sequence ()
3039
            (set condbit (lt HI op1 op2))
3040
            (set mode op1 (sub HI op1 (const 1)))
3041
       )
3042
       ()
3043
  )
3044
)
3045
(cmp5 cmpd1ri cmpd1  OP1_10 OP2_0 sr uimm4 HI)
3046
(cmp5 cmpd2ri cmpd2  OP1_11 OP2_0 sr uimm4 HI)
3047
(cmp5 cmpi1ri cmpi1  OP1_8 OP2_0 sr uimm4 HI)
3048
(cmp5 cmpi2ri cmpi2  OP1_9 OP2_0 sr uimm4 HI)
3049
(cmp5 cmpd1rim cmpd1  OP1_10 OP2_6 reg8 uimm16 HI)
3050
(cmp5 cmpd2rim cmpd2  OP1_11 OP2_6 reg8 uimm16 HI)
3051
(cmp5 cmpi1rim cmpi1  OP1_8 OP2_6 reg8 uimm16 HI)
3052
(cmp5 cmpi2rim cmpi2  OP1_9 OP2_6 reg8 uimm16 HI)
3053
 
3054
;compare register and direct memory
3055
(define-pmacro (cmp6 name insn opc1 opc2 op1 op2 mode )
3056
  (dni name
3057
       (.str name "compare" )
3058
       ((PIPE OS) (IDOC CMP))
3059
       (.str insn " $"op1 ",$pof$"op2)
3060
       (+ opc1 opc2 op1 op2)
3061
       (sequence ()
3062
            (set condbit (lt HI op1 (mem HI op2)))
3063
            (set mode op1 (sub HI op1 (const 1)))
3064
       )
3065
       ()
3066
  )
3067
)
3068
(cmp6 cmpd1rp cmpd1  OP1_10 OP2_2 reg8 upof16 HI )
3069
(cmp6 cmpd2rp cmpd2  OP1_11 OP2_2 reg8 upof16 HI )
3070
(cmp6 cmpi1rp cmpi1  OP1_8 OP2_2 reg8 upof16 HI )
3071
(cmp6 cmpi2rp cmpi2  OP1_9 OP2_2 reg8 upof16 HI )
3072
 
3073
;compare register and direct memory
3074
(define-pmacro (cmp7 name insn opc1 opc2 op1 op2 mode)
3075
  (dni name
3076
       (.str name "compare" )
3077
       ((PIPE OS) (IDOC CMP))
3078
       (.str insn " $"op1 ",$"op2)
3079
       (+ opc1 opc2 op1 op2)
3080
       (sequence ()
3081
            (set condbit (lt HI op1 (mem HI op2)))
3082
            (set mode op1 (sub HI op1 (const 1)))
3083
       )
3084
       ()
3085
  )
3086
)
3087
(cmp7 cmpd1rm cmpd1  OP1_10 OP2_2 regmem8 memgr8 HI)
3088
(cmp7 cmpd2rm cmpd2  OP1_11 OP2_2 regmem8 memgr8 HI)
3089
(cmp7 cmpi1rm cmpi1  OP1_8 OP2_2 regmem8 memgr8 HI)
3090
(cmp7 cmpi2rm cmpi2  OP1_9 OP2_2 regmem8 memgr8 HI)
3091
(cmp7 cmpd1rmi cmpd1  OP1_10 OP2_2 reg8 memory HI)
3092
(cmp7 cmpd2rmi cmpd2  OP1_11 OP2_2 reg8 memory HI)
3093
(cmp7 cmpi1rmi cmpi1  OP1_8 OP2_2 reg8 memory HI)
3094
(cmp7 cmpi2rmi cmpi2  OP1_9 OP2_2 reg8 memory HI)
3095
 
3096
 
3097
;Shift and rotate insns
3098
;****************************************************************
3099
(define-pmacro (shift name insn insn1 opc1 opc2 op1 op2 mode)
3100
  (dni name
3101
       (.str name "shift" )
3102
       ((PIPE OS) (IDOC ALU))
3103
       (.str insn " $"op1 ",$"op2)
3104
       (+ opc1 opc2 op1 op2)
3105
       (set mode op1 (insn1 mode op1 op2))
3106
       ()
3107
  )
3108
)
3109
(shift shlr shl sll OP1_4 OP2_12 dr sr HI)
3110
(shift shrr shr srl OP1_6 OP2_12 dr sr HI)
3111
(shift rolr rol rol OP1_0 OP2_12 dr sr HI)
3112
(shift rorr ror ror OP1_2 OP2_12 dr sr HI)
3113
(shift ashrr ashr sra OP1_10 OP2_12 dr sr HI)
3114
 
3115
(define-pmacro (shift1 name insn insn1 opc1 opc2 op1 op2 mode)
3116
  (dni name
3117
       (.str name "shift" )
3118
       ((PIPE OS) (IDOC ALU))
3119
       (.str insn " $"op1 ",$hash$"op2)
3120
       (+ opc1 opc2 op2 op1)
3121
       (set mode op1 (insn1 mode op1 op2))
3122
       ()
3123
  )
3124
)
3125
(shift1 shlri shl sll OP1_5 OP2_12 sr uimm4 HI)
3126
(shift1 shrri shr srl OP1_7 OP2_12 sr uimm4 HI)
3127
(shift1 rolri rol rol OP1_1 OP2_12 sr uimm4 HI)
3128
(shift1 rorri ror ror OP1_3 OP2_12 sr uimm4 HI)
3129
(shift1 ashrri ashr sra OP1_11 OP2_12 sr uimm4 HI)

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.