File indexing completed on 2025-04-20 08:13:39
0001 /*************************************************************************** 0002 * Copyright (C) 2003,2005 by David Saxton * 0003 * david@bluehaze.org * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 ***************************************************************************/ 0010 0011 #ifndef ASMINFO_H 0012 #define ASMINFO_H 0013 0014 #include <QList> 0015 #include <QString> 0016 #include <QStringList> 0017 0018 /** 0019 @author David Saxton 0020 */ 0021 struct Instruction { 0022 QString operand; 0023 QString description; 0024 QString opcode; 0025 }; 0026 0027 typedef QList<Instruction> InstructionList; 0028 0029 /** 0030 @short Base class for all instruction sets 0031 @author David Saxton 0032 */ 0033 class AsmInfo 0034 { 0035 public: 0036 AsmInfo(); 0037 virtual ~AsmInfo(); 0038 0039 enum Set { PIC12 = 1 << 0, PIC14 = 1 << 1, PIC16 = 1 << 2 }; 0040 enum { AsmSetAll = PIC12 | PIC14 | PIC16 }; 0041 0042 static QString setToString(Set set); 0043 static Set stringToSet(const QString &set); 0044 0045 /** 0046 * @return the instruction set in use 0047 */ 0048 virtual Set set() const = 0; 0049 /** 0050 * Returns a list of instruction operands (all uppercase). 0051 */ 0052 QStringList operandList() const 0053 { 0054 return m_operandList; 0055 } 0056 /** 0057 * @param operand is the name of the instruction - eg 'addwf' or 'clrwdt'. 0058 * @param description is instruction description - eg 'Add W and f'. 0059 * @param opcode is the 14-bit code for the instruction, eg 0060 * '000111dfffffff'for addwf. 0061 */ 0062 void addInstruction(const QString &operand, const QString &description, const QString &opcode); 0063 void addInstruction(const char *operand, const char *description, const char *opcode) 0064 { 0065 addInstruction(QString::fromLatin1(operand), QString::fromLatin1(description), QString::fromLatin1(opcode)); 0066 } 0067 0068 private: 0069 InstructionList m_instructionList; 0070 QStringList m_operandList; 0071 }; 0072 0073 #endif