xref: /netbsd-src/sys/arch/vax/vax/db_disasm.h (revision ee918b29e1ca494b866845d941c9d30ab6dca848)
1*ee918b29Sragge /*	$NetBSD: db_disasm.h,v 1.8 2017/05/22 16:39:41 ragge Exp $ */
29a83d853Sragge /*
39a83d853Sragge  * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
49a83d853Sragge  * All rights reserved.
59a83d853Sragge  *
69a83d853Sragge  * This code is derived from software contributed to Ludd by
79a83d853Sragge  * Bertram Barth.
89a83d853Sragge  *
99a83d853Sragge  * Redistribution and use in source and binary forms, with or without
109a83d853Sragge  * modification, are permitted provided that the following conditions
119a83d853Sragge  * are met:
129a83d853Sragge  * 1. Redistributions of source code must retain the above copyright
139a83d853Sragge  *    notice, this list of conditions and the following disclaimer.
149a83d853Sragge  * 2. Redistributions in binary form must reproduce the above copyright
159a83d853Sragge  *    notice, this list of conditions and the following disclaimer in the
169a83d853Sragge  *    documentation and/or other materials provided with the distribution.
179a83d853Sragge  *
189a83d853Sragge  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
199a83d853Sragge  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
209a83d853Sragge  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
219a83d853Sragge  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
229a83d853Sragge  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
239a83d853Sragge  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
249a83d853Sragge  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
259a83d853Sragge  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
269a83d853Sragge  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
279a83d853Sragge  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
289a83d853Sragge  */
299a83d853Sragge 
309a83d853Sragge 
319a83d853Sragge 
329a83d853Sragge #define SIZE_BYTE	 1		/* Byte */
339a83d853Sragge #define SIZE_WORD	 2		/* Word */
349a83d853Sragge #define SIZE_LONG 	 4		/* Longword */
359a83d853Sragge #define SIZE_QWORD	 8		/* Quadword */
369a83d853Sragge #define SIZE_OWORD	16		/* Octaword */
379a83d853Sragge 
389a83d853Sragge /*
399a83d853Sragge  * The VAX instruction set has a variable length instruction format which
409a83d853Sragge  * may be as short as one byte and as long as needed depending on the type
419a83d853Sragge  * of instruction. [...] Each instruction consists of an opcode followed
429a83d853Sragge  * by zero to six operand specifiers whose number and type depend on the
439a83d853Sragge  * opcode. All operand specidiers are, themselves, of the same format --
449a83d853Sragge  * i.e. an address mode plus additional information.
459a83d853Sragge  *
469a83d853Sragge  * [VAX Architecture Handbook, p.52:  Instruction Format]
479a83d853Sragge  */
489a83d853Sragge 
49b2fabde4Schristos typedef const struct {
505c95110aSragge 	const char *mnemonic;
515c95110aSragge 	const char *argdesc;
52b2fabde4Schristos } vax_instr_t;
539a83d853Sragge 
54b2fabde4Schristos extern vax_instr_t vax_inst[256];
55b2fabde4Schristos extern vax_instr_t vax_inst2[0x56];
569a83d853Sragge 
57b2fabde4Schristos long skip_opcode(long);
5878c02895Schristos 
5978c02895Schristos /*
6078c02895Schristos  * reasonably simple macro to gather all the reserved two-byte opcodes
6178c02895Schristos  * into only a few table entries...
6278c02895Schristos  */
6378c02895Schristos #define	INDEX_OPCODE(x)	\
6478c02895Schristos 	(((x) & 0xff00) == 0xfe00) ? 0 : \
6578c02895Schristos 	((x) < 0xfd30) ? 0 : \
6678c02895Schristos 	((x) < 0xfd80) ? (x) - 0xfd30 : \
6778c02895Schristos 	((x) == 0xfd98) ? 0x50 : \
6878c02895Schristos 	((x) == 0xfd99) ? 0x51 : \
6978c02895Schristos 	((x) == 0xfdf6) ? 0x52 : \
7078c02895Schristos 	((x) == 0xfdf7) ? 0x53 : \
7178c02895Schristos 	((x) == 0xfffd) ? 0x54 : \
7278c02895Schristos 	((x) == 0xfffe) ? 0x55 : 0
73