compilator-2000/asm_instructions.h
Arnaud Vergnet a1c0f7a19f add if
2021-04-06 18:17:10 +02:00

49 lines
1 KiB
C

#ifndef COMPILATOR_2000_ASM_INSTRUCTIONS_H
#define COMPILATOR_2000_ASM_INSTRUCTIONS_H
#include <stdio.h>
#include "symbol_table.h"
#define INSTRUCTION_TABLE_SIZE 100
typedef enum Instruction {
ADD,
MUL,
SOU,
DIV,
COP,
AFC,
JMP,
JMF,
INF,
SUP,
EQU,
PRI
} Instruction;
char* instructions_labels[12];
typedef struct InstructionItem {
Instruction instruction;
int arg1;
int arg2;
int arg3;
} InstructionItem;
typedef struct InstructionTable {
InstructionItem table[INSTRUCTION_TABLE_SIZE];
int index;
} InstructionTable;
void init_instruction_table(InstructionTable *table);
int add_instruction(InstructionTable *table, Instruction instruction, int arg1, int arg2, int arg3);
void write_instruction_table(InstructionTable *table, FILE *file);
void write_instruction(InstructionItem *item, FILE *file);
int get_current_address(InstructionTable *table);
#endif //COMPILATOR_2000_ASM_INSTRUCTIONS_H