2020-11-18 17:53:23 -05:00
|
|
|
#ifndef ASSEMBLER_H
|
|
|
|
#define ASSEMBLER_H
|
|
|
|
#include <stdio.h>
|
2020-11-20 18:24:02 -05:00
|
|
|
#include "parser.h"
|
2020-11-18 17:53:23 -05:00
|
|
|
|
|
|
|
#define RAM_LIMIT 24577
|
|
|
|
#define TOP_VAR 16383
|
|
|
|
#define BOTTOM_VAR 16
|
|
|
|
#define INST_SIZE 17
|
|
|
|
#define C_TOKEN_SIZE 4
|
|
|
|
|
|
|
|
typedef struct {
|
2020-11-20 18:24:02 -05:00
|
|
|
char* name;
|
|
|
|
int value;
|
2020-11-18 17:53:23 -05:00
|
|
|
} SYMBOL;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
SYMBOL** items;
|
|
|
|
int count;
|
|
|
|
int size;
|
|
|
|
} SYMBOLARRAY;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int maxwidth;
|
|
|
|
int truelnscount;
|
|
|
|
int lncount;
|
|
|
|
|
2020-11-20 18:24:02 -05:00
|
|
|
LINELIST* lns;
|
2020-11-18 17:53:23 -05:00
|
|
|
|
|
|
|
SYMBOLARRAY* labels;
|
|
|
|
|
|
|
|
SYMBOLARRAY* vars;
|
2020-11-20 18:24:02 -05:00
|
|
|
int varsramind;
|
2020-11-18 17:53:23 -05:00
|
|
|
} ASSEMBLER;
|
|
|
|
|
2020-11-20 18:24:02 -05:00
|
|
|
ASSEMBLER* mkassembler(LINELIST* input);
|
2020-11-18 17:53:23 -05:00
|
|
|
void preprocess(ASSEMBLER* a);
|
|
|
|
void translate(ASSEMBLER* a);
|
|
|
|
void freeassembler(ASSEMBLER* a);
|
|
|
|
#endif
|