1 /* $NetBSD: db_instruction.h,v 1.4 1997/09/16 22:53:32 thorpej Exp $ */
4 * Mach Operating System
5 * Copyright (c) 1993,1992 Carnegie Mellon University
8 * Permission to use, copy, modify and distribute this software and its
9 * documentation is hereby granted, provided that both the copyright
10 * notice and this permission notice appear in all copies of the
11 * software, derivative works or modified versions, and any portions
12 * thereof, and that both notices appear in supporting documentation.
14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
15 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
16 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18 * Carnegie Mellon requests users of this software to return to
20 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
21 * School of Computer Science
22 * Carnegie Mellon University
23 * Pittsburgh PA 15213-3890
25 * any improvements or extensions that they make and grant Carnegie Mellon
26 * the rights to redistribute these changes.
32 * File: alpha_instruction.h
33 * Author: Alessandro Forin, Carnegie Mellon University
36 * Alpha Instruction set definition
38 * Reference: "Alpha System Reference Manual", V4.0, April 1991
42 #ifndef _ALPHA_INSTRUCTION_H_
43 #define _ALPHA_INSTRUCTION_H_ 1
45 #if !defined(ASSEMBLER)
48 * All instructions are in one of five formats:
49 * Memory, Branch, Operate, Floating-point Operate, PAL
51 * One minor departure from DEC's conventions is we use names
52 * for registers that are more akin their software use, e.g.
53 * rather then bluntly call them Ra/Rb/Rc we make clear which
54 * one is a source (Rs) and which one is a destination (Rd).
55 * When a second source register is defined we call it Rt.
61 * All instructions are 32 bits wide
66 * Generic instruction pseudo format; look at
67 * opcode to see how to interpret the rest.
75 * Memory instructions contain a 16 bit
76 * signed immediate value and two register
80 signed short displacement;
87 * Branch instruction contain a 21 bit offset,
88 * which is sign-extended, shifted and combined
89 * with the PC to form a 64 bit destination address.
91 * In computed jump instructions the opcode is further
92 * specified in the offset field, the rest of it is
93 * used as branch target hint. The destination of the
94 * jump is the source register.
97 signed int displacement : 21;
103 signed int hint : 14;
112 signed int offset : 16;
119 * Operate instructions are of two types, with
120 * a second source register or with a literal
121 * specifier. Bit 12 sez which is which.
131 } operate_generic_format;
140 } operate_reg_format;
149 } operate_lit_format;
153 * Floating point operate instruction are quite
154 * uniform in the encoding. As for the semantics..
166 * PAL instructions just define the major opcode
170 unsigned function : 26,
176 #endif /* !defined(ASSEMBLER) */
180 * Encoding of regular instructions (Appendix C op cit)
184 /* OPCODE, bits 26..31 */
186 #define op_pal 0x00 /* see PAL sub-table */
191 #define op_ldq_u 0x0b
195 #define op_stq_u 0x0f
197 #define op_arit 0x10 /* see ARIT sub-table */
198 #define op_logical 0x11 /* see LOGICAL sub-table */
199 #define op_bit 0x12 /* see BIT sub-table */
200 #define op_mul 0x13 /* see MUL sub-table */
202 #define op_vax_float 0x15 /* see FLOAT sub-table */
203 #define op_ieee_float 0x16 /* see FLOAT sub-table */
204 #define op_any_float 0x17 /* see FLOAT sub-table */
206 #define op_special 0x18 /* see SPECIAL sub-table */
207 #define op_pal19 0x19 /* reserved for pal code */
208 #define op_j 0x1a /* see JUMP sub-table */
209 #define op_pal1b 0x1b /* reserved for pal code */
210 #define op_intmisc 0x1c /* see INTMISC sub-table */
211 #define op_pal1d 0x1d /* reserved for pal code */
212 #define op_pal1e 0x1e /* reserved for pal code */
213 #define op_pal1f 0x1f /* reserved for pal code */
225 #define op_ldl_l 0x2a
226 #define op_ldq_l 0x2b
229 #define op_stl_c 0x2e
230 #define op_stq_c 0x2f
249 /* PAL, "function" opcodes (bits 0..25) */
251 * What we will implement is TBD. These are the unprivileged ones
252 * that we probably have to support for compat reasons.
255 /* See <machine/pal.h> */
257 /* ARIT, "function" opcodes (bits 5..11) */
260 #define op_s4addl 0x02
262 #define op_s4subl 0x0b
263 #define op_cmpbge 0x0f
264 #define op_s8addl 0x12
265 #define op_s8subl 0x1b
266 #define op_cmpult 0x1d
268 #define op_s4addq 0x22
270 #define op_s4subq 0x2b
271 #define op_cmpeq 0x2d
272 #define op_s8addq 0x32
273 #define op_s8subq 0x3b
274 #define op_cmpule 0x3d
275 #define op_addl_v 0x40
276 #define op_subl_v 0x49
277 #define op_cmplt 0x4d
278 #define op_addq_v 0x60
279 #define op_subq_v 0x69
280 #define op_cmple 0x6d
283 /* LOGICAL, "function" opcodes (bits 5..11) */
286 #define op_andnot 0x08 /* bic */
287 #define op_cmovlbs 0x14
288 #define op_cmovlbc 0x16
289 #define op_or 0x20 /* bis */
290 #define op_cmoveq 0x24
291 #define op_cmovne 0x26
292 #define op_ornot 0x28
294 #define op_cmovlt 0x44
295 #define op_cmovge 0x46
296 #define op_xornot 0x48 /* eqv */
297 #define op_amask 0x61
298 #define op_cmovle 0x64
299 #define op_cmovgt 0x66
300 #define op_implver 0x6c
302 /* BIT, "function" opcodes (bits 5..11) */
304 #define op_mskbl 0x02
305 #define op_extbl 0x06
306 #define op_insbl 0x0b
307 #define op_mskwl 0x12
308 #define op_extwl 0x16
309 #define op_inswl 0x1b
310 #define op_mskll 0x22
311 #define op_extll 0x26
312 #define op_insll 0x2b
314 #define op_zapnot 0x31
315 #define op_mskql 0x32
317 #define op_extql 0x36
319 #define op_insql 0x3b
321 #define op_mskwh 0x52
322 #define op_inswh 0x57
323 #define op_extwh 0x5a
324 #define op_msklh 0x62
325 #define op_inslh 0x67
326 #define op_extlh 0x6a
327 #define op_extqh 0x7a
328 #define op_insqh 0x77
329 #define op_mskqh 0x72
331 /* MUL, "function" opcodes (bits 5..11) */
334 #define op_mulq_v 0x60
335 #define op_mull_v 0x40
336 #define op_umulh 0x30
340 /* SPECIAL, "displacement" opcodes (bits 0..15) */
342 #define op_draint 0x0000
344 #define op_fetch 0x8000
345 #define op_fetch_m 0xa000
346 #define op_rpcc 0xc000
350 /* JUMP, "action" opcodes (bits 14..15) */
357 /* INTMISC, "function" opcodes (operate format) */
359 #define op_sextb 0x00
360 #define op_sextw 0x01
361 #define op_ctpop 0x30
365 #define op_unpkbw 0x34
366 #define op_unpkbl 0x35
369 #define op_minsb8 0x38
370 #define op_minsw4 0x39
371 #define op_minub8 0x3a
372 #define op_minuw4 0x3b
373 #define op_maxub8 0x3c
374 #define op_maxuw4 0x3d
375 #define op_maxsb8 0x3e
376 #define op_maxsw4 0x3f
377 #define op_ftoit 0x70
378 #define op_ftois 0x78
382 * Encoding of floating point instructions (pagg. C-5..6 op cit)
384 * Load and store operations use opcodes op_ldf..op_stt
387 /* any FLOAT, "function" opcodes (bits 5..11) */
389 #define op_cvtlq 0x010
390 #define op_cpys 0x020
391 #define op_cpysn 0x021
392 #define op_cpyse 0x022
393 #define op_mt_fpcr 0x024
394 #define op_mf_fpcr 0x025
395 #define op_fcmoveq 0x02a
396 #define op_fcmovne 0x02b
397 #define op_fcmovlt 0x02c
398 #define op_fcmovge 0x02d
399 #define op_fcmovle 0x02e
400 #define op_fcmovgt 0x02f
401 #define op_cvtql 0x030
402 #define op_cvtql_v 0x130
403 #define op_cvtql_sv 0x330
406 /* ieee FLOAT, "function" opcodes (bits 5..11) */
408 #define op_adds_c 0x000
409 #define op_subs_c 0x001
410 #define op_muls_c 0x002
411 #define op_divs_c 0x003
412 #define op_addt_c 0x020
413 #define op_subt_c 0x021
414 #define op_mult_c 0x022
415 #define op_divt_c 0x023
416 #define op_cvtts_c 0x02c
417 #define op_cvttq_c 0x02f
418 #define op_cvtqs_c 0x03c
419 #define op_cvtqt_c 0x03e
420 #define op_adds_m 0x040
421 #define op_subs_m 0x041
422 #define op_muls_m 0x042
423 #define op_divs_m 0x043
424 #define op_addt_m 0x060
425 #define op_subt_m 0x061
426 #define op_mult_m 0x062
427 #define op_divt_m 0x063
428 #define op_cvtts_m 0x06c
429 #define op_cvtqs_m 0x07c
430 #define op_cvtqt_m 0x07e
431 #define op_adds 0x080
432 #define op_subs 0x081
433 #define op_muls 0x082
434 #define op_divs 0x083
435 #define op_addt 0x0a0
436 #define op_subt 0x0a1
437 #define op_mult 0x0a2
438 #define op_divt 0x0a3
439 #define op_cmptun 0x0a4
440 #define op_cmpteq 0x0a5
441 #define op_cmptlt 0x0a6
442 #define op_cmptle 0x0a7
443 #define op_cvtts 0x0ac
444 #define op_cvttq 0x0af
445 #define op_cvtqs 0x0bc
446 #define op_cvtqt 0x0be
447 #define op_adds_d 0x0c0
448 #define op_subs_d 0x0c1
449 #define op_muls_d 0x0c2
450 #define op_divs_d 0x0c3
451 #define op_addt_d 0x0e0
452 #define op_subt_d 0x0e1
453 #define op_mult_d 0x0e2
454 #define op_divt_d 0x0e3
455 #define op_cvtts_d 0x0ec
456 #define op_cvtqs_d 0x0fc
457 #define op_cvtqt_d 0x0fe
458 #define op_adds_uc 0x100
459 #define op_subs_uc 0x101
460 #define op_muls_uc 0x102
461 #define op_divs_uc 0x103
462 #define op_addt_uc 0x120
463 #define op_subt_uc 0x121
464 #define op_mult_uc 0x122
465 #define op_divt_uc 0x123
466 #define op_cvtts_uc 0x12c
467 #define op_cvttq_vc 0x12f
468 #define op_adds_um 0x140
469 #define op_subs_um 0x141
470 #define op_muls_um 0x142
471 #define op_divs_um 0x143
472 #define op_addt_um 0x160
473 #define op_subt_um 0x161
474 #define op_mult_um 0x162
475 #define op_divt_um 0x163
476 #define op_cvtts_um 0x16c
477 #define op_adds_u 0x180
478 #define op_subs_u 0x181
479 #define op_muls_u 0x182
480 #define op_divs_u 0x183
481 #define op_addt_u 0x1a0
482 #define op_subt_u 0x1a1
483 #define op_mult_u 0x1a2
484 #define op_divt_u 0x1a3
485 #define op_cvtts_u 0x1ac
486 #define op_cvttq_v 0x1af
487 #define op_adds_ud 0x1c0
488 #define op_subs_ud 0x1c1
489 #define op_muls_ud 0x1c2
490 #define op_divs_ud 0x1c3
491 #define op_addt_ud 0x1e0
492 #define op_subt_ud 0x1e1
493 #define op_mult_ud 0x1e2
494 #define op_divt_ud 0x1e3
495 #define op_cvtts_ud 0x1ec
496 #define op_adds_suc 0x500
497 #define op_subs_suc 0x501
498 #define op_muls_suc 0x502
499 #define op_divs_suc 0x503
500 #define op_addt_suc 0x520
501 #define op_subt_suc 0x521
502 #define op_mult_suc 0x522
503 #define op_divt_suc 0x523
504 #define op_cvtts_suc 0x52c
505 #define op_cvttq_svc 0x52f
506 #define op_adds_sum 0x540
507 #define op_subs_sum 0x541
508 #define op_muls_sum 0x542
509 #define op_divs_sum 0x543
510 #define op_addt_sum 0x560
511 #define op_subt_sum 0x561
512 #define op_mult_sum 0x562
513 #define op_divt_sum 0x563
514 #define op_cvtts_sum 0x56c
515 #define op_adds_su 0x580
516 #define op_subs_su 0x581
517 #define op_muls_su 0x582
518 #define op_divs_su 0x583
519 #define op_addt_su 0x5a0
520 #define op_subt_su 0x5a1
521 #define op_mult_su 0x5a2
522 #define op_divt_su 0x5a3
523 #define op_cmptun_su 0x5a4
524 #define op_cmpteq_su 0x5a5
525 #define op_cmptlt_su 0x5a6
526 #define op_cmptle_su 0x5a7
527 #define op_cvtts_su 0x5ac
528 #define op_cvttq_sv 0x5af
529 #define op_adds_sud 0x5c0
530 #define op_subs_sud 0x5c1
531 #define op_muls_sud 0x5c2
532 #define op_divs_sud 0x5c3
533 #define op_addt_sud 0x5e0
534 #define op_subt_sud 0x5e1
535 #define op_mult_sud 0x5e2
536 #define op_divt_sud 0x5e3
537 #define op_cvtts_sud 0x5ec
538 #define op_adds_suic 0x700
539 #define op_subs_suic 0x701
540 #define op_muls_suic 0x702
541 #define op_divs_suic 0x703
542 #define op_addt_suic 0x720
543 #define op_subt_suic 0x721
544 #define op_mult_suic 0x722
545 #define op_divt_suic 0x723
546 #define op_cvtts_suic 0x72c
547 #define op_cvttq_svic 0x72f
548 #define op_cvtqs_suic 0x73c
549 #define op_cvtqt_suic 0x73e
550 #define op_adds_suim 0x740
551 #define op_subs_suim 0x741
552 #define op_muls_suim 0x742
553 #define op_divs_suim 0x743
554 #define op_addt_suim 0x760
555 #define op_subt_suim 0x761
556 #define op_mult_suim 0x762
557 #define op_divt_suim 0x763
558 #define op_cvtts_suim 0x76c
559 #define op_cvtqs_suim 0x77c
560 #define op_cvtqt_suim 0x77e
561 #define op_adds_sui 0x780
562 #define op_subs_sui 0x781
563 #define op_muls_sui 0x782
564 #define op_divs_sui 0x783
565 #define op_addt_sui 0x7a0
566 #define op_subt_sui 0x7a1
567 #define op_mult_sui 0x7a2
568 #define op_divt_sui 0x7a3
569 #define op_cvtts_sui 0x7ac
570 #define op_cvttq_svi 0x7af
571 #define op_cvtqs_sui 0x7bc
572 #define op_cvtqt_sui 0x7be
573 #define op_adds_suid 0x7c0
574 #define op_subs_suid 0x7c1
575 #define op_muls_suid 0x7c2
576 #define op_divs_suid 0x7c3
577 #define op_addt_suid 0x7e0
578 #define op_subt_suid 0x7e1
579 #define op_mult_suid 0x7e2
580 #define op_divt_suid 0x7e3
581 #define op_cvtts_suid 0x7ec
582 #define op_cvtqs_suid 0x7fc
583 #define op_cvtqt_suid 0x7fe
586 /* vax FLOAT, "function" opcodes (bits 5..11) */
588 #define op_addf_c 0x000
589 #define op_subf_c 0x001
590 #define op_mulf_c 0x002
591 #define op_divf_c 0x003
592 #define op_cvtdg_c 0x01e
593 #define op_addg_c 0x020
594 #define op_subg_c 0x021
595 #define op_mulg_c 0x022
596 #define op_divg_c 0x023
597 #define op_cvtgf_c 0x02c
598 #define op_cvtgd_c 0x02d
599 #define op_cvtgqg_c 0x02f
600 #define op_cvtqf_c 0x03c
601 #define op_cvtqg_c 0x03e
602 #define op_addf 0x080
603 #define op_subf 0x081
604 #define op_mulf 0x082
605 #define op_divf 0x083
606 #define op_cvtdg 0x09e
607 #define op_addg 0x0a0
608 #define op_subg 0x0a1
609 #define op_mulg 0x0a2
610 #define op_divg 0x0a3
611 #define op_cmpgeq 0x0a5
612 #define op_cmpglt 0x0a6
613 #define op_cmpgle 0x0a7
614 #define op_cvtgf 0x0ac
615 #define op_cvtgd 0x0ad
616 #define op_cvtgq 0x0af
617 #define op_cvtqf 0x0bc
618 #define op_cvtqg 0x0be
619 #define op_addf_uc 0x100
620 #define op_subf_uc 0x101
621 #define op_mulf_uc 0x102
622 #define op_divf_uc 0x103
623 #define op_cvtdg_uc 0x11e
624 #define op_addg_uc 0x120
625 #define op_subg_uc 0x121
626 #define op_mulg_uc 0x122
627 #define op_divg_uc 0x123
628 #define op_cvtgf_uc 0x12c
629 #define op_cvtgd_uc 0x12d
630 #define op_cvtgqg_vc 0x12f
631 #define op_addf_u 0x180
632 #define op_subf_u 0x181
633 #define op_mulf_u 0x182
634 #define op_divf_u 0x183
635 #define op_cvtdg_u 0x19e
636 #define op_addg_u 0x1a0
637 #define op_subg_u 0x1a1
638 #define op_mulg_u 0x1a2
639 #define op_divg_u 0x1a3
640 #define op_cvtgf_u 0x1ac
641 #define op_cvtgd_u 0x1ad
642 #define op_cvtgqg_v 0x1af
643 #define op_addf_sc 0x400
644 #define op_subf_sc 0x401
645 #define op_mulf_sc 0x402
646 #define op_divf_sc 0x403
647 #define op_cvtdg_sc 0x41e
648 #define op_addg_sc 0x420
649 #define op_subg_sc 0x421
650 #define op_mulg_sc 0x422
651 #define op_divg_sc 0x423
652 #define op_cvtgf_sc 0x42c
653 #define op_cvtgd_sc 0x42d
654 #define op_cvtgqg_sc 0x42f
655 #define op_cvtqf_sc 0x43c
656 #define op_cvtqg_sc 0x43e
657 #define op_addf_s 0x480
658 #define op_subf_s 0x481
659 #define op_mulf_s 0x482
660 #define op_divf_s 0x483
661 #define op_cvtdg_s 0x49e
662 #define op_addg_s 0x4a0
663 #define op_subg_s 0x4a1
664 #define op_mulg_s 0x4a2
665 #define op_divg_s 0x4a3
666 #define op_cmpgeq_s 0x4a5
667 #define op_cmpglt_s 0x4a6
668 #define op_cmpgle_s 0x4a7
669 #define op_cvtgf_s 0x4ac
670 #define op_cvtgd_s 0x4ad
671 #define op_cvtgqg_s 0x4af
672 #define op_cvtqf_s 0x4bc
673 #define op_cvtqg_s 0x4be
674 #define op_addf_suc 0x500
675 #define op_subf_suc 0x501
676 #define op_mulf_suc 0x502
677 #define op_divf_suc 0x503
678 #define op_cvtdg_suc 0x51e
679 #define op_addg_suc 0x520
680 #define op_subg_suc 0x521
681 #define op_mulg_suc 0x522
682 #define op_divg_suc 0x523
683 #define op_cvtgf_suc 0x52c
684 #define op_cvtgd_suc 0x52d
685 #define op_cvtgqg_svc 0x52f
686 #define op_addf_su 0x580
687 #define op_subf_su 0x581
688 #define op_mulf_su 0x582
689 #define op_divf_su 0x583
690 #define op_cvtdg_su 0x59e
691 #define op_addg_su 0x5a0
692 #define op_subg_su 0x5a1
693 #define op_mulg_su 0x5a2
694 #define op_divg_su 0x5a3
695 #define op_cvtgf_su 0x5ac
696 #define op_cvtgd_su 0x5ad
697 #define op_cvtgqg_sv 0x5af
700 #endif /* _ALPHA_INSTRUCTION_H_ */