summaryrefslogtreecommitdiffstats
path: root/src/micro/asminfo.h
blob: c2bc0bf7e5c1420dd969b5dd3186306587b02908 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/***************************************************************************
 *   Copyright (C) 2003,2005 by David Saxton                               *
 *   david@bluehaze.org                                                    *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/

#ifndef ASMINFO_H
#define ASMINFO_H

#include <tqstring.h>
#include <tqstringlist.h>
#include <tqvaluelist.h>

/**
@author David Saxton
*/
struct Instruction
{
	TQString operand;
	TQString description;
	TQString opcode;
};
typedef TQValueList<Instruction> InstructionList;

/**
@short Base class for all instruction sets
@author David Saxton
*/
class AsmInfo
{
public:
	AsmInfo();
	virtual ~AsmInfo();
	
	enum Set
	{
		PIC12	= 1 << 0,
		PIC14	= 1 << 1,
		PIC16	= 1 << 2
	};
	enum { AsmSetAll = PIC12 | PIC14 | PIC16 };
	
	static TQString setToString( Set set );
	static Set stringToSet( const TQString & set );
	
	/**
	 * @return the instruction set in use
	 */
	virtual Set set() const = 0;
	/**
	 * Returns a list of instruction operands (all uppercase).
	 */
	TQStringList operandList() const { return m_operandList; }
	/**
	 * @param operand is the name of the instruction - eg 'addwf' or 'clrwdt'.
	 * @param description is instruction description - eg 'Add W and f'.
	 * @param opcode' is the 14-bit code for the instruction, eg
	 * '000111dfffffff'for addwf.
	 */
	void addInstruction( const TQString &operand, const TQString &description, const TQString &opcode );
	
private:
	InstructionList m_instructionList;
	TQStringList m_operandList;
};

#endif