diff src/lwasm.h @ 37:538e15927776

Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
author lost
date Sat, 03 Jan 2009 04:20:49 +0000
parents 9bd0fbfe7405
children 9bd584bb6296
line wrap: on
line diff
--- a/src/lwasm.h	Fri Jan 02 06:07:40 2009 +0000
+++ b/src/lwasm.h	Sat Jan 03 04:20:49 2009 +0000
@@ -24,10 +24,13 @@
 #ifndef __lwasm_h_seen__
 #define __lwasm_h_seen__
 
+#include "expr.h"
+
 #define OUTPUT_DECB		0	// DECB multirecord format
 #define OUTPUT_RAW		1	// raw sequence of bytes
 #define OUTPUT_OBJ		2	// proprietary object file format
 
+
 // structure for tracking errors
 typedef struct lwasm_error_s lwasm_error_t;
 struct lwasm_error_s
@@ -46,12 +49,25 @@
 	lwasm_line_t *prev;	// previous line
 	lwasm_error_t *err;	// error messages
 	int fsize;			// forced size (0 = no forced size)
+	char *sym;			// scratch area to record the presence of a symbol
+};
+
+// for keeping track of symbols
+typedef struct lwasm_symbol_ent_s lwasm_symbol_ent_t;
+struct lwasm_symbol_ent_s
+{
+	char *sym;			// the symbol
+	int context;		// the context number of the symbol (-1 for global)
+	int value;			// the value of the symbol
+	lwasm_symbol_ent_t *next;	// next symbol in the table
+	lwasm_symbol_ent_t *prev;	// previous symbol in the table
 };
 
 // keep track of current assembler state
 typedef struct {
 	int dpval;					// current dp value (setdp)
 	int addr;					// current address
+	int context;				// context counter (for local symbols)
 	int errorcount;				// error count
 	int passnum;				// which pass are we on?
 	int execaddr;				// execution address for the program (END ....)
@@ -59,6 +75,9 @@
 
 	lwasm_line_t *lineshead;	// first line of source code
 	lwasm_line_t *linestail;	// last line of source code
+	
+	lwasm_symbol_ent_t *symhead;	// first entry in symbol table
+	lwasm_symbol_ent_t *symtail;	// last entry in symbol table
 
 	const char *infile;			// input file
 	const char *outfile;		// output file
@@ -84,14 +103,23 @@
 __lwasm_E__ int lwasm_lookupreg2(const char *reglist, char **str);
 __lwasm_E__ int lwasm_lookupreg3(const char *rlist, const char **str);
 
+__lwasm_E__ lwasm_expr_stack_t *lwasm_evaluate_expr(asmstate_t *as, lwasm_line_t *l, const char *inp, const char **outp);
+
 #undef __lwasm_E__
 
 
-#ifndef __symtab_c_seen__
-//extern void register_symbol(asmstate_t *as, sourceline_t *cl, char *symstr, int val, int flags);
-//extern int lookup_symbol(asmstate_t *as, char *symstr);
-//extern void list_symbols(asmstate_t *as, FILE *f);
+#ifndef __symbol_c_seen__
+#define __lwasm_E__ extern
+#else
+#define __lwasm_E__
 #endif
 
+__lwasm_E__ int lwasm_register_symbol(asmstate_t *as, lwasm_line_t *l, char *sym, int val);
+__lwasm_E__ lwasm_symbol_ent_t *lwasm_find_symbol(asmstate_t *as, char *sym, int scontext);
+__lwasm_E__ int lwasm_set_symbol(asmstate_t *as, char *sym, int scontext, int val);
+
+#undef __lwasm_E__
+
+
 
 #endif //__lwasm_h_seen__