s502 assembler
A very simple assembler for the 6502 line of processors written in C
|
Go to the documentation of this file.
31 FAIL(
"Pass 1 init failed!\n");
40 LOG(4,
"Processing token:\n");
61 ERROR(
"More endif's than if's!\n");
82 LOG(3,
"Instruction: \n");
94 ERROR(
"Label is too long!");
104 #pragma GCC diagnostic push
105 #pragma GCC diagnostic ignored "-Wstringop-truncation"
108 #pragma GCC diagnostic pop
109 LOG(5,
"Label: %s\n", labelname);
112 ERROR(
"Can not re-define label '%s'\n", labelname);
119 LOG(3,
"Set label: '%s' to %d\n", labelname, s->
PC);
140 FAIL(
"Pass 1 failed!\n");
Map * labels
label locations
@ TT_INSTR
instruction token
struct Token::@1 instr
instruction data. Not used if token type is not TT_INSTR
const char * ADRM_NAMES[]
Human-readable names of address modes.
char stripped[TOKEN_BUFFER_SIZE]
stripped text from source file
@ DIR_STOP
An error occured, stop compilation.
int map_set(Map *map, char *name, int value)
Sets a key in the map.
Token * token
Token value.
#define LOG(LVL,...)
logging macro - works like printf
int istack_push(istack_ptr istack, int val)
push one element to the istack
TokensList * tokens
tokens
Compiler pseudo-global state.
#define LOGDO(LVL, x)
Conditional macro. Wraps contents into a conditional based on log level.
@ DIR_ENDIF
An endif was encountered, should pop from state stack.
int token_analyze_instruction(State *s, Token *t)
analyze instruction token (instruction, addressmode & operand)
int pass_one(State *s)
Compilation pass 1.
void istack_free(istack_ptr istack)
free all memory associated with a istack
step 1 and 3 processing for directive tokens
struct TokensListElement * next
next element in list or NULL
int binSize
number of bytes this token will generate
void instruction_print(Instruction *instr)
fancy-print one instruction data
int istack_pop(istack_ptr istack)
pop the top of the istack
AddressMode enum and related data.
TokensListElement * head
head (first element) of the list
An element of a TokensList.
enum DIRCommand do_directive_token(State *s, TokensListElement *ptr, int skip)
process a directive token
DIRCommand
Internal command type for directives.
@ DIR_IF_FALSE
A conditional evaluated to false.
@ TT_DIRECTIVE
directive token
Token type member methods.
enum tokenType type
type of this token
void token_print(Token *token)
Pretty-print one token, with its source and length.
@ DIR_IF_TRUE
A conditional evaluated to true.
int map_get(Map *map, char *name)
Get the value of a key.
logging and fancy-printing
int len
length of stripped text
@ MAP_MAX_KEY_LEN
Key buffer size for Map.
int token_get_operand(State *s, Token *t)
parse the operand of the instruction as a number
int istack_top(istack_ptr istack, int def)
get the top element of the istack
istack_ptr istack_new()
create an empty istack
TokensListElement * tokenslist_remove(TokensList *list, TokensListElement *el)
remove a token from the list
iStack class for storing non-negative integers
#define FAIL(...)
Fancy-print a fail (failed step). Works like printf.
#define ERROR(...)
Fancy-print an error (cause of faliure). Works like printf.