198b9484cSchristos /* Opcode table header for m680[01234]0/m6888[12]/m68851. 2*aab831ceSchristos Copyright (C) 1989-2024 Free Software Foundation, Inc. 398b9484cSchristos 498b9484cSchristos This file is part of GDB, GAS, and the GNU binutils. 598b9484cSchristos 698b9484cSchristos GDB, GAS, and the GNU binutils are free software; you can redistribute 798b9484cSchristos them and/or modify them under the terms of the GNU General Public 898b9484cSchristos License as published by the Free Software Foundation; either version 3, 998b9484cSchristos or (at your option) any later version. 1098b9484cSchristos 1198b9484cSchristos GDB, GAS, and the GNU binutils are distributed in the hope that they 1298b9484cSchristos will be useful, but WITHOUT ANY WARRANTY; without even the implied 1398b9484cSchristos warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 1498b9484cSchristos the GNU General Public License for more details. 1598b9484cSchristos 1698b9484cSchristos You should have received a copy of the GNU General Public License 1798b9484cSchristos along with this file; see the file COPYING3. If not, write to the Free 1898b9484cSchristos Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 1998b9484cSchristos 02110-1301, USA. */ 2098b9484cSchristos 2198b9484cSchristos /* These are used as bit flags for the arch field in the m68k_opcode 2298b9484cSchristos structure. */ 2398b9484cSchristos #define _m68k_undef 0 2498b9484cSchristos #define m68000 0x001 2598b9484cSchristos #define m68010 0x002 2698b9484cSchristos #define m68020 0x004 2798b9484cSchristos #define m68030 0x008 2898b9484cSchristos #define m68040 0x010 2998b9484cSchristos #define m68060 0x020 3098b9484cSchristos #define m68881 0x040 3198b9484cSchristos #define m68851 0x080 3298b9484cSchristos #define cpu32 0x100 /* e.g., 68332 */ 3398b9484cSchristos #define fido_a 0x200 3498b9484cSchristos #define m68k_mask 0x3ff 3598b9484cSchristos 3698b9484cSchristos #define mcfmac 0x400 /* ColdFire MAC. */ 3798b9484cSchristos #define mcfemac 0x800 /* ColdFire EMAC. */ 3898b9484cSchristos #define cfloat 0x1000 /* ColdFire FPU. */ 3998b9484cSchristos #define mcfhwdiv 0x2000 /* ColdFire hardware divide. */ 4098b9484cSchristos 4198b9484cSchristos #define mcfisa_a 0x4000 /* ColdFire ISA_A. */ 4298b9484cSchristos #define mcfisa_aa 0x8000 /* ColdFire ISA_A+. */ 4398b9484cSchristos #define mcfisa_b 0x10000 /* ColdFire ISA_B. */ 4498b9484cSchristos #define mcfisa_c 0x20000 /* ColdFire ISA_C. */ 4598b9484cSchristos #define mcfusp 0x40000 /* ColdFire USP instructions. */ 4698b9484cSchristos #define mcf_mask 0x7e400 4798b9484cSchristos 4898b9484cSchristos /* Handy aliases. */ 4998b9484cSchristos #define m68040up (m68040 | m68060) 5098b9484cSchristos #define m68030up (m68030 | m68040up) 5198b9484cSchristos #define m68020up (m68020 | m68030up) 5298b9484cSchristos #define m68010up (m68010 | cpu32 | fido_a | m68020up) 5398b9484cSchristos #define m68000up (m68000 | m68010up) 5498b9484cSchristos 5598b9484cSchristos #define mfloat (m68881 | m68040 | m68060) 5698b9484cSchristos #define mmmu (m68851 | m68030 | m68040 | m68060) 5798b9484cSchristos 5898b9484cSchristos /* The structure used to hold information for an opcode. */ 5998b9484cSchristos 6098b9484cSchristos struct m68k_opcode 6198b9484cSchristos { 6298b9484cSchristos /* The opcode name. */ 6398b9484cSchristos const char *name; 6498b9484cSchristos /* The pseudo-size of the instruction(in bytes). Used to determine 6598b9484cSchristos number of bytes necessary to disassemble the instruction. */ 6698b9484cSchristos unsigned int size; 6798b9484cSchristos /* The opcode itself. */ 6898b9484cSchristos unsigned long opcode; 6998b9484cSchristos /* The mask used by the disassembler. */ 7098b9484cSchristos unsigned long match; 7198b9484cSchristos /* The arguments. */ 7298b9484cSchristos const char *args; 7398b9484cSchristos /* The architectures which support this opcode. */ 7498b9484cSchristos unsigned int arch; 7598b9484cSchristos }; 7698b9484cSchristos 7798b9484cSchristos /* The structure used to hold information for an opcode alias. */ 7898b9484cSchristos 7998b9484cSchristos struct m68k_opcode_alias 8098b9484cSchristos { 8198b9484cSchristos /* The alias name. */ 8298b9484cSchristos const char *alias; 8398b9484cSchristos /* The instruction for which this is an alias. */ 8498b9484cSchristos const char *primary; 8598b9484cSchristos }; 8698b9484cSchristos 8798b9484cSchristos /* We store four bytes of opcode for all opcodes because that is the 8898b9484cSchristos most any of them need. The actual length of an instruction is 8998b9484cSchristos always at least 2 bytes, and is as much longer as necessary to hold 9098b9484cSchristos the operands it has. 9198b9484cSchristos 9298b9484cSchristos The match field is a mask saying which bits must match particular 9398b9484cSchristos opcode in order for an instruction to be an instance of that 9498b9484cSchristos opcode. 9598b9484cSchristos 9698b9484cSchristos The args field is a string containing two characters for each 9798b9484cSchristos operand of the instruction. The first specifies the kind of 9898b9484cSchristos operand; the second, the place it is stored. 9998b9484cSchristos 10098b9484cSchristos If the first char of args is '.', it indicates that the opcode is 10198b9484cSchristos two words. This is only necessary when the match field does not 10298b9484cSchristos have any bits set in the second opcode word. Such a '.' is skipped 10398b9484cSchristos for operand processing. */ 10498b9484cSchristos 10598b9484cSchristos /* Kinds of operands: 10698b9484cSchristos Characters used: AaBbCcDdEeFfGgHIiJjKkLlMmnOopQqRrSsTtUuVvWwXxYyZz01234|*~%;@!&$?/<>#^+- 10798b9484cSchristos 10898b9484cSchristos D data register only. Stored as 3 bits. 10998b9484cSchristos A address register only. Stored as 3 bits. 11098b9484cSchristos a address register indirect only. Stored as 3 bits. 11198b9484cSchristos R either kind of register. Stored as 4 bits. 11298b9484cSchristos r either kind of register indirect only. Stored as 4 bits. 11398b9484cSchristos At the moment, used only for cas2 instruction. 11498b9484cSchristos F floating point coprocessor register only. Stored as 3 bits. 11598b9484cSchristos O an offset (or width): immediate data 0-31 or data register. 11698b9484cSchristos Stored as 6 bits in special format for BF... insns. 11798b9484cSchristos + autoincrement only. Stored as 3 bits (number of the address register). 11898b9484cSchristos - autodecrement only. Stored as 3 bits (number of the address register). 11998b9484cSchristos Q quick immediate data. Stored as 3 bits. 12098b9484cSchristos This matches an immediate operand only when value is in range 1 .. 8. 12198b9484cSchristos M moveq immediate data. Stored as 8 bits. 12298b9484cSchristos This matches an immediate operand only when value is in range -128..127 12398b9484cSchristos T trap vector immediate data. Stored as 4 bits. 12498b9484cSchristos 12598b9484cSchristos k K-factor for fmove.p instruction. Stored as a 7-bit constant or 12698b9484cSchristos a three bit register offset, depending on the field type. 12798b9484cSchristos 12898b9484cSchristos # immediate data. Stored in special places (b, w or l) 12998b9484cSchristos which say how many bits to store. 13098b9484cSchristos ^ immediate data for floating point instructions. Special places 13198b9484cSchristos are offset by 2 bytes from '#'... 13298b9484cSchristos B pc-relative address, converted to an offset 13398b9484cSchristos that is treated as immediate data. 13498b9484cSchristos d displacement and register. Stores the register as 3 bits 13598b9484cSchristos and stores the displacement in the entire second word. 13698b9484cSchristos 13798b9484cSchristos C the CCR. No need to store it; this is just for filtering validity. 13898b9484cSchristos S the SR. No need to store, just as with CCR. 13998b9484cSchristos U the USP. No need to store, just as with CCR. 14098b9484cSchristos E the MAC ACC. No need to store, just as with CCR. 14198b9484cSchristos e the EMAC ACC[0123]. 14298b9484cSchristos G the MAC/EMAC MACSR. No need to store, just as with CCR. 14398b9484cSchristos g the EMAC ACCEXT{01,23}. 14498b9484cSchristos H the MASK. No need to store, just as with CCR. 14598b9484cSchristos i the MAC/EMAC scale factor. 14698b9484cSchristos 14798b9484cSchristos I Coprocessor ID. Not printed if 1. The Coprocessor ID is always 14898b9484cSchristos extracted from the 'd' field of word one, which means that an extended 14998b9484cSchristos coprocessor opcode can be skipped using the 'i' place, if needed. 15098b9484cSchristos 15198b9484cSchristos s System Control register for the floating point coprocessor. 15298b9484cSchristos 15398b9484cSchristos J Misc register for movec instruction, stored in 'j' format. 15498b9484cSchristos Possible values: 15598b9484cSchristos 0x000 SFC Source Function Code reg [60, 40, 30, 20, 10] 15698b9484cSchristos 0x001 DFC Data Function Code reg [60, 40, 30, 20, 10] 15798b9484cSchristos 0x002 CACR Cache Control Register [60, 40, 30, 20, mcf] 15898b9484cSchristos 0x003 TC MMU Translation Control [60, 40] 15998b9484cSchristos 0x004 ITT0 Instruction Transparent 16098b9484cSchristos Translation reg 0 [60, 40] 16198b9484cSchristos 0x005 ITT1 Instruction Transparent 16298b9484cSchristos Translation reg 1 [60, 40] 16398b9484cSchristos 0x006 DTT0 Data Transparent 16498b9484cSchristos Translation reg 0 [60, 40] 16598b9484cSchristos 0x007 DTT1 Data Transparent 16698b9484cSchristos Translation reg 1 [60, 40] 16798b9484cSchristos 0x008 BUSCR Bus Control Register [60] 16898b9484cSchristos 0x800 USP User Stack Pointer [60, 40, 30, 20, 10] 16998b9484cSchristos 0x801 VBR Vector Base reg [60, 40, 30, 20, 10, mcf] 17098b9484cSchristos 0x802 CAAR Cache Address Register [ 30, 20] 17198b9484cSchristos 0x803 MSP Master Stack Pointer [ 40, 30, 20] 17298b9484cSchristos 0x804 ISP Interrupt Stack Pointer [ 40, 30, 20] 17398b9484cSchristos 0x805 MMUSR MMU Status reg [ 40] 17498b9484cSchristos 0x806 URP User Root Pointer [60, 40] 17598b9484cSchristos 0x807 SRP Supervisor Root Pointer [60, 40] 17698b9484cSchristos 0x808 PCR Processor Configuration reg [60] 17798b9484cSchristos 0xC00 ROMBAR ROM Base Address Register [520X] 17898b9484cSchristos 0xC04 RAMBAR0 RAM Base Address Register 0 [520X] 17998b9484cSchristos 0xC05 RAMBAR1 RAM Base Address Register 0 [520X] 18098b9484cSchristos 0xC0F MBAR0 RAM Base Address Register 0 [520X] 18198b9484cSchristos 0xC04 FLASHBAR FLASH Base Address Register [mcf528x] 18298b9484cSchristos 0xC05 RAMBAR Static RAM Base Address Register [mcf528x] 18398b9484cSchristos 18498b9484cSchristos L Register list of the type d0-d7/a0-a7 etc. 18598b9484cSchristos (New! Improved! Can also hold fp0-fp7, as well!) 18698b9484cSchristos The assembler tries to see if the registers match the insn by 18798b9484cSchristos looking at where the insn wants them stored. 18898b9484cSchristos 18998b9484cSchristos l Register list like L, but with all the bits reversed. 19098b9484cSchristos Used for going the other way. . . 19198b9484cSchristos 19298b9484cSchristos c cache identifier which may be "nc" for no cache, "ic" 19398b9484cSchristos for instruction cache, "dc" for data cache, or "bc" 19498b9484cSchristos for both caches. Used in cinv and cpush. Always 19598b9484cSchristos stored in position "d". 19698b9484cSchristos 19798b9484cSchristos u Any register, with ``upper'' or ``lower'' specification. Used 19898b9484cSchristos in the mac instructions with size word. 19998b9484cSchristos 20098b9484cSchristos The remainder are all stored as 6 bits using an address mode and a 20198b9484cSchristos register number; they differ in which addressing modes they match. 20298b9484cSchristos 20398b9484cSchristos * all (modes 0-6,7.0-4) 20498b9484cSchristos ~ alterable memory (modes 2-6,7.0,7.1) 20598b9484cSchristos (not 0,1,7.2-4) 20698b9484cSchristos % alterable (modes 0-6,7.0,7.1) 20798b9484cSchristos (not 7.2-4) 20898b9484cSchristos ; data (modes 0,2-6,7.0-4) 20998b9484cSchristos (not 1) 21098b9484cSchristos @ data, but not immediate (modes 0,2-6,7.0-3) 21198b9484cSchristos (not 1,7.4) 21298b9484cSchristos ! control (modes 2,5,6,7.0-3) 21398b9484cSchristos (not 0,1,3,4,7.4) 21498b9484cSchristos & alterable control (modes 2,5,6,7.0,7.1) 21598b9484cSchristos (not 0,1,3,4,7.2-4) 21698b9484cSchristos $ alterable data (modes 0,2-6,7.0,7.1) 21798b9484cSchristos (not 1,7.2-4) 21898b9484cSchristos ? alterable control, or data register (modes 0,2,5,6,7.0,7.1) 21998b9484cSchristos (not 1,3,4,7.2-4) 22098b9484cSchristos / control, or data register (modes 0,2,5,6,7.0-3) 22198b9484cSchristos (not 1,3,4,7.4) 22298b9484cSchristos > *save operands (modes 2,4,5,6,7.0,7.1) 22398b9484cSchristos (not 0,1,3,7.2-4) 22498b9484cSchristos < *restore operands (modes 2,3,5,6,7.0-3) 22598b9484cSchristos (not 0,1,4,7.4) 22698b9484cSchristos 22798b9484cSchristos coldfire move operands: 22898b9484cSchristos m (modes 0-4) 22998b9484cSchristos n (modes 5,7.2) 23098b9484cSchristos o (modes 6,7.0,7.1,7.3,7.4) 23198b9484cSchristos p (modes 0-5) 23298b9484cSchristos 23398b9484cSchristos coldfire bset/bclr/btst/mulsl/mulul operands: 23498b9484cSchristos q (modes 0,2-5) 23598b9484cSchristos v (modes 0,2-5,7.0,7.1) 23698b9484cSchristos b (modes 0,2-5,7.2) 23798b9484cSchristos w (modes 2-5,7.2) 23898b9484cSchristos y (modes 2,5) 23998b9484cSchristos z (modes 2,5,7.2) 24098b9484cSchristos x mov3q immediate operand. 24198b9484cSchristos j coprocessor ET operand. 24298b9484cSchristos K coprocessor command number. 24398b9484cSchristos 4 (modes 2,3,4,5) 24498b9484cSchristos */ 24598b9484cSchristos 24698b9484cSchristos /* For the 68851: */ 24798b9484cSchristos /* I didn't use much imagination in choosing the 24898b9484cSchristos following codes, so many of them aren't very 24998b9484cSchristos mnemonic. -rab 25098b9484cSchristos 25198b9484cSchristos 0 32 bit pmmu register 25298b9484cSchristos Possible values: 25398b9484cSchristos 000 TC Translation Control Register (68030, 68851) 25498b9484cSchristos 25598b9484cSchristos 1 16 bit pmmu register 25698b9484cSchristos 111 AC Access Control (68851) 25798b9484cSchristos 25898b9484cSchristos 2 8 bit pmmu register 25998b9484cSchristos 100 CAL Current Access Level (68851) 26098b9484cSchristos 101 VAL Validate Access Level (68851) 26198b9484cSchristos 110 SCC Stack Change Control (68851) 26298b9484cSchristos 26398b9484cSchristos 3 68030-only pmmu registers (32 bit) 26498b9484cSchristos 010 TT0 Transparent Translation reg 0 26598b9484cSchristos (aka Access Control reg 0 -- AC0 -- on 68ec030) 26698b9484cSchristos 011 TT1 Transparent Translation reg 1 26798b9484cSchristos (aka Access Control reg 1 -- AC1 -- on 68ec030) 26898b9484cSchristos 26998b9484cSchristos W wide pmmu registers 27098b9484cSchristos Possible values: 27198b9484cSchristos 001 DRP Dma Root Pointer (68851) 27298b9484cSchristos 010 SRP Supervisor Root Pointer (68030, 68851) 27398b9484cSchristos 011 CRP Cpu Root Pointer (68030, 68851) 27498b9484cSchristos 27598b9484cSchristos f function code register (68030, 68851) 27698b9484cSchristos 0 SFC 27798b9484cSchristos 1 DFC 27898b9484cSchristos 27998b9484cSchristos V VAL register only (68851) 28098b9484cSchristos 28198b9484cSchristos X BADx, BACx (16 bit) 28298b9484cSchristos 100 BAD Breakpoint Acknowledge Data (68851) 28398b9484cSchristos 101 BAC Breakpoint Acknowledge Control (68851) 28498b9484cSchristos 28598b9484cSchristos Y PSR (68851) (MMUSR on 68030) (ACUSR on 68ec030) 28698b9484cSchristos Z PCSR (68851) 28798b9484cSchristos 28898b9484cSchristos | memory (modes 2-6, 7.*) 28998b9484cSchristos 29098b9484cSchristos t address test level (68030 only) 29198b9484cSchristos Stored as 3 bits, range 0-7. 29298b9484cSchristos Also used for breakpoint instruction now. 29398b9484cSchristos 29498b9484cSchristos */ 29598b9484cSchristos 29698b9484cSchristos /* Places to put an operand, for non-general operands: 29798b9484cSchristos Characters used: BbCcDdFfGgHhIijkLlMmNnostWw123456789/ 29898b9484cSchristos 29998b9484cSchristos s source, low bits of first word. 30098b9484cSchristos d dest, shifted 9 in first word 30198b9484cSchristos 1 second word, shifted 12 30298b9484cSchristos 2 second word, shifted 6 30398b9484cSchristos 3 second word, shifted 0 30498b9484cSchristos 4 third word, shifted 12 30598b9484cSchristos 5 third word, shifted 6 30698b9484cSchristos 6 third word, shifted 0 30798b9484cSchristos 7 second word, shifted 7 30898b9484cSchristos 8 second word, shifted 10 30998b9484cSchristos 9 second word, shifted 5 31098b9484cSchristos E second word, shifted 9 31198b9484cSchristos D store in both place 1 and place 3; for divul and divsl. 31298b9484cSchristos B first word, low byte, for branch displacements 31398b9484cSchristos W second word (entire), for branch displacements 31498b9484cSchristos L second and third words (entire), for branch displacements 31598b9484cSchristos (also overloaded for move16) 31698b9484cSchristos b second word, low byte 31798b9484cSchristos w second word (entire) [variable word/long branch offset for dbra] 31898b9484cSchristos W second word (entire) (must be signed 16 bit value) 31998b9484cSchristos l second and third word (entire) 32098b9484cSchristos g variable branch offset for bra and similar instructions. 32198b9484cSchristos The place to store depends on the magnitude of offset. 32298b9484cSchristos t store in both place 7 and place 8; for floating point operations 32398b9484cSchristos c branch offset for cpBcc operations. 32498b9484cSchristos The place to store is word two if bit six of word one is zero, 32598b9484cSchristos and words two and three if bit six of word one is one. 32698b9484cSchristos i Increment by two, to skip over coprocessor extended operands. Only 32798b9484cSchristos works with the 'I' format. 32898b9484cSchristos k Dynamic K-factor field. Bits 6-4 of word 2, used as a register number. 32998b9484cSchristos Also used for dynamic fmovem instruction. 33098b9484cSchristos C floating point coprocessor constant - 7 bits. Also used for static 33198b9484cSchristos K-factors... 33298b9484cSchristos j Movec register #, stored in 12 low bits of second word. 33398b9484cSchristos m For M[S]ACx; 4 bits split with MSB shifted 6 bits in first word 33498b9484cSchristos and remaining 3 bits of register shifted 9 bits in first word. 33598b9484cSchristos Indicate upper/lower in 1 bit shifted 7 bits in second word. 33698b9484cSchristos Use with `R' or `u' format. 33798b9484cSchristos n `m' withouth upper/lower indication. (For M[S]ACx; 4 bits split 33898b9484cSchristos with MSB shifted 6 bits in first word and remaining 3 bits of 33998b9484cSchristos register shifted 9 bits in first word. No upper/lower 34098b9484cSchristos indication is done.) Use with `R' or `u' format. 34198b9484cSchristos o For M[S]ACw; 4 bits shifted 12 in second word (like `1'). 34298b9484cSchristos Indicate upper/lower in 1 bit shifted 7 bits in second word. 34398b9484cSchristos Use with `R' or `u' format. 34498b9484cSchristos M For M[S]ACw; 4 bits in low bits of first word. Indicate 34598b9484cSchristos upper/lower in 1 bit shifted 6 bits in second word. Use with 34698b9484cSchristos `R' or `u' format. 34798b9484cSchristos N For M[S]ACw; 4 bits in low bits of second word. Indicate 34898b9484cSchristos upper/lower in 1 bit shifted 6 bits in second word. Use with 34998b9484cSchristos `R' or `u' format. 35098b9484cSchristos h shift indicator (scale factor), 1 bit shifted 10 in second word 35198b9484cSchristos 35298b9484cSchristos Places to put operand, for general operands: 35398b9484cSchristos d destination, shifted 6 bits in first word 35498b9484cSchristos b source, at low bit of first word, and immediate uses one byte 35598b9484cSchristos w source, at low bit of first word, and immediate uses two bytes 35698b9484cSchristos l source, at low bit of first word, and immediate uses four bytes 35798b9484cSchristos s source, at low bit of first word. 35898b9484cSchristos Used sometimes in contexts where immediate is not allowed anyway. 35998b9484cSchristos f single precision float, low bit of 1st word, immediate uses 4 bytes 36098b9484cSchristos F double precision float, low bit of 1st word, immediate uses 8 bytes 36198b9484cSchristos x extended precision float, low bit of 1st word, immediate uses 12 bytes 36298b9484cSchristos p packed float, low bit of 1st word, immediate uses 12 bytes 36398b9484cSchristos G EMAC accumulator, load (bit 4 2nd word, !bit8 first word) 36498b9484cSchristos H EMAC accumulator, non load (bit 4 2nd word, bit 8 first word) 36598b9484cSchristos F EMAC ACCx 36698b9484cSchristos f EMAC ACCy 36798b9484cSchristos I MAC/EMAC scale factor 36898b9484cSchristos / Like 's', but set 2nd word, bit 5 if trailing_ampersand set 36998b9484cSchristos ] first word, bit 10 37098b9484cSchristos */ 37198b9484cSchristos 37298b9484cSchristos extern const struct m68k_opcode m68k_opcodes[]; 37398b9484cSchristos extern const struct m68k_opcode_alias m68k_opcode_aliases[]; 37498b9484cSchristos 37598b9484cSchristos extern const int m68k_numopcodes, m68k_numaliases; 37698b9484cSchristos 37798b9484cSchristos /* end of m68k-opcode.h */ 378