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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-binutils/] [binutils-2.19.1/] [cgen/] [cpu/] [ia32.cpu] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 jlechner
; Intel IA32 CPU description.  -*- Scheme -*-
2
; Copyright (C) 2000, 2009 Red Hat, Inc.
3
; This file is part of CGEN.
4
; See file COPYING.CGEN for details.
5
;
6
; References:
7
;
8
; Intel486 Processor Family, Programmer's Reference Manual, Intel
9
 
10
(define-rtl-version 0 8)
11
 
12
(include "simplify.inc")
13
 
14
; define-arch must appear first
15
 
16
(define-arch
17
  (name ia32) ; name of cpu family
18
  (comment "Intel IA32 (x86)")
19
  (default-alignment unaligned)
20
  (insn-lsb0? #t)
21
  (machs i386 i486 pentium pentium-ii pentium-iii) ; ??? wip
22
  (isas ia32) ; ??? separate 8086 isa?
23
)
24
 
25
; Attributes.
26
 
27
; Instruction set parameters.
28
 
29
(define-isa
30
  (name ia32)
31
 
32
  (default-insn-bitsize 8)
33
 
34
  ; Number of bytes of insn we can initially fetch.
35
  (base-insn-bitsize 8)
36
 
37
  ; Used in computing bit numbers.
38
  (default-insn-word-bitsize 32)
39
 
40
  ; Initial bitnumbers to decode insns by.
41
  (decode-assist (0 1 2 3 4 5 6 7))
42
)
43
 
44
; Cpu family definitions.
45
 
46
(define-cpu
47
  ; cpu names must be distinct from the architecture name and machine names.
48
  ; The "b" suffix stands for "base" and is the convention.
49
  ; The "f" suffix stands for "family" and is the convention.
50
  (name ia32bf)
51
  (comment "Intel x86 base family")
52
  (endian little)
53
  (word-bitsize 32)
54
)
55
 
56
(define-mach
57
  (name pentium-ii)
58
  (comment "Pentium II")
59
  (cpu ia32bf)
60
)
61
 
62
; Model descriptions.
63
 
64
; The meaning of this value is wip but at the moment it's intended to describe
65
; the implementation (i.e. what -mtune=foo does in sparc gcc).
66
; ??? This is intended to be redesigned later.
67
 
68
(define-model
69
  (name pentium-ii)
70
  (comment "Pentium II model")
71
  (mach pentium-ii)
72
  (unit u-exec "Execution Unit" ()
73
        1 1 ; issue done
74
        () ; state
75
        () ; inputs
76
        () ; outputs
77
        () ; profile action (default)
78
        )
79
)
80
 
81
; Instruction fields.
82
 
83
; There currently doesn't exist shorthand macros for CISC ISA's,
84
; so define our own.
85
; DIF: define-ia32-field
86
; DNIF: define-normal-ia32-field
87
 
88
(define-pmacro (dif x-name x-comment x-attrs x-word-offset x-word-length x-start x-length x-mode x-encode x-decode)
89
  (define-ifield
90
    (name x-name)
91
    (comment x-comment)
92
    (.splice attrs (.unsplice x-attrs))
93
    (word-offset x-word-offset)
94
    (word-length x-word-length)
95
    (start x-start)
96
    (length x-length)
97
    (mode x-mode)
98
    (encode x-encode)
99
    (decode x-decode)
100
    )
101
)
102
 
103
(define-pmacro (dnif x-name x-comment x-attrs x-word-offset x-word-length x-start x-length)
104
  (dif x-name x-comment x-attrs x-word-offset x-word-length x-start x-length
105
       UINT #f #f)
106
)
107
 
108
(dnif f-opcode "first insn byte" () 0 8 7 8)
109
 
110
; The mod-r/m byte.
111
(dnif f-mod "mod field of mod-r/m byte" () 8 8 7 2)
112
(dnif f-reg/opcode "reg/opcode field of mod-r/m byte" () 8 8 5 3)
113
(dnif f-r/m "r/m field of mod-r/m byte" () 8 8 2 3)
114
(dsmf f-mod-r/m "entire mod-r/m byte" () (f-mod f-reg/opcode f-r/m))
115
 
116
(dnif f-simm8  "signed 8 bit immediate"  () 8 8 7 8)
117
(dnif f-simm16 "signed 16 bit immediate" () 8 16 15 16)
118
(dnif f-simm32 "signed 32 bit immediate" () 8 32 31 32)
119
 
120
(dnif f-disp8  "signed 8 bit displacement"  () 8 8 7 8)
121
(dnif f-disp16 "signed 16 bit displacement" () 8 16 15 16)
122
(dnif f-disp32 "signed 32 bit displacement" () 8 32 31 32)
123
 
124
(dnif f-rel8  "signed 8 bit pc-relative displacement"  (PCREL-ADDR) 8 8 7 8)
125
(dnif f-rel16 "signed 16 bit pc-relative displacement" (PCREL-ADDR) 8 16 15 16)
126
(dnif f-rel32 "signed 32 bit pc-relative displacement" (PCREL-ADDR) 8 32 31 32)
127
 
128
; The sib byte.
129
(dnif f-sib-ss "sib scale size" () 16 8 7 2)
130
(dnif f-sib-base "sib base reg" () 16 8 5 3)
131
(dnif f-sib-index "sib index reg" () 16 8 2 3)
132
(dsmf f-sib "entire sib byte" () (f-sib-ss f-sib-base f-sib-index))
133
 
134
; Enums.
135
 
136
(define-pmacro (build-hex2 num) (.hex num 2))
137
 
138
; insn-opcode
139
; "00" ... "FF"
140
(define-normal-insn-enum insn-opcode "insn opcode enums" () OP_ f-opcode
141
  (.map .upcase (.map build-hex2 (.iota 256)))
142
)
143
 
144
; Hardware pieces.
145
; These entries list the elements of the raw hardware.
146
; They're also used to provide tables and other elements of the assembly
147
; language.
148
;
149
; ??? Sets of SP have extra-special semantics.
150
 
151
(dnh h-pc "program counter" (PC PROFILE) (pc) () () ())
152
 
153
(define-keyword
154
  (name gr8-names)
155
  (enum-prefix H-GR8-)
156
  (name-prefix "%")
157
  (values (al 0) (cl 1) (dl 2) (bl 3) (ah 4) (ch 5) (dh 6) (bh 7))
158
)
159
 
160
(define-hardware
161
  (name h-gr8)
162
  (comment "8 bit general registers")
163
  (attrs VIRTUAL PROFILE)
164
  (type register QI (8))
165
  (indices extern-keyword gr8-names)
166
  (get (index)
167
       (if (lt index 4)
168
           (reg QI h-gr index)
169
           (bitfield (reg h-gr (sub index 4)) 15 8)))
170
  (set (index newval)
171
       (if (lt index 4)
172
           (set (bitfield (reg h-gr index) 7 8) newval)
173
           (set (bitfield (reg h-gr (sub index 4)) 15 8) newval)))
174
)
175
 
176
(define-keyword
177
  (name gr16-names)
178
  (enum-prefix H-GR16-)
179
  (name-prefix "%")
180
  (values (ax 0) (cx 1) (dx 2) (bx 3) (sp 4) (bp 5) (si 6) (di 7))
181
)
182
 
183
(define-hardware
184
  (name h-gr16)
185
  (comment "16 bit general registers")
186
  (attrs VIRTUAL PROFILE)
187
  (type register HI (8))
188
  (indices extern-keyword gr16-names)
189
  (get (index) (reg HI h-gr index))
190
  (set (index newval) (set (bitfield (reg h-gr index) 15 16) newval))
191
)
192
 
193
(define-keyword
194
  (name gr-names)
195
  (enum-prefix H-GR-)
196
  (name-prefix "%")
197
  (values (eax 0) (ecx 1) (edx 2) (ebx 3) (esp 4) (ebp 5) (esi 6) (edi 7))
198
)
199
 
200
(define-hardware
201
  (name h-gr)
202
  (comment "general registers")
203
  (attrs PROFILE CACHE-ADDR)
204
  (type register SI (8))
205
  (indices extern-keyword gr-names)
206
)
207
 
208
(dsh h-cf "carry flag"    () (register BI))
209
(dsh h-sf "sign flag"     () (register BI))
210
(dsh h-of "overflow flag" () (register BI))
211
(dsh h-zf "zero flag"     () (register BI))
212
 
213
; Instruction Operands.
214
 
215
; M32R specific operand attributes:
216
; - none yet
217
 
218
; Some registers are refered to explicitly.
219
; ??? Might eventually be worth defining them all, but for now we just
220
; define the ones we need.
221
; ??? Another way to do this is to use pmacros.
222
 
223
(dnop al  "%al register"  () h-gr8 0)
224
(dnop ax  "%ax register"  () h-gr16 0)
225
(dnop eax "%eax register" () h-gr 0)
226
 
227
; Registers specified in the Reg/Opcode field of the r/m byte.
228
 
229
(dnop reg8  "8 bit register"  () h-gr8  f-reg/opcode)
230
(dnop reg16 "16 bit register" () h-gr16 f-reg/opcode)
231
(dnop reg32 "32 bit register" () h-gr f-reg/opcode)
232
 
233
; Various numeric operands.
234
 
235
(dnop simm8  "8 bit signed immediate"  () h-sint f-simm8)
236
(dnop simm16 "16 bit signed immediate" () h-sint f-simm16)
237
(dnop simm32 "32 bit signed immediate" () h-sint f-simm32)
238
 
239
(dnop disp8  "8 bit displacement"  () h-sint f-disp8)
240
(dnop disp16 "16 bit displacement" () h-sint f-disp16)
241
(dnop disp32 "32 bit displacement" () h-sint f-disp32)
242
 
243
(dnop rel8  "8 bit displacement"  () h-iaddr f-rel8)
244
(dnop rel16 "16 bit displacement" () h-iaddr f-rel16)
245
(dnop rel32 "32 bit displacement" () h-iaddr f-rel32)
246
 
247
; The condition code registers.
248
 
249
(dnop cf "carry flag"    () h-cf f-nil)
250
(dnop sf "sign flag"     () h-sf f-nil)
251
(dnop of "overflow flag" () h-of f-nil)
252
(dnop zf "zero flag"     () h-zf f-nil)
253
 
254
; ModRM support.
255
 
256
(dnop r/m-reg8  "8 bit register in r/m field"  () h-gr8  f-r/m)
257
(dnop r/m-reg16 "16 bit register in r/m field" () h-gr16 f-r/m)
258
(dnop r/m-reg32 "32 bit register in r/m field" () h-gr f-r/m)
259
 
260
(define-operand
261
  (name mod-r/m-base-reg)
262
  (comment "base register for mod-r/m addressing")
263
  (mode SI)
264
  (type h-gr)
265
  (index f-r/m)
266
)
267
 
268
(define-operand
269
  (name sib-base)
270
  (comment "base register for sib addressing")
271
  (mode SI)
272
  (type h-gr)
273
  (index f-sib-base)
274
)
275
 
276
(define-operand
277
  (name sib-index)
278
  (comment "index register for sib addressing")
279
  (mode SI)
280
  (type h-gr)
281
  (index f-sib-index)
282
)
283
 
284
; The mod-r/m and sib ifields.
285
; These are composed of several ifields and specify a set of choices
286
; (addressing modes) to choose from.
287
 
288
(define-pmacro (diff x-name x-comment x-attrs x-start x-length x-follows x-mode)
289
  "Define an ia32 ifield that follows another ifield."
290
  (define-ifield
291
    (name x-name)
292
    (comment x-comment)
293
    (.splice attrs (.unsplice x-attrs))
294
    (start x-start)
295
    (length x-length)
296
    (follows x-follows)
297
    (mode x-mode)
298
    )
299
)
300
 
301
; These must be defined before they're used and it makes sense to define
302
; the operand with the ifield (rather than follow the usual convention of
303
; defining all ifields first - not that that convention is necessarily the
304
; best).
305
 
306
(dnif f-disp8-@16 "signed 8 bit displacement at offset 16" () 16 8 7 8)
307
(dnop disp8-@16   "signed 8 bit displacement at offset 16" () h-sint f-disp8-@16)
308
 
309
(dnif f-disp32-@16 "signed 32 bit displacement at offset 16" () 16 32 31 32)
310
(dnop disp32-@16   "signed 32 bit displacement at offset 16" () h-sint f-disp32-@16)
311
 
312
(dnif f-disp32-@24 "signed 32 bit displacement at offset 24" () 24 32 31 32)
313
(dnop disp32-@24   "signed 32 bit displacement at offset 24" () h-sint f-disp32-@24)
314
 
315
; The sib operand, used by the mod-r/m operand.
316
 
317
(dndo base+index*1
318
      SI
319
      (sib-base sib-index)
320
      "${sib-base}+${sib-index}"
321
      f-sib
322
      (+ (f-sib-ss 0) sib-base sib-index)
323
      (andif (orif (ne f-mod 0)
324
                   (ne f-sib-base 5))
325
             (ne f-sib-index 4))
326
      (add sib-base sib-index)
327
      () ; no setter
328
)
329
 
330
(dndo base-1
331
      SI
332
      (sib-base)
333
      "${sib-base}"
334
      f-sib
335
      (+ (f-sib-ss 0) sib-base (f-sib-index 4))
336
      (orif (ne f-mod 0)
337
            (ne f-sib-base 5))
338
      sib-base
339
      () ; no setter
340
)
341
 
342
(dndo index*1+disp32
343
      SI
344
      (sib-index disp32)
345
      "${disp32-@24}(${sib-index})"
346
      f-sib
347
      (+ (f-sib-ss 0) (f-sib-base 5) sib-index disp32-@24)
348
      (andif (eq f-mod 0)
349
             (ne f-sib-index 4))
350
      (add sib-index disp32-@24)
351
      () ; no setter
352
)
353
 
354
(dndo disp32-1
355
      SI
356
      (disp32)
357
      "${disp32-@24}"
358
      f-sib
359
      (+ (f-sib-ss 0) (f-sib-base 5) (f-sib-index 4) disp32-@24)
360
      (eq f-mod 0)
361
      disp32-@24
362
      () ; no setter
363
)
364
 
365
(dndo base+index*2
366
      SI
367
      (sib-base sib-index)
368
      "${sib-base}+${sib-index}*2"
369
      f-sib
370
      (+ (f-sib-ss 1) sib-base sib-index)
371
      (andif (orif (ne f-mod 0)
372
                   (ne f-sib-base 5))
373
             (ne f-sib-index 4))
374
      (add sib-base (mul sib-index 2))
375
      () ; no setter
376
)
377
 
378
(dndo base-2
379
      SI
380
      (sib-base)
381
      "${sib-base}"
382
      f-sib
383
      (+ (f-sib-ss 1) sib-base (f-sib-index 4))
384
      ()
385
      sib-base
386
      () ; no setter
387
)
388
 
389
(dndo index*2+disp32
390
      SI
391
      (sib-index disp32)
392
      "${disp32-@24}(${sib-index})"
393
      f-sib
394
      (+ (f-sib-ss 1) (f-sib-base 5) sib-index disp32-@24)
395
      (andif (eq f-mod 0)
396
             (ne f-sib-index 4))
397
      (add (mul sib-index 2) disp32-@24)
398
      () ; no setter
399
)
400
 
401
(dndo disp32-2
402
      SI
403
      (disp32)
404
      "${disp32-@24}"
405
      f-sib
406
      (+ (f-sib-ss 1) (f-sib-base 5) (f-sib-index 4) disp32-@24)
407
      (eq f-mod 0)
408
      disp32-@24
409
      () ; no setter
410
)
411
 
412
(dndo base+index*4
413
      SI
414
      (sib-base sib-index)
415
      "${sib-base}+${sib-index}*4"
416
      f-sib
417
      (+ (f-sib-ss 2) sib-base sib-index)
418
      (andif (orif (ne f-mod 0)
419
                   (ne f-sib-base 5))
420
             (ne f-sib-index 4))
421
      (add sib-base (mul sib-index 4))
422
      () ; no setter
423
)
424
 
425
(dndo base-4
426
      SI
427
      (sib-base)
428
      "${sib-base}"
429
      f-sib
430
      (+ (f-sib-ss 2) sib-base (f-sib-index 4))
431
      ()
432
      sib-base
433
      () ; no setter
434
)
435
 
436
(dndo index*4+disp32
437
      SI
438
      (sib-index disp32)
439
      "${disp32-@24}(${sib-index})"
440
      f-sib
441
      (+ (f-sib-ss 2) (f-sib-base 5) sib-index disp32-@24)
442
      (andif (eq f-mod 0)
443
             (ne f-sib-index 4))
444
      (add (mul sib-index 4) disp32-@24)
445
      () ; no setter
446
)
447
 
448
(dndo disp32-4
449
      SI
450
      (disp32)
451
      "${disp32-@24}"
452
      f-sib
453
      (+ (f-sib-ss 2) (f-sib-base 5) (f-sib-index 4) disp32-@24)
454
      (eq f-mod 0)
455
      disp32-@24
456
      () ; no setter
457
)
458
 
459
(dndo base+index*8
460
      SI
461
      (sib-base sib-index)
462
      "${sib-base}+${sib-index}*8"
463
      f-sib
464
      (+ (f-sib-ss 3) sib-base sib-index)
465
      (andif (orif (ne f-mod 0)
466
                   (ne f-sib-base 5))
467
             (ne f-sib-index 4))
468
      (add sib-base (mul sib-index 8))
469
      () ; no setter
470
)
471
 
472
(dndo base-8
473
      SI
474
      (sib-base)
475
      "${sib-base}"
476
      f-sib
477
      (+ (f-sib-ss 3) sib-base (f-sib-index 4))
478
      ()
479
      sib-base
480
      () ; no setter
481
)
482
 
483
(dndo index*8+disp32
484
      SI
485
      (sib-index disp32)
486
      "${disp32-@24}(${sib-index})"
487
      f-sib
488
      (+ (f-sib-ss 3) (f-sib-base 5) sib-index disp32-@24)
489
      (andif (eq f-mod 0)
490
             (ne f-sib-index 4))
491
      (add (mul sib-index 8) disp32-@24)
492
      () ; no setter
493
)
494
 
495
(dndo disp32-8
496
      SI
497
      (disp32)
498
      "${disp32-@24}"
499
      f-sib
500
      (+ (f-sib-ss 3) (f-sib-base 5) (f-sib-index 4) disp32-@24)
501
      (eq f-mod 0)
502
      disp32-@24
503
      () ; no setter
504
)
505
 
506
; Now define an "anyof" operand that puts it all together.
507
 
508
(define-anyof-operand
509
  (name sib)
510
  (comment "base + scaled-index + displacement")
511
  (mode SI)
512
  ; Each choice must have the same base-ifield.
513
  (choices base+index*1
514
           base-1
515
           index*1+disp32
516
           disp32-1
517
           base+index*2
518
           base-2
519
           index*2+disp32
520
           disp32-2
521
           base+index*4
522
           base-4
523
           index*4+disp32
524
           disp32-4
525
           base+index*8
526
           base-8
527
           index*8+disp32
528
           disp32-8
529
           )
530
)
531
 
532
; Additional ifields/operands used by the mod-r/m byte.
533
; It seems cleaner to define the operand with its ifield so they are.
534
; Maybe the rest should be organized similarily.
535
; Also, the ones that "follow" other ifields must be defined after the latter
536
; has been defined.
537
 
538
(diff f-disp8-follows-sib "disp8 ifield after sib ifields"
539
      () 7 8 sib INT
540
)
541
(dnop disp8-follows-sib "disp8 following sib"
542
      () h-sint f-disp8-follows-sib
543
)
544
 
545
(diff f-disp32-follows-sib "disp32 ifield after sib ifields"
546
      () 31 32 sib INT
547
)
548
(dnop disp32-follows-sib "disp32 following sib"
549
      () h-sint f-disp32-follows-sib
550
)
551
 
552
; The complete mod-r/m operand, used by instructions.
553
; ??? The [] bracketing is for clarity.  Match actual assembler later.
554
; blah blah blah intel vs at&t blah blah blah
555
 
556
(define-pmacro (define-mod-r/m-choices x-mode x-r/m-reg)
557
  (begin
558
    (dndo (.sym @reg- x-mode)
559
          x-mode
560
          (mod-r/m-base-reg)
561
          "[${mod-r/m-base-reg}]"
562
          f-mod-r/m
563
          (+ (f-mod 0) mod-r/m-base-reg)
564
          (andif (ne f-r/m 4) (ne f-r/m 5))
565
          (mem x-mode mod-r/m-base-reg)
566
          ()
567
          )
568
    (dndo (.sym @sib- x-mode)
569
          x-mode
570
          (sib)
571
          "[$sib]"
572
          f-mod-r/m
573
          (+ (f-mod 0) (f-r/m 4) sib)
574
          ()
575
          (mem x-mode sib)
576
          ()
577
          )
578
    (dndo (.sym @disp32- x-mode)
579
          x-mode
580
          (disp32-@16)
581
          "[${disp32-@16}]"
582
          f-mod-r/m
583
          (+ (f-mod 0) (f-r/m 5) disp32-@16)
584
          ()
585
          (mem x-mode disp32-@16)
586
          ()
587
          )
588
    (dndo (.sym @reg+disp8- x-mode)
589
          x-mode
590
          (mod-r/m-base-reg disp8)
591
          "[${disp8-@16}(${mod-r/m-base-reg})]"
592
          f-mod-r/m
593
          (+ (f-mod 1) mod-r/m-base-reg disp8-@16)
594
          (ne f-r/m 4)
595
          (mem x-mode (add mod-r/m-base-reg disp8-@16))
596
          ()
597
          )
598
    (dndo (.sym @sib+disp8- x-mode)
599
          x-mode
600
          (sib disp8-follows-sib)
601
          "[${disp8-follows-sib}($sib)]"
602
          f-mod-r/m
603
          (+ (f-mod 1) (f-r/m 4) sib disp8-follows-sib)
604
          ()
605
          (mem x-mode (add sib disp8-follows-sib))
606
          ()
607
          )
608
    (dndo (.sym @reg+disp32- x-mode)
609
          x-mode
610
          (mod-r/m-base-reg disp32)
611
          "[${disp32-@16}(${mod-r/m-base-reg})]"
612
          f-mod-r/m
613
          (+ (f-mod 2) mod-r/m-base-reg disp32-@16)
614
          (ne f-r/m 4)
615
          (mem x-mode (add mod-r/m-base-reg disp32-@16))
616
          ()
617
          )
618
    (dndo (.sym @sib+disp32- x-mode)
619
          x-mode
620
          (sib disp32-follows-sib)
621
          "[${disp32-follows-sib}($sib)]"
622
          f-mod-r/m
623
          (+ (f-mod 2) (f-r/m 4) sib disp32-follows-sib)
624
          ()
625
          (mem x-mode (add sib disp32-follows-sib))
626
          ()
627
          )
628
    (dndo (.sym reg- x-mode)
629
          x-mode
630
          (x-r/m-reg)
631
          (.str "${" x-r/m-reg "}")
632
          f-mod-r/m
633
          (+ (f-mod 3) x-r/m-reg)
634
          ()
635
          x-r/m-reg
636
          ()
637
          )
638
    )
639
)
640
 
641
(define-pmacro (define-mod-r/m-operand x-name x-comment x-mode x-r/m-reg)
642
  (begin
643
    (define-mod-r/m-choices x-mode x-r/m-reg)
644
    (define-anyof-operand
645
      (name x-name)
646
      (comment x-comment)
647
      (mode x-mode)
648
      ; Each choice must have the same base-ifield.
649
      (choices (.sym @reg- x-mode)
650
               (.sym @sib- x-mode)
651
               (.sym @disp32- x-mode)
652
               (.sym @reg+disp8- x-mode)
653
               (.sym @sib+disp8- x-mode)
654
               (.sym @reg+disp32- x-mode)
655
               (.sym @sib+disp32- x-mode)
656
               (.sym reg- x-mode)
657
               ))
658
    )
659
)
660
 
661
(define-mod-r/m-operand mod-r/m-8  "8 bit mod-r/m value"  QI r/m-reg8)
662
(define-mod-r/m-operand mod-r/m-16 "16 bit mod-r/m value" HI r/m-reg16)
663
(define-mod-r/m-operand mod-r/m-32 "32 bit mod-r/m value" SI r/m-reg32)
664
 
665
; Additional ifields/operands used by instructions.
666
; These "follow" the mod-r/m byte so must be defined afterwards.
667
 
668
(diff f-simm8-follows-mod-r/m-8 "simm8 ifield after mod-r/m-8 ifields"
669
      () 7 8 mod-r/m-8 INT
670
)
671
(dnop simm8-follows-mod-r/m-8 "simm8 following mod-r/m-8"
672
      () h-sint f-simm8-follows-mod-r/m-8
673
)
674
 
675
(diff f-simm16-follows-mod-r/m-16 "simm16 ifield after mod-r/m-16 ifields"
676
      () 15 16 mod-r/m-16 INT
677
)
678
(dnop simm16-follows-mod-r/m-16 "simm16 following mod-r/m-16"
679
      () h-sint f-simm16-follows-mod-r/m-16
680
)
681
 
682
(diff f-simm32-follows-mod-r/m-32 "simm32 ifield after mod-r/m-32 ifields"
683
      () 31 32 mod-r/m-32 INT
684
)
685
(dnop simm32-follows-mod-r/m-32 "simm32 following mod-r/m-32"
686
      () h-sint f-simm32-follows-mod-r/m-32
687
)
688
 
689
(diff f-simm8-follows-mod-r/m-16 "simm8 ifield after mod-r/m-16 ifields"
690
      () 7 8 mod-r/m-16 INT
691
)
692
(dnop simm8-follows-mod-r/m-16 "simm8 following mod-r/m-16"
693
      () h-sint f-simm8-follows-mod-r/m-16
694
)
695
 
696
(diff f-simm8-follows-mod-r/m-32 "simm8 ifield after mod-r/m-32 ifields"
697
      () 7 8 mod-r/m-32 INT
698
)
699
(dnop simm8-follows-mod-r/m-32 "simm8 following mod-r/m-32"
700
      () h-sint f-simm8-follows-mod-r/m-32
701
)
702
 
703
; Some subroutines, to simplify the semantic specs.
704
 
705
(define-pmacro (define-arith-subr x-name x-mode x-fn x-set-cc-fn)
706
  (define-subr
707
    (name x-name)
708
    (mode VOID)
709
    (args ((x-mode dst) (x-mode src1) (x-mode src2)))
710
    (code (sequence ((x-mode arg1)
711
                     (x-mode arg2)
712
                     (x-mode result))
713
                    (set arg1 src1)
714
                    (set arg2 src2)
715
                    (set result (x-fn arg1 arg2))
716
                    (set dst result)
717
                    (x-set-cc-fn result arg1 arg2)))
718
    )
719
)
720
 
721
(define-arith-subr add-QI QI add set-add-cc)
722
(define-arith-subr add-HI HI add set-add-cc)
723
(define-arith-subr add-SI SI add set-add-cc)
724
 
725
; Instruction definitions.
726
 
727
; IA32 specific instruction attributes:
728
; - none yet
729
 
730
(dni nop
731
     "nop"
732
     ()
733
     "nop"
734
     (+ OP_90)
735
     (nop)
736
     ()
737
)
738
 
739
; Add, subtract.
740
;
741
; ??? Insn naming puts destination before addend.  Ok?
742
 
743
(dni add-al-simm8
744
     "add 8 bit signed immediate to %al"
745
     ()
746
     "FIXME"
747
     (+ OP_04 simm8)
748
     (sequence ()
749
               (set al (add al simm8))
750
               ; ??? condition codes
751
               )
752
     ()
753
)
754
 
755
(dni add-ax-simm16
756
     "add 16 bit signed immediate to %ax"
757
     ()
758
     "FIXME"
759
     ; ??? Need something like ifield assertions to distinguish from
760
     ; 32 bit case.
761
     (+ OP_05 simm16)
762
     (sequence ()
763
               (set ax (add ax simm16))
764
               ; ??? condition codes
765
               )
766
     ()
767
)
768
 
769
(dni add-eax-simm32
770
     "add 32 bit signed immediate to %eax"
771
     ()
772
     "FIXME"
773
     (+ OP_05 simm32)
774
     (sequence ()
775
               (set eax (add eax simm32))
776
               ; ??? condition codes
777
               )
778
     ()
779
)
780
 
781
(dni add-r/m8-simm8
782
     "add 8 bit immediate"
783
     ()
784
     "FIXME"
785
     (+ OP_80 mod-r/m-8 simm8-follows-mod-r/m-8 (f-reg/opcode 0))
786
     (sequence ()
787
               (set mod-r/m-8 (add mod-r/m-8 simm8-follows-mod-r/m-8))
788
               ; ??? condition codes
789
               )
790
     ()
791
)
792
 
793
(dni add-r/m16-simm16
794
     "add 16 bit immediate"
795
     ()
796
     "FIXME"
797
     ; ??? Need something akin to ifield-assertions to distinguish from
798
     ; 32 bit version.
799
     (+ OP_81 mod-r/m-16 simm16-follows-mod-r/m-16 (f-reg/opcode 0))
800
     (sequence ()
801
               (set mod-r/m-16 (add mod-r/m-16 simm16-follows-mod-r/m-16))
802
               ; ??? condition codes
803
               )
804
     ()
805
)
806
 
807
(dni add-r/m32-simm32
808
     "add 32 bit immediate"
809
     ()
810
     "FIXME"
811
     (+ OP_81 mod-r/m-32 simm32-follows-mod-r/m-32 (f-reg/opcode 0))
812
     (sequence ()
813
               (set mod-r/m-32 (add mod-r/m-32 simm32-follows-mod-r/m-32))
814
               ; ??? condition codes
815
               )
816
     ()
817
)
818
 
819
(dni add-r/m16-simm8
820
     "add 8 bit signed immediate to 16 bit value"
821
     ()
822
     "FIXME"
823
     ; ??? Need something akin to ifield-assertions to distinguish from
824
     ; 32 bit version.
825
     (+ OP_83 mod-r/m-16 simm8-follows-mod-r/m-16 (f-reg/opcode 0))
826
     (sequence ()
827
               (set mod-r/m-16 (add mod-r/m-16 (ext HI simm8-follows-mod-r/m-16)))
828
               ; ??? condition codes
829
               )
830
     ()
831
)
832
 
833
(dni add-r/m32-simm8
834
     "add 8 bit signed immediate to 32 bit value"
835
     ()
836
     "FIXME"
837
     (+ OP_83 mod-r/m-32 simm8-follows-mod-r/m-32 (f-reg/opcode 0))
838
     (sequence ()
839
               (set mod-r/m-32 (add mod-r/m-32 (ext SI simm8-follows-mod-r/m-32)))
840
               ; ??? condition codes
841
               )
842
     ()
843
)
844
 
845
(dni add-r/m8-reg8
846
     "add 8 bit reg to 8 bit r/m"
847
     ()
848
     "FIXME"
849
     (+ OP_00 mod-r/m-8 reg8)
850
     (sequence ()
851
               (set mod-r/m-8 (add mod-r/m-8 reg8))
852
               ; ??? condition codes
853
               )
854
     ()
855
)
856
 
857
(dni add-r/m16-reg16
858
     "add 16 bit reg to 16 bit r/m"
859
     ()
860
     "FIXME"
861
     ; ??? Need something akin to ifield-assertions to distinguish from
862
     ; 32 bit version.
863
     (+ OP_01 mod-r/m-16 reg16)
864
     (sequence ()
865
               (set mod-r/m-16 (add mod-r/m-16 reg16))
866
               ; ??? condition codes
867
               )
868
     ()
869
)
870
 
871
(dni add-r/m32-reg32
872
     "add 32 bit reg to 32 bit r/m"
873
     ()
874
     "FIXME"
875
     (+ OP_01 mod-r/m-32 reg32)
876
     (sequence ()
877
               (set mod-r/m-32 (add mod-r/m-32 reg32))
878
               ; ??? condition codes
879
               )
880
     ()
881
)
882
 
883
(dni add-reg8-r/m8
884
     "add 8 bit r/m to 8 bit reg"
885
     ()
886
     "FIXME"
887
     (+ OP_02 mod-r/m-8 reg8)
888
     (sequence ()
889
               (set reg8 (add reg8 mod-r/m-8))
890
               ; ??? condition codes
891
               )
892
     ()
893
)
894
 
895
(dni add-reg16-r/m16
896
     "add 16 bit r/m to 16 bit reg"
897
     ()
898
     "FIXME"
899
     ; ??? Need something akin to ifield-assertions to distinguish from
900
     ; 32 bit version.
901
     (+ OP_03 mod-r/m-16 reg16)
902
     (sequence ()
903
               (set reg16 (add reg16 mod-r/m-16))
904
               ; ??? condition codes
905
               )
906
     ()
907
)
908
 
909
(dni add-reg32-r/m32
910
     "add 32 bit r/m to 32 bit reg"
911
     ()
912
     "FIXME"
913
     (+ OP_03 mod-r/m-32 reg32)
914
     (sequence ()
915
               (set reg32 (add reg32 mod-r/m-32))
916
               ; ??? condition codes
917
               )
918
     ()
919
)

powered by: WebSVN 2.1.0

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