s502 assembler
A very simple assembler for the 6502 line of processors written in C
|
Token type to store token information. More...
#include <token_t.h>
Public Member Functions | |
void | token_print (Token *token) |
Pretty-print one token, with its source and length. More... | |
int | token_recognize (Token *t) |
Parse token - test if it's an opcode, a label or a directive. More... | |
int | token_analyze_instruction (State *s, Token *t) |
analyze instruction token (instruction, addressmode & operand) More... | |
int | token_compile (State *s, Token *t, char **dataptr) |
compile token into binary data More... | |
int | token_get_operand (State *s, Token *t) |
parse the operand of the instruction as a number More... | |
Data Fields | |
int | binSize |
number of bytes this token will generate More... | |
enum tokenType | type |
type of this token More... | |
struct { | |
enum AddressMode | addressmode |
Address mode of the instruction. More... | |
int | number |
operand of the instruction More... | |
Instruction * | inst |
pointer to instruction data More... | |
int | address |
address of instruction in resulting bytecode More... | |
} | instr |
instruction data. Not used if token type is not TT_INSTR More... | |
char | stripped [TOKEN_BUFFER_SIZE] |
stripped text from source file More... | |
int | len |
length of stripped text More... | |
struct { | |
char | fname [TOKEN_SOURCE_FILE_SIZE] |
file name of source file More... | |
int | lineno |
line in source file More... | |
} | source |
source of this token More... | |
Private Member Functions | |
int | token_link_instruction (State *s, Token *token) |
find and link the instruction entry for a token More... | |
int | token_get_addressmode (Token *t) |
Determine the address mode of a token. More... | |
analyze instruction token (instruction, addressmode & operand)
Definition at line 224 of file tokenFunc.c.
Referenced by pass_one().
compile token into binary data
dataptr | char** to return data to |
s | assembler state |
t | token to compile |
Definition at line 318 of file tokenFunc.c.
Referenced by concat_bin().
|
private |
Determine the address mode of a token.
(modifies the token in-place)
Definition at line 109 of file tokenFunc.c.
References ADRM_ABS, ADRM_ABS_X, ADRM_ABS_Y, ADRM_ACC, ADRM_IMM, ADRM_IMP, ADRM_IND, ADRM_IND_X, ADRM_IND_Y, ADRM_REL, ADRM_ZPG, ADRM_ZPG_X, ADRM_ZPG_Y, instr, len, OPC_INVALID, stripped, and util_match_char().
Referenced by token_analyze_instruction().
parse the operand of the instruction as a number
Modifies the token in-places. Does NOT fail if operand is an undefined label!
Definition at line 287 of file tokenFunc.c.
Referenced by pass_one(), and pass_two().
find and link the instruction entry for a token
Definition at line 30 of file tokenFunc.c.
References State::instr, instr, Instruction::instruction_find(), and stripped.
Referenced by token_analyze_instruction().
void token_print | ( | Token * | token | ) |
Pretty-print one token, with its source and length.
Definition at line 20 of file tokenFunc.c.
Referenced by compile_data(), compile_pad(), pass_one(), pass_two(), read_file(), read_token(), token_analyze_instruction(), token_compile(), token_get_operand(), token_recognize(), and tokenslist_debug_print().
int token_recognize | ( | Token * | t | ) |
Parse token - test if it's an opcode, a label or a directive.
t | token to recognize - will be modified in-place |
Definition at line 251 of file tokenFunc.c.
Referenced by tokenslist_recognize().
int Token::binSize |
number of bytes this token will generate
Definition at line 39 of file token_t.h.
Referenced by compile_data(), compile_pad(), pass_one(), read_token(), token_analyze_instruction(), token_compile(), and token_get_operand().
struct { ... } Token::instr |
instruction data. Not used if token type is not TT_INSTR
Referenced by pass_one(), read_token(), token_analyze_instruction(), token_compile(), token_get_addressmode(), token_get_operand(), token_link_instruction(), and token_recognize().
int Token::len |
length of stripped text
Definition at line 57 of file token_t.h.
Referenced by pass_one(), read_file(), read_token(), token_get_addressmode(), token_print(), and token_recognize().
struct { ... } Token::source |
source of this token
Referenced by read_file(), and token_print().
char Token::stripped[TOKEN_BUFFER_SIZE] |
stripped text from source file
Definition at line 55 of file token_t.h.
Referenced by compile_data(), compile_pad(), directive_compile(), pass_one(), read_token(), token_get_addressmode(), token_get_operand(), token_link_instruction(), token_print(), and token_recognize().
enum tokenType Token::type |
type of this token
Definition at line 39 of file token_t.h.
Referenced by pass_one(), token_compile(), token_get_operand(), and token_recognize().