Line 2... |
Line 2... |
//
|
//
|
// Filename: zparser.h
|
// Filename: zparser.h
|
//
|
//
|
// Project: Zip CPU -- a small, lightweight, RISC CPU core
|
// Project: Zip CPU -- a small, lightweight, RISC CPU core
|
//
|
//
|
// Purpose: The beginnings of a parser for Zip CPU assembly.
|
// Purpose: This file is really mis-named. At one time it was going to
|
|
// be header file for the parser for the Zip Assembler, zasm.
|
|
// Since then, I discovered Flex and Bison and have written a
|
|
// parser using those tools. The true parser may therefore be
|
|
// found in zasm.y. This file, however, still declares some
|
|
// very valuable tools. In particular, all of the routines used
|
|
// to build instructions from the appropriate fields are declared
|
|
// in this file.
|
//
|
//
|
// Creator: Dan Gisselquist, Ph.D.
|
// Creator: Dan Gisselquist, Ph.D.
|
// Gisselquist Tecnology, LLC
|
// Gisselquist Tecnology, LLC
|
//
|
//
|
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
Line 54... |
Line 61... |
typedef enum {
|
typedef enum {
|
ZIPC_ALWAYS, ZIPC_Z, ZIPC_NZ, ZIPC_GE, ZIPC_GT, ZIPC_LT,
|
ZIPC_ALWAYS, ZIPC_Z, ZIPC_NZ, ZIPC_GE, ZIPC_GT, ZIPC_LT,
|
ZIPC_C, ZIPC_V
|
ZIPC_C, ZIPC_V
|
} ZIPCOND;
|
} ZIPCOND;
|
|
|
bool iscomment(const char *line) const;
|
|
bool islabel(const char *line) const;
|
|
bool parse_op(const char *line, ZIPA pc, ZIPI &instruction, const unsigned lineno) const;
|
|
bool parse(const char *line, ZIPA &pc, ZIPI &instruction, const unsigned lineno);
|
|
|
|
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
|
{ return op_cmp(ZIPC_ALWAYS, imm, b, a); }
|
{ return op_cmp(ZIPC_ALWAYS, imm, b, a); }
|