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

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [sw/] [zasm/] [zparser.h] - Diff between revs 126 and 143

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 126 Rev 143
Line 42... Line 42...
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
 
 
#ifndef ZPARSER_H
#ifndef ZPARSER_H
#define ZPARSER_H
#define ZPARSER_H
 
 
 
/*
 
 * LONG_MPY controls whether or not the instruction set has:
 
 *   (if not defined)
 
 *      LDIHI   - load the value into the upper 16 bits of a register
 
 *      MPYS    - Multiplies two 16-bit values into a    signed 32-bit result
 
 *      MPYU    - Multiplies two 16-bit values into an unsigned 32-bit result
 
 *   (if defined)
 
 *      MPY     - Multiplies two 32-bit values and returns the lower 32-bits of
 
 *                      the result.  Works for signed and unsigned values.
 
 *      MPYSHI  - Multiplies two 32-bit values and returns the upper 32-bits of
 
 *                      the   signed 64-bit result
 
 *      MPYUHI  - Multiplies two 32-bit values and returns the upper 32-bits of
 
 *                      the unsigned 64-bit result
 
 *
 
 */
 
#define LONG_MPY
 
 
 
#include "zopcodes.h"
 
 
class   ZPARSER {
class   ZPARSER {
public:
public:
        typedef unsigned int    ZIPI, ZIPA;
        typedef unsigned int    ZIPA;
        typedef int     ZIPIMM;
        typedef int     ZIPIMM;
        typedef enum {
        typedef enum {
                ZIP_R0, ZIP_R1, ZIP_R2, ZIP_R3, ZIP_R4, ZIP_R5, ZIP_R6, ZIP_R7,
                ZIP_R0, ZIP_R1, ZIP_R2, ZIP_R3, ZIP_R4, ZIP_R5, ZIP_R6, ZIP_R7,
                ZIP_R8, ZIP_R9, ZIP_R10, ZIP_R11, ZIP_R12,
                ZIP_R8, ZIP_R9, ZIP_R10, ZIP_R11, ZIP_R12,
                        ZIP_SP, ZIP_CC, ZIP_PC,
                        ZIP_SP, ZIP_CC, ZIP_PC,
Line 65... Line 84...
 
 
        typedef enum {
        typedef enum {
                // 16 ALU instructions
                // 16 ALU instructions
                ZIPO_SUB=0, ZIPO_AND, ZIPO_ADD, ZIPO_OR, // 5'h000xx
                ZIPO_SUB=0, ZIPO_AND, ZIPO_ADD, ZIPO_OR, // 5'h000xx
                ZIPO_XOR, ZIPO_LSR, ZIPO_LSL, ZIPO_ASR,         // 5'h001xx
                ZIPO_XOR, ZIPO_LSR, ZIPO_LSL, ZIPO_ASR,         // 5'h001xx
 
#ifdef  LONG_MPY
 
                ZIPO_MPY, ZIPO_LDILO, ZIPO_MPYUHI, ZIPO_MPYSHI, // 5'h010xx
 
#else
                ZIPO_LDIHI, ZIPO_LDILO, ZIPO_MPYU, ZIPO_MPYS,   // 5'h010xx
                ZIPO_LDIHI, ZIPO_LDILO, ZIPO_MPYU, ZIPO_MPYS,   // 5'h010xx
 
#endif
                ZIPO_BREV, ZIPO_POPC, ZIPO_ROL, ZIPO_MOV,       // 5'h011xx
                ZIPO_BREV, ZIPO_POPC, ZIPO_ROL, ZIPO_MOV,       // 5'h011xx
                ZIPO_CMP, ZIPO_TST,                             // 5'h1000x
                ZIPO_CMP, ZIPO_TST,                             // 5'h1000x
                ZIPO_LOD, ZIPO_STO,                             // 5'h1001w
                ZIPO_LOD, ZIPO_STO,                             // 5'h1001w
                ZIPO_DIVU, ZIPO_DIVS,                           // 5'h1010s
                ZIPO_DIVU, ZIPO_DIVS,                           // 5'h1010s
                ZIPO_LDI, ZIPO_LDIn,                            // 5'h1011x
                ZIPO_LDI, ZIPO_LDIn,                            // 5'h1011x
Line 77... Line 100...
                ZIPO_FPADD=0x18, ZIPO_FPSUB,                    // 5'h1100x
                ZIPO_FPADD=0x18, ZIPO_FPSUB,                    // 5'h1100x
                ZIPO_FPMUL, ZIPO_FPDIV,                         // 5'h1101x
                ZIPO_FPMUL, ZIPO_FPDIV,                         // 5'h1101x
                ZIPO_FPCVT, ZIPO_FPINT,                         // 5'h1110x
                ZIPO_FPCVT, ZIPO_FPINT,                         // 5'h1110x
        } ZIPOP;
        } ZIPOP;
 
 
#define ZIPO_MPY        ZIPO_LDIHI
 
#define ZIPO_MPYSHI     ZIPO_MPYS
 
#define ZIPO_MPYUHI     ZIPO_MPYU
 
 
 
        ZIPIMM  brev(ZIPIMM) const;
        ZIPIMM  brev(ZIPIMM) const;
 
 
        ZIPI    op_cmp(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const;
        ZIPI    op_cmp(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const;
        ZIPI    op_cmp(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const;
        ZIPI    op_cmp(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const;
        ZIPI    op_cmp(ZIPIMM imm, ZIPREG b, ZIPREG a) const
        ZIPI    op_cmp(ZIPIMM imm, ZIPREG b, ZIPREG a) const
Line 113... Line 132...
 
 
        ZIPI    op_noop(void) const;
        ZIPI    op_noop(void) const;
        ZIPI    op_break(void) const;
        ZIPI    op_break(void) const;
        ZIPI    op_lock(void) const;
        ZIPI    op_lock(void) const;
 
 
        ZIPI    op_mpy(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const;
#ifdef  LONG_MPY
        ZIPI    op_mpy(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const;
        ZIPI    op_mpy(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const;
//
        ZIPI    op_mpy(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const;
 
        ZIPI    op_mpy(ZIPIMM imm, ZIPREG b, ZIPREG a) const
 
                { return op_mpy(ZIPC_ALWAYS, imm, b, a); }
 
        ZIPI    op_mpy(ZIPIMM imm, ZIPREG a) const
 
                { return op_mpy(ZIPC_ALWAYS, imm, a); }
 
#else
        ZIPI    op_ldihi(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const;
        ZIPI    op_ldihi(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const;
        ZIPI    op_ldihi(ZIPIMM imm, ZIPREG a) const
        ZIPI    op_ldihi(ZIPIMM imm, ZIPREG a) const
                { return op_ldihi(ZIPC_ALWAYS, imm, a); }
                { return op_ldihi(ZIPC_ALWAYS, imm, a); }
 
#endif
        ZIPI    op_ldilo(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const;
        ZIPI    op_ldilo(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const;
        ZIPI    op_ldilo(ZIPIMM imm, ZIPREG a) const
        ZIPI    op_ldilo(ZIPIMM imm, ZIPREG a) const
                { return op_ldilo(ZIPC_ALWAYS, imm, a); }
                { return op_ldilo(ZIPC_ALWAYS, imm, a); }
 
 
 
#ifdef LONG_MPY
 
        ZIPI    op_mpyuhi(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const;
 
        ZIPI    op_mpyuhi(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const;
 
        ZIPI    op_mpyuhi(ZIPIMM imm, ZIPREG b, ZIPREG a) const
 
                { return op_mpyuhi(ZIPC_ALWAYS, imm, b, a); }
 
        ZIPI    op_mpyuhi(ZIPIMM imm, ZIPREG a) const
 
                { return op_mpyuhi(ZIPC_ALWAYS,imm,a); }
 
#else
        ZIPI    op_mpyu(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const;
        ZIPI    op_mpyu(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const;
        ZIPI    op_mpyu(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const;
        ZIPI    op_mpyu(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const;
        ZIPI    op_mpyu(ZIPIMM imm, ZIPREG b, ZIPREG a) const
        ZIPI    op_mpyu(ZIPIMM imm, ZIPREG b, ZIPREG a) const
                { return op_mpyu(ZIPC_ALWAYS, imm, b, a); }
                { return op_mpyu(ZIPC_ALWAYS, imm, b, a); }
        ZIPI    op_mpyu(ZIPIMM imm, ZIPREG a) const
        ZIPI    op_mpyu(ZIPIMM imm, ZIPREG a) const
                { return op_mpyu(ZIPC_ALWAYS, imm, a); }
                { return op_mpyu(ZIPC_ALWAYS, imm, a); }
 
#endif
//
//
        ZIPI    op_mpyuhi(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const
 
                { return op_mpyu(cnd,imm,b,a); }
 
        ZIPI    op_mpyuhi(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const
 
                { return op_mpyu(cnd,imm,a); }
 
 
 
 
#ifdef  LONG_MPY
 
        ZIPI    op_mpyshi(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const;
 
        ZIPI    op_mpyshi(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const;
 
        ZIPI    op_mpyshi(ZIPIMM imm, ZIPREG b, ZIPREG a) const
 
                { return op_mpyshi(ZIPC_ALWAYS, imm, b, a); }
 
        ZIPI    op_mpyshi(ZIPIMM imm, ZIPREG a) const
 
                { return op_mpyshi(ZIPC_ALWAYS, imm, a); }
 
#else
        ZIPI    op_mpys(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const;
        ZIPI    op_mpys(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const;
        ZIPI    op_mpys(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const;
        ZIPI    op_mpys(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const;
        ZIPI    op_mpys(ZIPIMM imm, ZIPREG b, ZIPREG a) const
        ZIPI    op_mpys(ZIPIMM imm, ZIPREG b, ZIPREG a) const
                { return op_mpys(ZIPC_ALWAYS, imm, b, a); }
                { return op_mpys(ZIPC_ALWAYS, imm, b, a); }
        ZIPI    op_mpys(ZIPIMM imm, ZIPREG a) const
        ZIPI    op_mpys(ZIPIMM imm, ZIPREG a) const
                { return op_mpys(ZIPC_ALWAYS, imm, a); }
                { return op_mpys(ZIPC_ALWAYS, imm, a); }
//
#endif
        ZIPI    op_mpyshi(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const
 
                { return op_mpys(cnd,imm,b,a);  }
 
        ZIPI    op_mpyshi(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const
 
                { return op_mpys(cnd,imm,a);    }
 
 
 
        ZIPI    op_rol(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const;
        ZIPI    op_rol(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const;
        ZIPI    op_rol(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const;
        ZIPI    op_rol(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const;
        ZIPI    op_rol(ZIPIMM imm, ZIPREG b, ZIPREG a) const
        ZIPI    op_rol(ZIPIMM imm, ZIPREG b, ZIPREG a) const
                { return op_rol(ZIPC_ALWAYS, imm, b, a); }
                { return op_rol(ZIPC_ALWAYS, imm, b, a); }

powered by: WebSVN 2.1.0

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