49 lines
1.0 KiB
C
49 lines
1.0 KiB
C
#ifndef OPCODES_H
|
|
#define OPCODES_H
|
|
|
|
#include <string.h>
|
|
#include "symbols_table.h"
|
|
|
|
typedef enum {
|
|
R1, R2, R3, R4, R5, R6, R7, R8
|
|
} Registers;
|
|
|
|
typedef enum {
|
|
COPY, ADD, SUB, JZ, INT, YLD, RET,
|
|
CMP, NOP, JMP, CALL, IN, OUT,
|
|
} Mnemonic;
|
|
|
|
typedef enum {
|
|
NoParameter,
|
|
ConstantParameter,
|
|
AddressParameter,
|
|
RegisterParameter
|
|
} OpcodeParameter;
|
|
|
|
typedef struct {
|
|
Mnemonic Mnemonic;
|
|
OpcodeParameter ParameterOneType;
|
|
OpcodeParameter ParameterTwoType;
|
|
|
|
union {
|
|
int Constant;
|
|
Symbol* Symbol;
|
|
} ParameterOne;
|
|
|
|
union {
|
|
int Constant;
|
|
Symbol* Symbol;
|
|
} ParameterTwo;
|
|
} Instruction;
|
|
|
|
//extern Instruction instructions[OPCODECOUNT];
|
|
|
|
Instruction* CreateInstruction(Mnemonic mnemonic);
|
|
void FreeInstruction(Instruction* instruction);
|
|
int IsOpcode(const char*, Mnemonic*);
|
|
int IsRegister(const char*, Registers*);
|
|
void GetMnemonicText(Mnemonic mnemonic, char buffer[12]);
|
|
//const Instruction* GetOpcodeDetails(Mnemonic);
|
|
unsigned char GetInstructionMask(Mnemonic type);
|
|
|
|
#endif |