1 /*************************************************************************** 2 * Copyright (C) 2003,2005 by David Saxton * 3 * david@bluehaze.org * 4 * * 5 * This program is free software; you can redistribute it and/or modify * 6 * it under the terms of the GNU General Public License as published by * 7 * the Free Software Foundation; either version 2 of the License, or * 8 * (at your option) any later version. * 9 ***************************************************************************/ 10 11 #ifndef ASMINFO_H 12 #define ASMINFO_H 13 14 #include <QString> 15 #include <QStringList> 16 #include <QList> 17 18 /** 19 @author David Saxton 20 */ 21 struct Instruction 22 { 23 QString operand; 24 QString description; 25 QString opcode; 26 }; 27 28 typedef QList<Instruction> InstructionList; 29 30 /** 31 @short Base class for all instruction sets 32 @author David Saxton 33 */ 34 class AsmInfo 35 { 36 public: 37 AsmInfo(); 38 virtual ~AsmInfo(); 39 40 enum Set 41 { 42 PIC12 = 1 << 0, 43 PIC14 = 1 << 1, 44 PIC16 = 1 << 2 45 }; 46 enum { AsmSetAll = PIC12 | PIC14 | PIC16 }; 47 48 static QString setToString( Set set ); 49 static Set stringToSet( const QString & set ); 50 51 /** 52 * @return the instruction set in use 53 */ 54 virtual Set set() const = 0; 55 /** 56 * Returns a list of instruction operands (all uppercase). 57 */ operandList()58 QStringList operandList() const { return m_operandList; } 59 /** 60 * @param operand is the name of the instruction - eg 'addwf' or 'clrwdt'. 61 * @param description is instruction description - eg 'Add W and f'. 62 * @param opcode is the 14-bit code for the instruction, eg 63 * '000111dfffffff'for addwf. 64 */ 65 void addInstruction( const QString &operand, const QString &description, const QString &opcode ); addInstruction(const char * operand,const char * description,const char * opcode)66 void addInstruction( const char* operand, const char* description, const char* opcode ) { 67 addInstruction(QString::fromLatin1(operand),QString::fromLatin1(description), QString::fromLatin1(opcode)); 68 } 69 70 private: 71 InstructionList m_instructionList; 72 QStringList m_operandList; 73 }; 74 75 #endif 76