diff lwasm/list.c @ 389:fbb7bfed8076

Added in structure support and fixed up some warts in the listing code (by adding more warts)
author lost@l-w.ca
date Wed, 14 Jul 2010 22:33:55 -0600
parents a741d2e4869f
children 027d7fbcdcfc
line wrap: on
line diff
--- a/lwasm/list.c	Wed Jul 14 20:17:57 2010 -0600
+++ b/lwasm/list.c	Wed Jul 14 22:33:55 2010 -0600
@@ -55,15 +55,53 @@
 	{
 		if (cl -> len < 1)
 		{
-			fprintf(of, "                      ");
+			if (cl -> soff >= 0)
+			{
+				fprintf(of, "%04X                  ", cl -> soff & 0xffff);
+			}
+			else if (cl -> dshow >= 0)
+			{
+				if (cl -> dsize == 1)
+				{
+					fprintf(of, "     %02X                 ", cl -> dshow & 0xff);
+				}
+				else
+				{
+					fprintf(of, "     %04X               ", cl -> dshow & 0xff);
+				}
+			}
+			else if (cl -> dptr)
+			{
+				lw_expr_t te;
+				te = lw_expr_copy(cl -> dptr -> value);
+				as -> exportcheck = 1;
+				as -> csect = cl -> csect;
+				lwasm_reduce_expr(as, te);
+				as -> exportcheck = 0;
+				if (lw_expr_istype(te, lw_expr_type_int))
+				{
+					fprintf(of, "     %04X             ", lw_expr_intval(te) & 0xffff);
+				}
+				else
+				{
+					fprintf(of, "     ????             ");
+				}
+				lw_expr_destroy(te);
+			}
+			else
+			{
+				fprintf(of, "                      ");
+			}
 		}
 		else
 		{
 			lw_expr_t te;
 			te = lw_expr_copy(cl -> addr);
 			as -> exportcheck = 1;
+			as -> csect = cl -> csect;
 			lwasm_reduce_expr(as, te);
 			as -> exportcheck = 0;
+//			fprintf(of, "%s\n", lw_expr_print(te));
 			fprintf(of, "%04X ", lw_expr_intval(te) & 0xffff);
 			lw_expr_destroy(te);
 			for (i = 0; i < cl -> outputl && i < 8; i++)
@@ -76,7 +114,7 @@
 			}
 			fprintf(of, " ");
 		}
-		fprintf(of, "%15s:%05d %s\n", cl -> linespec, cl -> lineno, cl -> ltext);
+		fprintf(of, "(%31.31s):%05d %s\n", cl -> linespec, cl -> lineno, cl -> ltext);
 		if (cl -> outputl > 8)
 		{
 			for (i = 8; i < cl -> outputl; i++)