Initial commit of files related to NED architecture.
[ned1] / nedasm / nedasm_structures.h
/*
* © 2018 Aaron Taylor <ataylor at subgeniuskitty dot com>
* See LICENSE.txt file for copyright and license details.
*/
#ifndef NEDASM_STRUCTURES_H
#define NEDASM_STRUCTURES_H
#include <stdint.h>
/* This enumeration is slightly misnamed since, in addition to syllables, it also includes WORD. */
/* And now includes LABELs, not even a real instruction. TODO: Fix either the name or purpose. */
enum syllables {
/* Manually assign values so that 0 remains unassigned, use for uninitialized value. */
WORD = 1,
MVSTCK = 2,
ADD = 3,
XOR = 4,
NOT = 5,
OR = 6,
AND = 7,
BRZ = 8,
TEST = 9,
CMPSWP = 10,
SHIFT = 11,
STORE = 12,
LOAD = 13,
NOP = 14,
HALT = 15,
IM = 16,
LDSP = 17,
STSP = 18,
JMP = 19,
SWAP = 20,
LABEL = 21
};
struct instruction {
/* Pointer to previous entry in list. NULL indicates start of list. */
struct instruction * prev;
/* Pointer to next entry in list. NULL indicates end of list. */
struct instruction * next;
/* Line number of the source file in which this instruction was commanded. */
uint32_t linenum;
/* Specifies the type of instruction this struct represents. */
enum syllables syllable;
/* Contains data value for instructions containing embedded data. */
/* (WORD_x, IM_x, LDSP+x, STSP+x, etc) */
int32_t data;
/* Stores the target label string for instructions that alter PC. */
/* NULL if the address to jump to was already placed on TOS by other instructions. */
/* (BRZ, JMP, etc) */
char * target;
/* Stores the label name if this instruction is a label target. */
char * label;
/* Address in RAM of this instruction. Generated during assembly as an offset. */
uint32_t address;
};
struct instruction * create_instruction_struct(void);
struct instruction * seek_instruction_list_start(struct instruction * instructions);
struct instruction * seek_instruction_list_end(struct instruction * instructions);
void insert_NOP_structs_after(struct instruction * list, uint8_t count);
void insert_NOP_structs_before(struct instruction * list, uint8_t count);
struct instruction * remove_instruction_struct(struct instruction * instructions);
#endif