s502 assembler
A very simple assembler for the 6502 line of processors written in C
|
Go to the documentation of this file.
13 if (
'0' <= c && c <=
'9')
15 if (
'a' <= c && c <=
'f')
17 if (
'A' <= c && c <=
'F')
31 int count = strlen(str);
44 ERROR(
"Can not interpret number: '%.*s'\n", count, str);
63 if (str[0] ==
'@' || str[0] ==
'&') {
77 int p = (str[0] ==
'>' || str[0] ==
'<') ? 1 : 0;
80 if (num < 0)
return num;
82 num = str[0] ==
'>' ? num >> 8 : num;
83 num &= str[0] ==
'>' || str[0] ==
'<' ? 0xff : 0xffff;
Map * labels
label locations
int number_parse_number(char *str)
interpret a string as a decimal or hex number
Compiler pseudo-global state.
Map * defines
defined constants
Simple key->value map (str->int)
int number_get_raw(State *s, char *str)
interpret number without modifiers
int map_get(Map *map, char *name)
Get the value of a key.
logging and fancy-printing
int number_char_to_digit(char c)
Convert a hex char to a digit.
@ NUMBER_ERROR
Could not parse a number or constant is undefined.
Number module to parse numbers.
int number_get_number(State *s, char *str)
interpret a string as a constant, label or number
#define ERROR(...)
Fancy-print an error (cause of faliure). Works like printf.
@ NUMBER_LABEL_NODEF
Undefined label.