| 1 |
2 |
dgisselq |
////////////////////////////////////////////////////////////////////////////////
|
| 2 |
|
|
//
|
| 3 |
|
|
// Filename: zopcodes.h
|
| 4 |
|
|
//
|
| 5 |
|
|
// Project: Zip CPU -- a small, lightweight, RISC CPU core
|
| 6 |
|
|
//
|
| 7 |
|
|
// Purpose: A structure defined to keep track of our various opcodes and
|
| 8 |
|
|
// some of their shortcut synonyms.
|
| 9 |
|
|
//
|
| 10 |
|
|
// Creator: Dan Gisselquist, Ph.D.
|
| 11 |
69 |
dgisselq |
// Gisselquist Technology, LLC
|
| 12 |
2 |
dgisselq |
//
|
| 13 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
| 14 |
|
|
//
|
| 15 |
|
|
// Copyright (C) 2015, Gisselquist Technology, LLC
|
| 16 |
|
|
//
|
| 17 |
|
|
// This program is free software (firmware): you can redistribute it and/or
|
| 18 |
|
|
// modify it under the terms of the GNU General Public License as published
|
| 19 |
|
|
// by the Free Software Foundation, either version 3 of the License, or (at
|
| 20 |
|
|
// your option) any later version.
|
| 21 |
|
|
//
|
| 22 |
|
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
| 23 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
| 24 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
| 25 |
|
|
// for more details.
|
| 26 |
|
|
//
|
| 27 |
|
|
// You should have received a copy of the GNU General Public License along
|
| 28 |
|
|
// with this program. (It's in the $(ROOT)/doc directory, run make with no
|
| 29 |
|
|
// target there if the PDF file isn't present.) If not, see
|
| 30 |
|
|
// <http://www.gnu.org/licenses/> for a copy.
|
| 31 |
|
|
//
|
| 32 |
|
|
// License: GPL, v3, as defined and found on www.gnu.org,
|
| 33 |
|
|
// http://www.gnu.org/licenses/gpl.html
|
| 34 |
|
|
//
|
| 35 |
|
|
//
|
| 36 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
| 37 |
|
|
#ifndef ZOPCODES_H
|
| 38 |
|
|
#define ZOPCODES_H
|
| 39 |
|
|
|
| 40 |
89 |
dgisselq |
#define ZIP_OPUNUSED -1
|
| 41 |
2 |
dgisselq |
#define ISUSEROP(A) ((a&(~0x0f))==0x000)
|
| 42 |
|
|
#define ISSUPROP(A) ((a&(~0x0f))==0x010)
|
| 43 |
|
|
#define ISLCLROP(A) ((a&(~0x0f))==0x020)
|
| 44 |
89 |
dgisselq |
#define ZIP_BITFIELD(LN,MN) (((LN&0x0ff)<<8)+(MN&0x0ff))
|
| 45 |
|
|
#define ZIP_REGFIELD(MN) (0x00000400 +(MN&0x0ff))
|
| 46 |
|
|
#define ZIP_URGFIELD(MN) (0x0100400 +(MN&0x0ff))
|
| 47 |
|
|
#define ZIP_SRGFIELD(MN) (0x0200400 +(MN&0x0ff))
|
| 48 |
|
|
#define ZIP_IMMFIELD(LN,MN) (0x40000000 + (((LN&0x0ff)<<8)+(MN&0x0ff))) // Sgn extnd
|
| 49 |
2 |
dgisselq |
// #define REGVAL(V) ((V & 0x0f)+0x020)
|
| 50 |
|
|
|
| 51 |
13 |
dgisselq |
typedef unsigned int ZIPI; // A Zip CPU instruction
|
| 52 |
2 |
dgisselq |
|
| 53 |
|
|
typedef struct {
|
| 54 |
|
|
char s_opstr[8];
|
| 55 |
|
|
ZIPI s_mask, s_val;
|
| 56 |
|
|
int s_result, s_ra, s_rb, s_i, s_cf;
|
| 57 |
|
|
} ZOPCODE;
|
| 58 |
|
|
|
| 59 |
|
|
extern const ZOPCODE zoplist[];
|
| 60 |
|
|
extern const int nzoplist;
|
| 61 |
|
|
|
| 62 |
|
|
// Disassemble an opcode
|
| 63 |
70 |
dgisselq |
extern void zipi_to_string(const ZIPI ins, char *la, char *lb);
|
| 64 |
2 |
dgisselq |
extern const char *zop_regstr[];
|
| 65 |
|
|
extern const char *zop_ccstr[];
|
| 66 |
70 |
dgisselq |
extern unsigned int zop_early_branch(const unsigned int pc, const ZIPI ins);
|
| 67 |
2 |
dgisselq |
|
| 68 |
|
|
#endif
|