XiPU uROM Generator
instruction.cpp
Go to the documentation of this file.
1 /*
2  * Author: Pawel Jablonski
3  * E-mail: pj@xirx.net
4  * WWW: xirx.net
5  * GIT: git.xirx.net
6  *
7  * License: You can use this code however you like
8  * but leave information about the original author.
9  * Code is free for non-commercial and commercial use.
10  */
11 
12 #include "instruction.h"
13 
14 //! Default constructor for creating an empty instruction
16 {
17  this->opcode = 0;
18 
19  this->arg0 = Arg::None;
20  this->arg1 = Arg::None;
21  this->arg2 = Arg::None;
22 
23  this->c = Flag::Any;
24  this->z = Flag::Any;
25 }
26 
27 /**
28  * Constructor using for create an instruction with a defined opcode
29  *
30  * @param opcode Opcode number
31  * @param arg0 First argument type
32  * @param arg1 Second argument type
33  * @param arg2 Third argument type
34  * @param c Which status of the carry flag is accepted
35  * @param z Which status of the zero flag is accepted
36  */
37 Instruction::Instruction(unsigned char opcode, Arg arg0, Arg arg1, Arg arg2, Flag c, Flag z)
38 {
39  this->opcode = opcode;
40 
41  this->arg0 = arg0;
42  this->arg1 = arg1;
43  this->arg2 = arg2;
44 
45  this->c = c;
46  this->z = z;
47 }
48 
49 /**
50  * Add step to the step list of the instruction
51  *
52  * @param step Single step of the instruction
53  */
54 void Instruction::addStep(const Step &step)
55 {
56  this->stepList.append(step);
57 }
58 
59 /**
60  * Get an opcode number of the instruction
61  *
62  * @return Opcode of the instruction
63  */
64 unsigned char Instruction::getOpcode() const
65 {
66  return(this->opcode);
67 }
68 
69 /**
70  * Get a first argument type of the instruction
71  *
72  * @return Argument type
73  */
75 {
76  return(this->arg0);
77 }
78 
79 /**
80  * Get a second argument type of the instruction
81  *
82  * @return Argument type
83  */
85 {
86  return(this->arg1);
87 }
88 
89 /**
90  * Get a third argument type of the instruction
91  *
92  * @return Argument type
93  */
95 {
96  return(this->arg2);
97 }
98 
99 /**
100  * Get a status of accepting the carry flag
101  *
102  * @return Accepting status of the carry flag
103  */
105 {
106  return(this->c);
107 }
108 
109 /**
110  * Get a status of accepting the zero flag
111  *
112  * @return Accepting status of the zero flag
113  */
115 {
116  return(this->z);
117 }
118 
119 /**
120  * Get a step list of the instruction
121  *
122  * @return Step list of the instruction
123  */
124 const QList<Step> &Instruction::getStepList() const
125 {
126  return(this->stepList);
127 }
Flag
Tristate flag definition for carry and zero control bits.
Definition: instruction.h:35
@ Any
Accept both values.
Arg arg0
First argument type.
Definition: instruction.h:60
Arg getArg0() const
Definition: instruction.cpp:74
Arg
Definitions of the instruction argument types.
Definition: instruction.h:25
@ None
No argument.
Arg getArg2() const
Definition: instruction.cpp:94
Flag getZ() const
void addStep(const Step &step)
Definition: instruction.cpp:54
Flag c
Carry flag accept status.
Definition: instruction.h:64
Flag z
Zero flag accept status.
Definition: instruction.h:65
unsigned char getOpcode() const
Definition: instruction.cpp:64
Arg getArg1() const
Definition: instruction.cpp:84
QList< Step > stepList
Atomic list of steps for the control unit.
Definition: instruction.h:67
unsigned char opcode
Opcode of defined instruction.
Definition: instruction.h:58
const QList< Step > & getStepList() const
Arg arg1
Second argument type.
Definition: instruction.h:61
Instruction()
Default constructor for creating an empty instruction.
Definition: instruction.cpp:15
Flag getC() const
Arg arg2
Third argument type.
Definition: instruction.h:62
Definition: step.h:24