Adds untested binary support to assembler.

This commit is contained in:
Felix Queißner 2016-07-01 19:38:10 +02:00
parent 073c12600b
commit 7dd273547c
3 changed files with 6 additions and 0 deletions

View file

@ -180,6 +180,9 @@ void assemble()
case TOK_HEX:
current.argument = (uint32_t)strtol(yytext, NULL, 16);
break;
case TOK_BIN:
current.argument = (uint32_t)strtol(yytext + 2, NULL, 2);
break;
case TOK_CHAR:
current.argument = (uint32_t)yytext[1];
break;

View file

@ -12,6 +12,7 @@
#define TOK_NEWLINE 6
#define TOK_CHAR 7
#define TOK_REFERENCE 8
#define TOK_BIN 9
extern int yylineno;

View file

@ -9,6 +9,7 @@ digit [0-9]
hexdigit [0-9a-fA-F]
intnum -?{digit}+
hexnum "0x"{hexdigit}+
binnum "0b"[01]+
mnemonic [a-zA-Z]+
labelname [a-zA-Z0-9_]+
label {labelname}":"
@ -19,6 +20,7 @@ ref @{labelname}
{comment} ;
{hexnum} RETURN(TOK_HEX,);
{intnum} RETURN(TOK_INT,);
{binnum} RETURN(TOK_BIN,);
{whitespace} ;
{mnemonic} RETURN(TOK_MNEMONIC,);
{label} RETURN(TOK_LABEL,);