Casio_asm/assembler/assembler.h

68 lines
1.2 KiB
C

#ifndef ASSEMBLER_H
#define ASSEMBLER_H
#include "../common/buffer.h"
#include "../common/opcodeInfo.h"
#include "../common/string.h"
#include "../common/sourceFile.h"
#include "../common/types.h"
#include "assemblerConfig.h"
typedef struct label_t {
int offset; //offset in memory
int hash; //hash of the name
} label_t;
typedef struct opcode_any_t {
char nArgs;
unsigned char code;
char extended;
unsigned char args[2];
unsigned short immediate;
} opcode_any_t;
typedef struct assembler_t {
//offsets in assembled and input code
int offset;
int pos;
//user-friendly line and column indicators
int line;
int col;
//current opcode being read
opcode_any_t op;
//to keep track of the labels
int labelCount;
label_t labels[64];
//input and output streams
buffer_t *in;
buffer_t *out;
buffer_t *stdout;
//current character
char chr;
//current status
char status;
} assembler_t;
int Assembler_assemble(assembler_t *status);
int Assembler_doFile(char* inFile, char* outFile, char* confFile, buffer_t** info);
#define EOPEN1 -1
#define EOPEN2 -2
#define EOPEN3 -3
#define ELEN -4
#define EALLOC -5
#define EREAD -6
#define EWRITE -7
#define EASM -8
#define ECFG -9
#define ETRUNC -10
#define EINIT -11
#endif