⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 listfile_h.h

📁 MCS-51单片机宏汇编器源程序,单片机初学者必看
💻 H
字号:
//---------------------------------------------------------------------------
//-------- ListFile_H.h ------------------------------------------------------
//---------------------------------------------------------------------------
#ifndef	ListFile_H.h  // 防止被重复引用
#define ListFile_H.h
//---------------------------------------------------------------------------
#include <time.h>

#include "JsGlobal_H.h"
#include "Tokenfield_H.h"
#include "AsmF_H.h"
#include "TriVal_H.h"
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
//
//                            列表文件管理器
//
//---------------------------------------------------------------------------
class LISTFile : public JObject
{ private:
   class MacroAsmber& masm;         // 指向父类。
          FILE* OutputFile;   // 输出文件。
       AsmLine* &CurAsmLn;    // 当前汇编行指针。
    Tokenfield* TknPt;        // 当前Token指针。
       Jstring  FileName;     // 列表文件的文件名。
    union
    { struct
      { bool symbols :1;      // 是否列出符号表。
        bool Xref    :1;      // 是否列出交叉参考表。
        bool List    :1;      // 是否列出后续源文件。
        bool Gen     :1;      // 是否列出宏展开。
        bool LastOK  :1;      // 续行否(上一行完成否)。
        bool SrcEnd  :1;      // 源文件读完否。
        bool InMacro :1;      // 在宏体中否。
        bool         :1;      // 备用。
      } setn; // end struct
      int8u setting;          // 标志设定组。
    }; // end union
          int8u Cursor;       // 当前光标。
         int16u CurTextLn;    // 当前文本行号。

         int16u LineCount;    // 页面中的行计数器。
         int16u PageCount;    // 换页计数器。

    Jstring  Title;           // 标题。
      int16u PageLength;      // 一页的最大行数。
       int8u PageWidth;       // 一页的最大列数。

    struct JDate              // 产生列表文件时的日期。
    { int16u year;
       int8u month;
       int8u day;
    } jdate; // end Date

    TokenStack SaRs_Stk;      // 给Save和Restore使用的栈。

  // ------ private functions ------

    void GenSrcText();         // 产生一个源文本(一行的右栏)。

    bool GenALeftLine();       // 产生一行的左栏。返回true表示finished。

    void MinorCtrlAct(AsmLine* line); // 次要控制指令执行子程序。


  public:

     LISTFile(MacroAsmber& msm, const Jstring &filename); // constructor

    ~LISTFile()       {}                                   // destructor

   // 字符数据区。
    static const char* hebk;   // "------------------";
    static const char* Debk;   // "==================";

   // ------ public functions ------

   const Jstring& GetName()  { return FileName; } // end GetName

    void OpenFileForWrite();   // 为OutputFile赋初值。

    void CloseFile();          // 关闭列表文件。

    void GenListHeader();      // 产生列表文件头。

    void GenPageHeader();      // 产生页头。

    void PrintTheErrWarn(Tokenfield* &pt); // 产生警告或错误行。

    void GenOBJList();         // 产生一个OBJ列表。

    void GenRegBankUsed();     // 产生一个寄存器组使用情况表。

    void PrintSymbolTable();   // 产生一个Symbol列表。

  //---------------------------
  friend class MacroAsmber;
}; // end LISTFile
//---------------------------------------------------------------------------


//---------------------------------------------------------------------------
const int8u SRCbound = 18;     // 右栏界
const int8u Fixbound = 16;     // 在此处打印一个'F'
//---------------------------------------------------------------------------


//---------------------------------------------------------------------------
// 把光标移到右栏上。
//---------------------------------------------------------------------------
#define TABtheSRC(tp,cur)  for(;(cur)<SRCbound;++(cur)) {putc(' ',(tp));}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// 在当前光标位置打印当前地址值(LOC)。
//---------------------------------------------------------------------------
#define PRLineLOC(tp,cur,lc)  fprintf((tp),"%4.4X  ",(lc)); (cur)+=6;
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// 把光标移到恰当的地方,打印'F'。
//---------------------------------------------------------------------------
#define PRFixChar(tp,cur)  for(;(cur)<Fixbound;++(cur)) {putc(' ',(tp));}       \
                           putc('F',(tp)); ++(cur);
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// 打开列表文件, 准备写入。
// 该函数为OutputFile赋初始值。
//---------------------------------------------------------------------------
inline void LISTFile::OpenFileForWrite()
{ OutputFile = fopen((const char*)FileName, "w");
  if(OutputFile == NULL)
   { printf("\nCannot open file %s!", FileName()); } // endif
} // end OpenFileForWrite
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// 关闭列表文件。
//---------------------------------------------------------------------------
inline void LISTFile::CloseFile()
{ if(fclose(OutputFile))
   { printf("\nClose file %s error.", FileName()); } // endif
} // end CloseFile
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------
//               Written by JamesyFront.    ZLGmcu Dev.Co.Ltd.  2002.
//---------------------------------------------------------------------------


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -