OpenCores
URL https://opencores.org/ocsvn/zipcpu/zipcpu/trunk

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [sw/] [zasm/] [zopcodes.h] - Blame information for rev 202

Details | Compare with Previous | View Log

Line No. Rev Author Line
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 202 dgisselq
// Copyright (C) 2015-2017, Gisselquist Technology, LLC
16 2 dgisselq
//
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 202 dgisselq
// with this program.  (It's in the $(ROOT)/doc directory.  Run make with no
29 2 dgisselq
// 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 202 dgisselq
//
38
//
39 2 dgisselq
#ifndef ZOPCODES_H
40
#define ZOPCODES_H
41
 
42 202 dgisselq
#include <stdint.h>
43
 
44
// MACROS used in the instruction definition list.
45 89 dgisselq
#define ZIP_OPUNUSED    -1
46 2 dgisselq
#define ISUSEROP(A)     ((a&(~0x0f))==0x000)
47
#define ISSUPROP(A)     ((a&(~0x0f))==0x010)
48
#define ISLCLROP(A)     ((a&(~0x0f))==0x020)
49 202 dgisselq
#define ZIP_BITFIELD(LN,MN)     (((LN&0x0ff)<<8)+(MN&0x0ff)) // A generic bitfield
50
#define ZIP_REGFIELD(MN)        (0x00000400 +(MN&0x0ff)) // Normal register field
51
#define ZIP_URGFIELD(MN)        (0x0100400 +(MN&0x0ff)) // User register field
52
#define ZIP_IMMFIELD(LN,MN)     (0x40000000 + (((LN&0x0ff)<<8)+(MN&0x0ff))) // Sgn extnd
53 89 dgisselq
#define ZIP_SRGFIELD(MN)        (0x0200400 +(MN&0x0ff))
54 202 dgisselq
#define ZIP_SP  0xd0000
55 2 dgisselq
 
56 202 dgisselq
typedef uint32_t        ZIPI;   // A Zip CPU instruction
57 2 dgisselq
 
58
typedef struct {
59 202 dgisselq
        char    s_opstr[8];     // OPCode name
60
        ZIPI    s_mask,         // Bits that must match 4 this pattern to match
61
                s_val;          // What those masked bits must be
62
        //
63
        // The following describe not the value, but the bits where there
64
        // respective vaules will be found within the instruction.  For example,
65
        // an instruction with no immediate will have an s_i value of -1
66
        // (ZIP_OPUNUSED), whereas an instruction with an immediate value of -1
67
        // might have an s_i value of ZIP_BITFIELD(14,0), or 0x0400.  The
68
        // opcode itself will tell you what the value is--not this structure
69
        // describing the opcode.
70
        //
71
        int     s_result,       // Register where the result will be placed
72
                s_ra,           // A register, often the result
73
                s_rb,           // B register, source operand (if used)
74
                s_i,            // Immediate value, added to B if B is used
75
                s_cf;           // Condition flags.
76 2 dgisselq
} ZOPCODE;
77
 
78 202 dgisselq
extern  const   char    *zip_regstr[49], *zip_ccstr[8];
79 2 dgisselq
 
80 202 dgisselq
extern  const ZOPCODE   *zip_oplist, *zip_opbottomlist;
81
extern  const int       nzip_oplist, nzip_opbottom;
82
 
83 2 dgisselq
// Disassemble an opcode
84 202 dgisselq
extern  void zipi_to_double_string(const uint32_t, const ZIPI, char *, char *);
85 2 dgisselq
extern  const   char    *zop_regstr[];
86
extern  const   char    *zop_ccstr[];
87 70 dgisselq
extern  unsigned int    zop_early_branch(const unsigned int pc, const ZIPI ins);
88 2 dgisselq
 
89
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.