s502 assembler
A very simple assembler for the 6502 line of processors written in C
|
linked list member holding instruction data More...
#include <instructions.h>
Public Member Functions | |
Instruction * | instruction_load (char *fname) |
Load instruction data from CSV file. More... | |
Instruction * | instruction_find (Instruction *list, char *mnem) |
find the Instruction entry for a given mnemonic More... | |
void | instruction_free (Instruction *list) |
free all memory associated with an Instruction* list More... | |
void | instruction_print (Instruction *instr) |
fancy-print one instruction data More... | |
void | instruction_print_all (Instruction *list) |
debug-print all instructions in a list More... | |
Data Fields | |
char | mnem [4] |
3-letter mnemonic of an instruction + trailing 0 More... | |
unsigned char | opcs [ADRM_COUNT] |
Different combinarions of this instruction. Invalid ones are set to OPC_INVALID. More... | |
struct Instruction * | next |
Next instruction pointer on NULL. More... | |
linked list member holding instruction data
Member of a list which holds data about instructions and opcodes.
This list should be loaded from file using instruction_load()
Definition at line 25 of file instructions.h.
Instruction * instruction_find | ( | Instruction * | list, |
char * | mnem | ||
) |
find the Instruction entry for a given mnemonic
list | linked list head containing loaded instructions |
mnem | pointer to string to seatch for |
Searches the linked list for an instruction entry.
Only checks the first 3 characters, so there is no need to copy the data on the caller side.
Definition at line 111 of file instructions.c.
Referenced by Token::token_link_instruction().
void instruction_free | ( | Instruction * | list | ) |
free all memory associated with an Instruction* list
list | list to free |
Frees all memory associated with the instruction data linked list, including the list head.
Invalidates all pointers to any data within the list, so they should be all NULL-ed!
Definition at line 121 of file instructions.c.
Referenced by instruction_load(), and state_free().
Instruction * instruction_load | ( | char * | fname | ) |
Load instruction data from CSV file.
fname | CSV file name/path to load from |
Opens the file, parses CSV and returns instruction data.
Checks for simple problems. Prints errors.
Returns NULL on error, and linked list (withut sentinel) otherwise.
Works both on Windows and Linux platforms with the same files.
Definition at line 18 of file instructions.c.
Referenced by state_load_instr().
void instruction_print | ( | Instruction * | instr | ) |
fancy-print one instruction data
instr | instruction list entry to print |
Fancy-print all data associated with one instruction (mnemonic, address modes and opcodes for them).
Useful for error reporting and debugging.
Definition at line 132 of file instructions.c.
Referenced by instruction_print_all(), and pass_one().
void instruction_print_all | ( | Instruction * | list | ) |
debug-print all instructions in a list
list | list of instructions to print |
Fancy-print all instructions from the list using instruction_print()
Useful for debugging
Definition at line 141 of file instructions.c.
char Instruction::mnem[4] |
3-letter mnemonic of an instruction + trailing 0
Definition at line 27 of file instructions.h.
Referenced by instruction_find(), instruction_load(), and instruction_print().
struct Instruction* Instruction::next |
Next instruction pointer on NULL.
Definition at line 31 of file instructions.h.
Referenced by instruction_find(), instruction_free(), instruction_load(), and instruction_print_all().
unsigned char Instruction::opcs[ADRM_COUNT] |
Different combinarions of this instruction. Invalid ones are set to OPC_INVALID.
Definition at line 29 of file instructions.h.
Referenced by instruction_load(), and instruction_print().