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

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [sw/] [zasm/] [asmdata.h] - Diff between revs 13 and 26

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

Rev 13 Rev 26
Line 47... Line 47...
#include <list>
#include <list>
#include "zopcodes.h"
#include "zopcodes.h"
#include "zparser.h"
#include "zparser.h"
 
 
extern  "C" char        *linecp;
extern  "C" char        *linecp;
 
extern  int     yylineno;
 
 
typedef enum {
typedef enum {
//      TST     OPCND
//      TST     OPCND
        // Dual operand instructions that take conditions
        // Dual operand instructions that take conditions
        OP_CMP, OP_TST, OP_MOV, OP_LDIHI, OP_LDILO, OP_MPY, OP_ROL,
        OP_CMP, OP_TST, OP_MOV, OP_LDIHI, OP_LDILO, OP_MPYU, OP_MPYS, OP_ROL,
                OP_SUB, OP_AND, OP_ADD, OP_OR, OP_XOR,
                OP_SUB, OP_AND, OP_ADD, OP_OR, OP_XOR,
                OP_LSL, OP_ASR, OP_LSR,
                OP_LSL, OP_ASR, OP_LSR,
        // Memory operands/operators
        // Memory operands/operators
        OP_LOD, OP_STO,
        OP_LOD, OP_STO,
        // Dual operand instructions that do not take conditions
        // Dual operand instructions that do not take conditions
Line 63... Line 64...
        // Single operand instructions that can take conditions
        // Single operand instructions that can take conditions
        OP_CLRF, OP_JMP, OP_LJMP, OP_NOT,
        OP_CLRF, OP_JMP, OP_LJMP, OP_NOT,
        // Branch operands
        // Branch operands
        OP_BRA, OP_BZ, OP_BNZ, OP_BGE, OP_BGT, OP_BLT, OP_BRC, OP_BRV,
        OP_BRA, OP_BZ, OP_BNZ, OP_BGE, OP_BGT, OP_BLT, OP_BRC, OP_BRV,
        // Single operand instructions that have no explicit conditions
        // Single operand instructions that have no explicit conditions
        OP_CLR, OP_TRAP,
        OP_CLR, OP_TRAP, OP_NEG,
        // BAREOPs that can have conditions
        // BAREOPs that can have conditions
        OP_HALT,  OP_RTU, OP_BUSY,
        OP_HALT,  OP_RTU, OP_BUSY,
        // BAREOPs without conditions
        // BAREOPs without conditions
        OP_BREAK, OP_NOOP,
        OP_BREAK, OP_NOOP,
        // Error condition--undefined operand
        // Error condition--undefined operand
Line 77... Line 78...
#define DEFAULT_LINE    0x4e000000
#define DEFAULT_LINE    0x4e000000
 
 
class   ASMLINE {
class   ASMLINE {
public:
public:
        char    m_state;
        char    m_state;
 
        int     m_lineno;
        virtual bool    isdefined(void) { return true; };
        virtual bool    isdefined(void) { return true; };
        virtual ~ASMLINE(void) {};
        virtual ~ASMLINE(void) {};
        virtual int     nlines(void) { return 0; }
        virtual int     nlines(void) { return 0; }
        virtual unsigned int    eval(const int lno) { return DEFAULT_LINE; }
        virtual unsigned int    eval(const int lno) { return DEFAULT_LINE; }
        virtual void    dump(FILE *fp) = 0;
        virtual void    dump(FILE *fp) = 0;
Line 115... Line 117...
*/
*/
 
 
class   ILINE : public ASMLINE { // Instruction line
class   ILINE : public ASMLINE { // Instruction line
public:
public:
        ZIPI    m_in;
        ZIPI    m_in;
        ILINE(const ZIPI in) : m_in(in) { m_state = 'I'; };
        ILINE(const ZIPI in) : m_in(in) { m_state = 'I'; m_lineno = yylineno; };
        virtual bool    isdefined(void) { return true; };
        virtual bool    isdefined(void) { return true; };
        virtual int     nlines(void) { return 1; }
        virtual int     nlines(void) { return 1; }
        virtual unsigned int    eval(const int lno);
        virtual unsigned int    eval(const int lno);
        void    dump(FILE *fp) { fprintf(fp, "IN: %08x\n", m_in); }
        void    dump(FILE *fp) { fprintf(fp, "IN: %08x\n", m_in); }
};
};
 
 
class   VLINE : public ASMLINE { // Void line
class   VLINE : public ASMLINE { // Void line
public:
public:
        VLINE(void) { m_state = 'V'; };
        VLINE(void) { m_state = 'V'; m_lineno = yylineno; };
        virtual bool    isdefined(void) { return true; };
        virtual bool    isdefined(void) { return true; };
        virtual int     nlines(void) { return 0; }
        virtual int     nlines(void) { return 0; }
        virtual unsigned int    eval(const int lno);
        virtual unsigned int    eval(const int lno);
        void    dump(FILE *fp) { fprintf(fp, "void\n"); }
        void    dump(FILE *fp) { fprintf(fp, "void\n"); }
};
};
 
 
class   DLINE : public ASMLINE { // Data line
class   DLINE : public ASMLINE { // Data line
public:
public:
        ZIPI    m_data;
        ZIPI    m_data;
        DLINE(const ZIPI dat) : m_data(dat) { m_state = 'D'; };
        DLINE(const ZIPI dat) : m_data(dat) { m_state = 'D'; m_lineno = yylineno; };
        virtual bool    isdefined(void) { return true; };
        virtual bool    isdefined(void) { return true; };
        virtual int     nlines(void) { return 1; }
        virtual int     nlines(void) { return 1; }
        virtual unsigned int    eval(const int lno);
        virtual unsigned int    eval(const int lno);
        void    dump(FILE *fp) { fprintf(fp, "\tWORD\t%08d\n", m_data); }
        void    dump(FILE *fp) { fprintf(fp, "\tWORD\t%08d\n", m_data); }
};
};
Line 146... Line 148...
class   LLINE : public ASMLINE { // List line -- one line that has turned into
class   LLINE : public ASMLINE { // List line -- one line that has turned into
                // many
                // many
public:
public:
        int     m_nlines;
        int     m_nlines;
        ASMLINE **m_lines;
        ASMLINE **m_lines;
        LLINE(void) : m_nlines(0), m_lines(NULL) { m_state = 'L'; };
        LLINE(void) : m_nlines(0), m_lines(NULL) { m_state = 'L'; m_lineno = yylineno; };
        void addline(ASMLINE *line) ;
        void addline(ASMLINE *line) ;
        virtual bool    isdefined(void);
        virtual bool    isdefined(void);
        ~LLINE(void);
        ~LLINE(void);
        virtual int     nlines(void) { return m_nlines; }
        virtual int     nlines(void) { return m_nlines; }
        virtual unsigned int    eval(const int lno);
        virtual unsigned int    eval(const int lno);
Line 167... Line 169...
        AST                     *m_imm;
        AST                     *m_imm;
        ZPARSER::ZIPREG         m_opb, m_opa;
        ZPARSER::ZIPREG         m_opb, m_opa;
 
 
        TLINE(void) : m_opcode(OP_NONE), m_cond(ZPARSER::ZIPC_ALWAYS),
        TLINE(void) : m_opcode(OP_NONE), m_cond(ZPARSER::ZIPC_ALWAYS),
                        m_imm(NULL), m_opa(ZPARSER::ZIP_Rnone), m_opb(ZPARSER::ZIP_Rnone)
                        m_imm(NULL), m_opa(ZPARSER::ZIP_Rnone), m_opb(ZPARSER::ZIP_Rnone)
                        { m_state = 'T'; };
                        { m_state = 'T'; m_lineno = yylineno; };
        virtual bool    isdefined(void) {
        virtual bool    isdefined(void) {
                if (m_imm != NULL) {
                if (m_imm != NULL) {
                        bool answer = m_imm->isdefined();
                        bool answer = m_imm->isdefined();
                        return answer;
                        return answer;
                } else return true;
                } else return true;
Line 258... Line 260...
        FILE            *m_fp;
        FILE            *m_fp;
 
 
public:
public:
        OBJFILE(void) { m_fp = NULL; m_pc = 0; }
        OBJFILE(void) { m_fp = NULL; m_pc = 0; }
        void open(const char *fname);
        void open(const char *fname);
 
        void close(void) { fclose(m_fp); };
        unsigned int pc(void) { return m_pc; }
        unsigned int pc(void) { return m_pc; }
        void    operator+=(ASMLINE *ln);
        void    operator+=(ASMLINE *ln);
        bool    reduce(void);
        bool    reduce(void);
};
};
 
 

powered by: WebSVN 2.1.0

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