#include <stdio.h>
#include <ctype.h>
+
#define GMQCC_VERSION_MAJOR 0
#define GMQCC_VERSION_MINOR 1
#define GMQCC_VERSION_PATCH 0
bool util_strupper (const char *);
bool util_strdigit (const char *);
+bool util_strncmpexact (const char *, const char *, size_t);
char *util_strdup (const char *);
char *util_strrq (const char *);
char *util_strrnl (const char *);
INSTR_BITAND,
INSTR_BITOR,
- /* Virtual instructions used by the IR
+ /*
+ * Virtual instructions used by the assembler
+ * keep at the end but before virtual instructions
+ * for the IR below.
+ */
+ AINSTR_END,
+
+ /*
+ * Virtual instructions used by the IR
* Keep at the end!
*/
VINSTR_PHI,
* code_write -- writes out the compiled file
* code_init -- prepares the code file
*/
-void code_write ();
-void code_init ();
+bool code_write (const char *filename);
+void code_init ();
+uint32_t code_genstring (const char *string);
+uint32_t code_cachedstring(const char *string);
/*===================================================================*/
/*========================= assembler.c =============================*/
{ "NOT_FNC" , 0, 7 },
{ "IF" , 0, 2 },
{ "IFNOT" , 0, 5 },
- { "CALL0" , 0, 5 },
- { "CALL1" , 0, 5 },
- { "CALL2" , 0, 5 },
- { "CALL3" , 0, 5 },
- { "CALL4" , 0, 5 },
- { "CALL5" , 0, 5 },
- { "CALL6" , 0, 5 },
- { "CALL7" , 0, 5 },
- { "CALL8" , 0, 5 },
+ { "CALL0" , 1, 5 },
+ { "CALL1" , 2, 5 },
+ { "CALL2" , 3, 5 },
+ { "CALL3" , 4, 5 },
+ { "CALL4" , 5, 5 },
+ { "CALL5" , 6, 5 },
+ { "CALL6" , 7, 5 },
+ { "CALL7" , 8, 5 },
+ { "CALL8" , 9, 5 },
{ "STATE" , 0, 5 },
{ "GOTO" , 0, 4 },
{ "AND" , 0, 3 },
{ "OR" , 0, 2 },
{ "BITAND" , 0, 6 },
- { "BITOR" , 0, 5 }
+ { "BITOR" , 0, 5 },
+ { "END" , 0, 3 } /* virtual assembler instruction */
};
void asm_init (const char *, FILE **);