s502 assembler
A very simple assembler for the 6502 line of processors written in C
|
Go to the documentation of this file. 1 #include "debugmalloc.h"
3 #define __USE_MINGW_ANSI_STDIO 1
21 ERROR(
"Memory allocation error in tokenslist_new()!\n");
33 if (elem == NULL)
goto ERR_MEM;
37 if (!elem->
token)
goto ERR_MEM;
39 if (list->
head == NULL) {
55 ERROR(
"Memory allocation error in tokenslist_add()!\n");
68 if (el->
prev != NULL) {
80 while (list->
head != NULL) {
90 LOG(0,
"Dumping code:\n");
100 if (src->
head == NULL)
120 FAIL(
"Can not recognize token types!\n");
void tokenslist_free(TokensList *list)
free ALL memory associated with the TokensList object
int tokenslist_add(TokensList *list, Token t)
Append a token to the list.
Token * token
Token value.
TokensListElement * tail
tail (last element) pointer
void tokenslist_debug_print(TokensList *list)
Pretty-print all tokens in a list.
#define LOG(LVL,...)
logging macro - works like printf
struct TokensListElement * prev
prev element in list or NULL
struct TokensListElement * next
next element in list or NULL
Token type to store token information.
TokensListElement * head
head (first element) of the list
An element of a TokensList.
int tokenslist_recognize(TokensList *t)
Do token recognition on all tokens in a list.
Token type member methods.
A doubly-linked list for storing Tokens.
void token_print(Token *token)
Pretty-print one token, with its source and length.
int token_recognize(Token *t)
Parse token - test if it's an opcode, a label or a directive.
logging and fancy-printing
TokensListElement * tokenslist_remove(TokensList *list, TokensListElement *el)
remove a token from the list
void tokenslist_insert(TokensList *list, TokensListElement *target, TokensList *src)
Insert the contents of SRC into another list after an element.
TokensList * tokenslist_new()
Create a new (empty) TokensList object.
#define FAIL(...)
Fancy-print a fail (failed step). Works like printf.
#define ERROR(...)
Fancy-print an error (cause of faliure). Works like printf.