Change Parser to use defines.h
MODIFY
src/defines.h
src/defines.h
#include <cstdint>
-typedef struct {
- int type;
- uint32_t word;
-} Instruction;
-
enum instrType {
LUI = 0b0110111,
JAL = 0b1101111,
@@ -17,6 +12,12 @@ enum instrType {
STORE = 0b0100011,
OP_IMM = 0b0010011,
OP = 0b0110011,
+ INVALID = 0b0
};
+typedef struct {
+ instrType type = INVALID;
+ uint32_t word = 0;
+} Instruction;
+
#endif // DEFINES_H

MODIFY
src/parser.cpp
src/parser.cpp
Parser::Parser(char *fileName) {}
-int Parser::decodeInstruction(uint32_t word) {}
+instrType Parser::getOpType(uint32_t word) { return INVALID; }
+
+Instruction Parser::getInstruction() const { return m_currentInstruction; }

MODIFY
src/parser.h
src/parser.h
#ifndef PARSER_H
#define PARSER_H
-#include <cstdint>
+#include "defines.h"
class Parser {
public:
Parser(char *fileName);
~Parser();
- int getInstruction(int byteOffset = 4);
+ bool parseInstruction(int byteOffset = 4);
uint32_t readWord();
- int decodeInstruction(uint32_t word);
+ instrType getOpType(uint32_t word);
+
+ Instruction getInstruction() const;
private:
+ Instruction m_currentInstruction;
// FILE *filePtr;
};

Change Parser to use defines.h