From 82aefe59d893c0c68d3899bb6b8b07580351fb4e Mon Sep 17 00:00:00 2001 From: Bernd Boeckmann Date: Sat, 15 Oct 2022 21:20:18 +0200 Subject: [PATCH] implement character constants --- asm6502.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/asm6502.c b/asm6502.c index d2ba748..b9a43c6 100644 --- a/asm6502.c +++ b/asm6502.c @@ -200,6 +200,7 @@ void dump_symbols(void) #define ERR_BYTERNG 21 #define ERR_LOCAL_REDEF 22 #define ERR_NO_GLOBAL 23 +#define ERR_CHR 24 char *err_msg[] = { "", @@ -225,7 +226,8 @@ char *err_msg[] = { "string not terminated", "byte value out of range", "illegal redefinition of local label", - "local label definition requires previous global label" + "local label definition requires previous global label", + "malformed character constant" }; jmp_buf error_jmp; @@ -447,6 +449,16 @@ value primary(char **p) SET_DEFINED(res); } } + else if (**p == '\'') { + (*p)++; + if (IS_END(**p) || (**p < 0x20)) error(ERR_CHR); + res.v = **p; + SET_TYPE(res, TYPE_BYTE); + SET_DEFINED(res); + (*p)++; + if (**p != '\'') error(ERR_CHR); + (*p)++; + } else if (isalpha(**p)) { ident(p, id); sym = lookup(id, symbols);