v6502
The MOS 6502 Virtual Machine and Toolchain Infrastructure
parser.h
Go to the documentation of this file.
1 
4 /*
5  * Copyright (c) 2013 Daniel Loffgren
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy
8  * of this software and associated documentation files (the "Software"), to
9  * deal in the Software without restriction, including without limitation the
10  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11  * sell copies of the Software, and to permit persons to whom the Software is
12  * furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in
15  * all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23  * IN THE SOFTWARE.
24  */
25 
26 #ifndef v6502_parser_h
27 #define v6502_parser_h
28 
29 #include <string.h>
30 
31 #include <v6502/cpu.h>
32 #include <as6502/token.h>
33 
49 uint16_t as6502_valueForString(int *wide, const char *string, size_t len);
51 #define as6502_valueForToken(wide, token) as6502_valueForString(wide, token->text, token->len)
52 
53 void as6502_byteValuesForString(uint8_t *high, uint8_t *low, int *wide, const char *string, size_t len);
55 void as6502_instructionForExpression(uint8_t *opcode, uint8_t *low, uint8_t *high, v6502_address_mode *mode, as6502_token *head);
59 void as6502_executeAsmLineOnCPU(v6502_cpu *cpu, const char *line, size_t len);
65 int as6502_isBranchInstruction(const char *string);
67 int as6502_isDigit(char c);
69 int as6502_isNumber(const char *c);
72 #endif
An individual token which will often be a part of a linked list of tokens.
Definition: token.h:41
v6502_opcode as6502_opcodeForInstructionAndMode(as6502_token *instruction, v6502_address_mode mode)
Returns the v6502_opcode for a given instruction string at a specified v6502_address_mode.
Definition: parser.c:100
v6502_address_mode
Address Modes.
Definition: cpu.h:279
int as6502_isNumber(const char *c)
Determines whether or not a token is a number literal.
Definition: parser.c:756
Virtual CPU Object.
Definition: cpu.h:35
int as6502_isDigit(char c)
Tests a single character for the possibility of being a hex/oct/dec digit.
Definition: parser.c:747
int as6502_instructionLengthForAddressMode(v6502_address_mode mode)
Returns the instruction length for a given v6502_address_mode.
Definition: parser.c:877
v6502_address_mode as6502_addressModeForExpression(as6502_token *head)
Returns the v6502_address_mode for a given (already lexed) expression by analyzing the operands...
Definition: parser.c:782
void as6502_executeAsmLineOnCPU(v6502_cpu *cpu, const char *line, size_t len)
Executes a symbol-free line of assembly on a specified v6502_cpu.
Definition: parser.c:927
Virtual CPU.
void as6502_instructionForExpression(uint8_t *opcode, uint8_t *low, uint8_t *high, v6502_address_mode *mode, as6502_token *head)
Completely parses a line of text to extract the instruction and v6502_address_mode.
Definition: parser.c:902
void as6502_byteValuesForString(uint8_t *high, uint8_t *low, int *wide, const char *string, size_t len)
Determines the numeric value of a literal separated into its high and low bytes.
Definition: parser.c:735
void as6502_stringForAddressMode(char *out, v6502_address_mode mode)
Returns the string representation of an v6502_address_mode.
Definition: parser.c:49
v6502_opcode
Instruction Set.
Definition: cpu.h:58
int as6502_isBranchInstruction(const char *string)
Return YES if a given string reflects a branching instruction.
Definition: parser.c:772
Tokenization functionality.
uint16_t as6502_valueForString(int *wide, const char *string, size_t len)
Returns the numeric value of a literal regardless of base.
Definition: parser.c:643