13 #include <unordered_map> 32 virtual const bool handleKeyPress(
const GdkEventKey*
const e)
override;
55 const Gtk::StateFlags
NORMAL = Gtk::STATE_FLAG_DIR_LTR;
62 Gtk::STATE_FLAG_DIR_LTR | Gtk::STATE_FLAG_ACTIVE;
68 Gtk::STATE_FLAG_DIR_LTR | Gtk::STATE_FLAG_FOCUSED;
75 Gtk::STATE_FLAG_FOCUSED |
76 Gtk::STATE_FLAG_ACTIVE;
90 const std::unordered_map<std::string, std::string>
mnemonicsMap = {
92 {
"swi 0",
"Printing character"},
93 {
"swi 1",
"Reading character"},
94 {
"swi 2",
"Halting execution"},
95 {
"swi 3",
"Printing string"},
96 {
"swi 4",
"Printing integer"},
98 {
"defw",
"defined as integer ?1?"},
99 {
"defb",
"Defined as string ?1?"},
100 {
"beq",
"Branch to label ?1? if equal"},
101 {
"blt",
"Branch to label ?1? if less than"},
102 {
"bne",
"Branch to label ?1? if not equal"},
103 {
"bgt",
"Branch to label ?1? if greater than"},
104 {
"b",
"Branch to label ?1?"},
106 {
"mov",
"Move ?2? into ?1?"},
107 {
"adr",
"Value at ?2? moves into ?1?"},
108 {
"adrl",
"Value at ?2? moves into ?1?"},
109 {
"cmp",
"Compare ?1? to ?2?"},
110 {
"cmn",
"Negatively compare ?1? to ?2?"},
111 {
"str",
"Store ?1? in ?2?"},
112 {
"ldr",
"Stores ?2? in ?1?"},
114 {
"sub",
"Subtract ?3? from ?2? and store in ?1?"},
115 {
"add",
"Add ?3? to ?2? and store in ?1?"},
116 {
"mul",
"Multiply ?3? with ?2? and store in ?1?"},
117 {
"and",
"bitwise and ?2? with ?3? and store in ?1?"},
118 {
"orr",
"bitwise or ?2? with ?3? and store in ?1?"},
120 {
"mla",
"Multiply ?2? with ?3? , add ?4? and store in ?1?"},
121 {
"mls",
"Multiply ?2? with ?3? , subtract ?4? and store in ?1?"}};
138 const uint32_t address);
143 const std::string
toLowerCase(std::string s)
const;
144 const std::vector<std::string>
parseDEFB(std::vector<std::string> v)
const;
145 const std::vector<std::string>
parseSWI(std::vector<std::string> m)
const;
146 const std::pair<std::vector<std::string>, std::string>
parseLabel(
147 std::vector<std::string> m)
const;
149 std::vector<std::string> m)
const;
void setEnglishMnemonic(const bool val)
Set the value of the englishMnemonic member variable.
The declaration of the DisassemblyModel class.
const Gtk::StateFlags NORMAL
The CSS state flags for an un-highlighted memory row.
A single instance of this class represents a single read memory address and the associated data - thi...
virtual const bool handleKeyPress(const GdkEventKey *const e) override
Handles any key press events.
const Gtk::StateFlags PC_ADDRESS_FOCUSED
The CSS state flags for e memory row that has keyboard focus and is currently stored in the Program C...
const Gtk::StateFlags FOCUSED
The CSS state flags for a memory row that has keyboard focus.
const std::unordered_map< std::string, std::string > mnemonicsMap
A map pairing ARM mnemonic commands with the English translation string associated with them for the ...
DisassemblyModel(DisassemblyView *const view, KoMo2Model *const parent)
Construct a new DisassemblyModel::DisassemblyModel object.
KoMo2Model *const parent
All models have a parent model - KoMo2Model, the most senior model in the hierarchy, sets its parent to self.
const std::string toLowerCase(std::string s) const
Converts a string to lower case.
void onBreakpointToggle(DisassemblyRows *const row)
Handle the toggling of a breakpoint within the DisassemblyView.
bool englishMnemonic
Whether or not ARM mnemonics should be read in English when being read by a screenreader, or if they should be left as ARM mnemonics.
const std::string intToFormattedHexString(const uint32_t formatMe) const
Converts a fixed width 32-bit integer to a hex string, padded with 0's to 8 characters, pre-fixed with "0x", and raised to all capitals.
JimulatorState
Describe the 5 states of Jimulator.
const std::string buildMnemonicString(std::string s, std::vector< std::string > m) const
Builds the output mnemonics string from the vector making up the current ARM command and the value re...
void setupButtonHandlers()
Adds button handlers to every breakpoint button.
void updateCSSFlags(const Gtk::StateFlags state, DisassemblyRows &row, const uint32_t address)
Handles setting the CSS flags for each disassembly row, which determines which CSS class it uses and ...
DisassemblyView *const view
The view this model represents.
static uint32_t memoryIndex
Fixed width integer representing the memory address of the view at the top of the container...
The superclass for all other Model classes. Uses a pure virtual function, so is abastract. Keeps KoMo2Model as a friend so it alone can call setJimulatorState. This class provides basic data that are needed by all other.
const Gtk::StateFlags PC_ADDRESS
The CSS state flags for if the memory row is currently stored in the Program Counter.
void refreshViews()
Refreshes the values in the views to display the new values fetched from Jimulator.
const std::string sanitizeParamters(std::string param) const
Sanitizes any of the paramters used with an ARM mnemonic.
virtual void changeJimulatorState(const JimulatorState newState) override
Handles changes of Jimulator state.
const std::string buildDisassemblyRowAccessibilityString(DisassemblyRows &val)
Generates the string to set for the accessibility model.
void incrementMemoryIndex(const uint32_t val)
Updates the list pointers to a new value. Val is multipled by 4 - for example, if val is 1...
The file containing the declaration of the class TerminalModel, which represents all of the data and ...
std::string PCValue
Stores the value currently in the program counter.
const std::string convertMnemonicToEnglish(const std::string mnemonic) const
Converts a mnemonic into plain English.
The logical model of the entire application. All other models should be member variables of this mode...
Represents the entire disassembly window in the overall KoMo2 GUI. Contains several rows of memory va...
void addScrollRecognition()
Adds scroll recognition to the container object, which causes scroll events to be sent to the member ...
const std::vector< std::string > parseDEFB(std::vector< std::string > v) const
Parses the DEFB ARM mnemonic - since a single ARM command is broken into a vector by the spaces betwe...
const std::array< Jimulator::MemoryValues, 13 > getMemoryValues() const
Reads memory values from Jimulator.
const std::pair< std::vector< std::string >, std::string > parseLabel(std::vector< std::string > m) const
Parses labels from an ARM command. If the first index in the vector is not a recognised keyword...
void setPCValue(const std::string val)
Updates the value of PCValue.
const bool handleScroll(GdkEventScroll *const e)
Handles the scroll events.
DisassemblyView *const getView()
Returns a pointer to the view object.
const std::vector< std::string > parseSWI(std::vector< std::string > m) const
Parses the SWI ARM mnemonic - the SWI command always takes 1 paramter, but means very different thing...