Home | History | Annotate | Line # | Download | only in opcodes
      1   1.1  christos /* mc9xgate-opc.c -- Freescale XGATE opcode list
      2  1.10  christos    Copyright (C) 1999-2025 Free Software Foundation, Inc.
      3   1.1  christos    Written by Sean Keys (skeys (at) ipdatasys.com)
      4   1.1  christos 
      5   1.1  christos    This file is part of the GNU opcodes library.
      6   1.1  christos 
      7   1.1  christos    This library is free software; you can redistribute it and/or modify
      8   1.1  christos    it under the terms of the GNU General Public License as published by
      9   1.1  christos    the Free Software Foundation; either version 3, or (at your option)
     10   1.1  christos    any later version.
     11   1.1  christos 
     12   1.1  christos    It is distributed in the hope that it will be useful, but WITHOUT
     13   1.1  christos    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
     14   1.1  christos    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
     15   1.1  christos    License for more details.
     16   1.1  christos 
     17   1.1  christos    You should have received a copy of the GNU General Public License
     18   1.1  christos    along with this file; see the file COPYING.  If not, write to the
     19   1.1  christos    Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
     20   1.1  christos    MA 02110-1301, USA.
     21   1.1  christos */
     22   1.1  christos 
     23   1.1  christos #include <stdio.h>
     24   1.1  christos #include "ansidecl.h"
     25   1.1  christos #include "opcode/xgate.h"
     26   1.1  christos 
     27   1.1  christos #define TABLE_SIZE(X)       (sizeof(X) / sizeof(X[0]))
     28   1.1  christos 
     29   1.1  christos /* Combination of CCR flags.  */
     30   1.1  christos /* ORDER HI TO LOW NZVC */
     31   1.1  christos #define XGATE_NZ_BIT	XGATE_N_BIT|XGATE_Z_BIT
     32   1.1  christos #define XGATE_NV_BIT	XGATE_N_BIT|XGATE_V_BIT
     33   1.1  christos #define XGATE_NC_BIT	XGATE_N_BIT|XGATE_C_BIT
     34   1.1  christos #define XGATE_ZV_BIT	XGATE_Z_BIT|XGATE_V_BIT
     35   1.1  christos #define XGATE_ZC_BIT	XGATE_Z_BIT|XGATE_C_BIT
     36   1.1  christos #define XGATE_VC_BIT	XGATE_V_BIT|XGATE_C_BIT
     37   1.1  christos #define XGATE_NVC_BIT	XGATE_NV_BIT|XGATE_C_BIT
     38   1.1  christos #define XGATE_NZC_BIT	XGATE_NZ_BIT|XGATE_C_BIT
     39   1.1  christos #define XGATE_NZV_BIT	XGATE_N_BIT|XGATE_Z_BIT|XGATE_V_BIT
     40   1.1  christos #define XGATE_ZVC_BIT	XGATE_VC_BIT|XGATE_Z_BIT
     41   1.1  christos #define XGATE_NZVC_BIT	XGATE_NZV_BIT|XGATE_C_BIT
     42   1.1  christos 
     43   1.1  christos /* Flags when the insn only changes some CCR flags.  */
     44   1.1  christos #define CHG_NONE        0,0,0
     45   1.1  christos #define CHG_Z           0,0,XGATE_Z_BIT
     46   1.1  christos #define CHG_C           0,0,XGATE_C_BIT
     47   1.1  christos #define CHG_ZVC         0,0,XGATE_ZVC_BIT
     48   1.1  christos #define CHG_NZC         0,0,XGATE_NZC_BIT
     49   1.1  christos #define CHG_NZV         0,0,XGATE_NZV_BIT
     50   1.1  christos #define CHG_NZVC        0,0,(XGATE_NZVC_BIT)
     51   1.1  christos #define CHG_HNZVC       0,0,XGATE_HNZVC_BIT  // TODO DELETE
     52   1.1  christos #define CHG_ALL         0,0,0xff
     53   1.1  christos 
     54   1.1  christos /* The insn clears and changes some flags.  */
     55   1.1  christos #define CLR_I           0,XG_I_BIT,0
     56   1.1  christos #define CLR_C           0,XGATE_C_BIT,0
     57   1.1  christos #define CLR_V           0,XGATE_V_BIT,0
     58   1.1  christos #define CLR_V_CHG_ZC    0,XGATE_V_BIT,XGATE_ZC_BIT
     59   1.1  christos #define CLR_V_CHG_NZ    0,XGATE_V_BIT,XGATE_NZ_BIT
     60   1.1  christos #define CLR_V_CHG_ZVC   0,XGATE_V_BIT,XGATE_ZVC_BIT
     61   1.1  christos #define CLR_N_CHG_ZVC   0,XGATE_N_BIT,XGATE_ZVC_BIT /* Used by lsr */
     62   1.1  christos #define CLR_VC_CHG_NZ   0,XGATE_VC_BIT,XGATE_NZ_BIT
     63   1.1  christos 
     64   1.1  christos /* The insn sets some flags.  */
     65   1.1  christos #define SET_I                   XGATE_I_BIT,0,0
     66   1.1  christos #define SET_C                   XGATE_C_BIT,0,0
     67   1.1  christos #define SET_V                   XGATE_V_BIT,0,0
     68   1.1  christos #define SET_Z_CLR_NVC           XGATE_Z_BIT,XGATE_NVC_BIT,0
     69   1.1  christos #define SET_C_CLR_V_CHG_NZ      XGATE_C_BIT,XGATE_V_BIT,XGATE_NZ_BIT
     70   1.1  christos #define SET_Z_CHG_HNVC          XGATE_Z_BIT,0,XGATE_HNVC_BIT
     71   1.1  christos 
     72   1.1  christos /* operand modes */
     73   1.1  christos #define OP_NONE         XGATE_OP_NONE
     74   1.1  christos #define OP_INH		XGATE_OP_INH
     75   1.1  christos #define OP_TRI		XGATE_OP_TRI
     76   1.1  christos #define OP_DYA		XGATE_OP_DYA
     77   1.1  christos #define OP_IMM3		XGATE_OP_IMM3
     78   1.1  christos #define OP_IMM4		XGATE_OP_IMM4
     79   1.1  christos #define OP_IMM8		XGATE_OP_IMM8
     80   1.1  christos #define OP_IMM16	XGATE_OP_IMM16
     81   1.1  christos #define OP_MON		XGATE_OP_MON
     82   1.1  christos #define OP_MON_R_C	XGATE_OP_MON_R_C
     83   1.1  christos #define OP_MON_C_R	XGATE_OP_MON_C_R
     84   1.1  christos #define OP_MON_R_P	XGATE_OP_MON_R_P
     85   1.1  christos #define OP_IDR	        XGATE_OP_IDR
     86   1.1  christos #define OP_IDO5		XGATE_OP_IDO5
     87   1.1  christos #define OP_REL9		XGATE_OP_REL9
     88   1.1  christos #define OP_REL10    	XGATE_OP_REL10
     89   1.3  christos #define OP_DM           XGATE_OP_DYA_MON
     90   1.1  christos /* macro operand modes */
     91   1.1  christos #define OP_mADD         XGATE_OP_IMM16mADD
     92   1.1  christos #define OP_mAND         XGATE_OP_IMM16mAND
     93   1.1  christos #define OP_mCPC         XGATE_OP_IMM16mCPC
     94   1.1  christos #define OP_mLDW         XGATE_OP_IMM16mLDW
     95   1.1  christos #define OP_mSUB         XGATE_OP_IMM16mSUB
     96   1.1  christos 
     97   1.1  christos #define ALL       XGATE_V1|XGATE_V2|XGATE_V3
     98   1.1  christos 
     99   1.1  christos const struct xgate_opcode xgate_opcodes[] = {
    100   1.3  christos /* Name -+                                                              +--- CPU
    101   1.3  christos    Constraints --+                                              +----------- CCR changes
    102   1.3  christos    Format -------+                                         +---------------- Max # cycles
    103   1.3  christos                                                         +------------------- Min # cycles
    104   1.3  christos    Size -------------------------------------+   +-------------------------- Opcode */
    105   1.3  christos     {   "adc",   OP_TRI, "00011rrrrrrrrr11", 2, 0x1803, 1, 1, CHG_NZVC, ALL},
    106   1.3  christos     {   "add",   OP_TRI, "00011rrrrrrrrr10", 2, 0x1802, 1, 1, CHG_NZVC, ALL},
    107   1.3  christos     {  "addh",  OP_IMM8, "11101rrriiiiiiii", 2, 0xE800, 1, 1, CHG_NZVC, ALL},
    108   1.3  christos     {  "addl",  OP_IMM8, "11100rrriiiiiiii", 2, 0xE000, 1, 1, CHG_NZVC, ALL},
    109   1.3  christos     {   "and",   OP_TRI, "00010rrrrrrrrr00", 2, 0x1000, 1, 1,  CHG_NZV, ALL},
    110   1.3  christos     {  "andh",  OP_IMM8, "10001rrriiiiiiii", 2, 0x8800, 1, 1,  CHG_NZV, ALL},
    111   1.3  christos     {  "andl",  OP_IMM8, "10000rrriiiiiiii", 2, 0x8000, 1, 1,  CHG_NZV, ALL},
    112   1.3  christos     {   "asr",  OP_IMM4, "00001rrriiii1001", 2, 0x0809, 1, 1, CHG_NZVC, ALL},
    113   1.3  christos     {   "asr",   OP_DYA, "00001rrrrrr10001", 2, 0x0811, 1, 1, CHG_NZVC, ALL},
    114   1.3  christos     {   "bcc",  OP_REL9, "0010000iiiiiiiii", 2, 0x2000, 1, 2, CHG_NONE, ALL},
    115   1.3  christos     {   "bcs",  OP_REL9, "0010001iiiiiiiii", 2, 0x2200, 1, 2, CHG_NONE, ALL},
    116   1.3  christos     {   "beq",  OP_REL9, "0010011iiiiiiiii", 2, 0x2600, 1, 2, CHG_NONE, ALL},
    117   1.3  christos     { "bfext",   OP_TRI, "01100rrrrrrrrr11", 2, 0x6003, 1, 1,  CHG_NZV, ALL},
    118   1.3  christos     {  "bffo",   OP_DYA, "00001rrrrrr10000", 2, 0x0810, 1, 1, CHG_NZVC, ALL},
    119   1.3  christos     { "bfins",   OP_TRI, "01101rrrrrrrrr11", 2, 0x6803, 1, 1,  CHG_NZV, ALL},
    120   1.3  christos     {"bfinsi",   OP_TRI, "01110rrrrrrrrr11", 2, 0x7003, 1, 1,  CHG_NZV, ALL},
    121   1.3  christos     {"bfinsx",   OP_TRI, "01111rrrrrrrrr11", 2, 0x7803, 1, 1,  CHG_NZV, ALL},
    122   1.3  christos     {   "bge",  OP_REL9, "0011010iiiiiiiii", 2, 0x3400, 1, 2, CHG_NONE, ALL},
    123   1.3  christos     {   "bgt",  OP_REL9, "0011100iiiiiiiii", 2, 0x3800, 1, 2, CHG_NONE, ALL},
    124   1.3  christos     {   "bhi",  OP_REL9, "0011000iiiiiiiii", 2, 0x3000, 1, 2, CHG_NONE, ALL},
    125   1.3  christos     {  "bith",  OP_IMM8, "10011rrriiiiiiii", 2, 0x9800, 1, 1,  CHG_NZV, ALL},
    126   1.3  christos     {  "bitl",  OP_IMM8, "10010rrriiiiiiii", 2, 0x9000, 1, 1,  CHG_NZV, ALL},
    127   1.3  christos     {   "ble",  OP_REL9, "0011101iiiiiiiii", 2, 0x3A00, 1, 2, CHG_NONE, ALL},
    128   1.3  christos     {   "bls",  OP_REL9, "0011001iiiiiiiii", 2, 0x3200, 1, 2, CHG_NONE, ALL},
    129   1.3  christos     {   "blt",  OP_REL9, "0011011iiiiiiiii", 2, 0x3600, 1, 2, CHG_NONE, ALL},
    130   1.3  christos     {   "bmi",  OP_REL9, "0010101iiiiiiiii", 2, 0x2A00, 1, 2, CHG_NONE, ALL},
    131   1.3  christos     {   "bne",  OP_REL9, "0010010iiiiiiiii", 2, 0x2400, 1, 2, CHG_NONE, ALL},
    132   1.3  christos     {   "bpl",  OP_REL9, "0010100iiiiiiiii", 2, 0x2800, 1, 2, CHG_NONE, ALL},
    133   1.3  christos     {   "bra", OP_REL10, "001111iiiiiiiiii", 2, 0x3C00, 2, 2, CHG_NONE, ALL},
    134   1.3  christos     {   "brk",   OP_INH, "0000000000000000", 2, 0x0000, 1, 1, CHG_NONE, ALL},
    135   1.3  christos     {   "bvc",  OP_REL9, "0010110iiiiiiiii", 2, 0x2C00, 1, 2, CHG_NONE, ALL},
    136   1.3  christos     {   "bvs",  OP_REL9, "0010111iiiiiiiii", 2, 0x2E00, 1, 2, CHG_NONE, ALL},
    137   1.3  christos     {  "cmpl",  OP_IMM8, "11010rrriiiiiiii", 2, 0xD000, 1, 1, CHG_NZVC, ALL},
    138   1.3  christos     {  "cpch",  OP_IMM8, "11011rrriiiiiiii", 2, 0xD800, 1, 1, CHG_NZVC, ALL},
    139   1.3  christos     {  "csem",  OP_IMM3, "00000iii11110000", 2, 0x00F0, 1, 1, CHG_NONE, ALL},
    140   1.3  christos     {  "csem",   OP_MON, "00000rrr11110001", 2, 0x00F1, 1, 1, CHG_NONE, ALL},
    141   1.3  christos     {   "csl",  OP_IMM4, "00001rrriiii1010", 2, 0x080A, 1, 1, CHG_NZVC, ALL},
    142   1.3  christos     {   "csl",   OP_DYA, "00001rrrrrr10010", 2, 0x0812, 1, 1, CHG_NZVC, ALL},
    143   1.3  christos     {   "csr",  OP_IMM4, "00001rrriiii1011", 2, 0x080B, 1, 1, CHG_NZVC, ALL},
    144   1.3  christos     {   "csr",   OP_DYA, "00001rrrrrr10011", 2, 0x0813, 1, 1, CHG_NZVC, ALL},
    145   1.3  christos     {   "jal",   OP_MON, "00000rrr11110110", 2, 0x00F6, 2, 2, CHG_NONE, ALL},
    146   1.3  christos     {   "ldb",  OP_IDO5, "01000rrrrrriiiii", 2, 0x4000, 2, 2, CHG_NONE, ALL},
    147   1.3  christos     {   "ldb",   OP_IDR, "01100rrrrrrrrrrr", 2, 0x6000, 2, 2, CHG_NONE, ALL},
    148   1.3  christos     {   "ldh",  OP_IMM8, "11111rrriiiiiiii", 2, 0xF800, 1, 1, CHG_NONE, ALL},
    149   1.3  christos     {   "ldl",  OP_IMM8, "11110rrriiiiiiii", 2, 0xF000, 1, 1, CHG_NONE, ALL},
    150   1.3  christos     {   "ldw",  OP_IDO5, "01001rrrrrriiiii", 2, 0x4800, 2, 2, CHG_NONE, ALL},
    151   1.3  christos     {   "ldw",   OP_IDR, "01101rrrrrrrrrrr", 2, 0x6800, 2, 2, CHG_NONE, ALL},
    152   1.3  christos     {   "lsl",  OP_IMM4, "00001rrriiii1100", 2, 0x080C, 1, 1, CHG_NZVC, ALL},
    153   1.3  christos     {   "lsl",   OP_DYA, "00001rrrrrr10100", 2, 0x0814, 1, 1, CHG_NZVC, ALL},
    154   1.3  christos     {   "lsr",  OP_IMM4, "00001rrriiii1101", 2, 0x080D, 1, 1, CHG_NZVC, ALL},
    155   1.3  christos     {   "lsr",   OP_DYA, "00001rrrrrr10101", 2, 0x0815, 1, 1, CHG_NZVC, ALL},
    156   1.3  christos     {   "nop",   OP_INH, "0000000100000000", 2, 0x0100, 1, 1, CHG_NONE, ALL},
    157   1.3  christos     {    "or",   OP_TRI, "00010rrrrrrrrr10", 2, 0x1002, 1, 1,  CHG_NZV, ALL},
    158   1.3  christos     {   "orh",  OP_IMM8, "10101rrriiiiiiii", 2, 0xA800, 1, 1,  CHG_NZV, ALL},
    159   1.3  christos     {   "orl",  OP_IMM8, "10100rrriiiiiiii", 2, 0xA000, 1, 1,  CHG_NZV, ALL},
    160   1.3  christos     {   "par",   OP_MON, "00000rrr11110101", 2, 0x00F5, 1, 1,  CHG_NZV, ALL},
    161   1.3  christos     {   "rol",  OP_IMM4, "00001rrriiii1110", 2, 0x080E, 1, 1,  CHG_NZV, ALL},
    162   1.3  christos     {   "rol",   OP_DYA, "00001rrrrrr10110", 2, 0x0816, 1, 1,  CHG_NZV, ALL},
    163   1.3  christos     {   "ror",  OP_IMM4, "00001rrriiii1111", 2, 0x080F, 1, 1,  CHG_NZV, ALL},
    164   1.3  christos     {   "ror",   OP_DYA, "00001rrrrrr10111", 2, 0x0817, 1, 1,  CHG_NZV, ALL},
    165   1.3  christos     {   "rts",   OP_INH, "0000001000000000", 2, 0x0200, 2, 2, CHG_NONE, ALL},
    166   1.3  christos     {   "sbc",   OP_TRI, "00011rrrrrrrrr01", 2, 0x1801, 1, 1,  CHG_NZV, ALL},
    167   1.3  christos     {  "ssem",  OP_IMM3, "00000iii11110010", 2, 0x00F2, 2, 2,    CHG_C, ALL},
    168   1.3  christos     {  "ssem",   OP_MON, "00000rrr11110011", 2, 0x00F3, 2, 2,    CHG_C, ALL},
    169   1.3  christos     {   "sex",   OP_MON, "00000rrr11110100", 2, 0x00F4, 1, 1,  CHG_NZV, ALL},
    170   1.3  christos     {   "sif",   OP_INH, "0000001100000000", 2, 0x0300, 2, 2, CHG_NONE, ALL},
    171   1.3  christos     {   "sif",   OP_MON, "00000rrr11110111", 2, 0x00F7, 2, 2, CHG_NONE, ALL},
    172   1.3  christos     {   "stb",  OP_IDO5, "01010rrrrrriiiii", 2, 0x5000, 2, 2, CHG_NONE, ALL},
    173   1.3  christos     {   "stb",   OP_IDR, "01110rrrrrrrrrrr", 2, 0x7000, 2, 2, CHG_NONE, ALL},
    174   1.3  christos     {   "stw",  OP_IDO5, "01011rrrrrriiiii", 2, 0x5800, 2, 2, CHG_NONE, ALL},
    175   1.3  christos     {   "stw",   OP_IDR, "01111rrrrrrrrrrr", 2, 0x7800, 2, 2, CHG_NONE, ALL},
    176   1.3  christos     {   "sub",   OP_TRI, "00011rrrrrrrrr00", 2, 0x1800, 1, 1, CHG_NZVC, ALL},
    177   1.3  christos     {  "subh",  OP_IMM8, "11001rrriiiiiiii", 2, 0xC800, 1, 1, CHG_NZVC, ALL},
    178   1.3  christos     {  "subl",  OP_IMM8, "11000rrriiiiiiii", 2, 0xC000, 1, 1, CHG_NZVC, ALL},
    179   1.3  christos     {   "tfr",  OP_MON_R_C, "00000rrr11111000", 2, 0x00F8, 1, 1, CHG_NONE, ALL},
    180   1.3  christos     {   "tfr",  OP_MON_C_R, "00000rrr11111001", 2, 0x00F9, 1, 1, CHG_NONE, ALL},
    181   1.3  christos     {   "tfr",  OP_MON_R_P, "00000rrr11111010", 2, 0x00FA, 1, 1, CHG_NONE, ALL},
    182   1.3  christos     {  "xnor",   OP_TRI, "00010rrrrrrrrr11", 2, 0x1003, 1, 1,  CHG_NZV, ALL},
    183   1.3  christos     { "xnorh",  OP_IMM8, "10111rrriiiiiiii", 2, 0xB800, 1, 1,  CHG_NZV, ALL},
    184   1.3  christos     { "xnorl",  OP_IMM8, "10110rrriiiiiiii", 2, 0xB000, 1, 1,  CHG_NZV, ALL},
    185   1.1  christos     /*  macro and alias codes  */
    186   1.3  christos     {   "add", OP_mADD,  "----------------", 4,      0, 0, 0, CHG_NONE, ALL},
    187   1.3  christos     {   "and", OP_mAND,  "----------------", 4,      0, 0, 0, CHG_NONE, ALL},
    188   1.3  christos     {   "bhs",  OP_REL9, "0010000iiiiiiiii", 2, 0x2000, 0, 0, CHG_NONE, ALL},
    189   1.3  christos     {   "blo",  OP_REL9, "0010001iiiiiiiii", 2, 0x2200, 0, 0, CHG_NONE, ALL},
    190   1.3  christos     {   "cmp",  OP_mCPC, "----------------", 4,      0, 0, 0, CHG_NONE, ALL},
    191   1.3  christos     {   "cmp",   OP_DYA, "00011sssrrrrrr00", 2, 0x1800, 0, 0, CHG_NZVC, ALL},
    192   1.3  christos     {   "com",   OP_DM,  "00010rrrsssrrr11", 2, 0x1003, 0, 0, CHG_NZVC, ALL},
    193   1.3  christos     {   "com",   OP_DYA, "00010rrrsssrrr11", 2, 0x1003, 0, 0,  CHG_NZV, ALL},
    194   1.3  christos     {   "cpc",   OP_DYA, "00011sssrrrrrr01", 2, 0x1801, 0, 0, CHG_NZVC, ALL},
    195   1.3  christos     {   "ldd",  OP_mLDW, "----------------", 4,      0, 0, 0, CHG_NONE, ALL},
    196   1.3  christos     {   "ldw",  OP_mLDW, "----------------", 4,      0, 0, 0, CHG_NONE, ALL},
    197   1.3  christos     {   "mov",   OP_DYA, "00010rrrsssrrr10", 2, 0x1002, 0, 0, CHG_NZVC, ALL},
    198   1.3  christos     {   "neg",   OP_DYA, "00011rrrsssrrr00", 2, 0x1800, 0, 0, CHG_NZVC, ALL},
    199   1.3  christos     {   "sub",  OP_mSUB, "----------------", 4,      0, 0, 0, CHG_NONE, ALL},
    200   1.3  christos     {   "tst",   OP_MON, "00011sssrrrsss00", 2, 0x1800, 0, 0,  CHG_NZV, ALL}
    201   1.1  christos };
    202   1.1  christos 
    203   1.1  christos const int xgate_num_opcodes = TABLE_SIZE (xgate_opcodes);
    204