From 3ef269315409c698a1e0f689722136dcd974fe36 Mon Sep 17 00:00:00 2001
From: Quentin Carbonneaux <quentin.carbonneaux@yale.edu>
Date: Thu, 1 Oct 2015 13:19:09 -0400
Subject: [PATCH] support negative frame offsets in emit

They are used to access function parameters passed
on the stack.
---
 lisc/emit.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lisc/emit.c b/lisc/emit.c
index 8a9983f..ab7a72a 100644
--- a/lisc/emit.c
+++ b/lisc/emit.c
@@ -83,10 +83,16 @@ Next:
 			break;
 		case RSlot:
 		Slot: {
+			int off;
 			struct { int i:14; } x = {ref.val}; /* fixme */
 			assert(NAlign == 3);
-			assert(fn->slot >= x.i);
-			fprintf(f, "%d(%%rbp)", -4 * (fn->slot - x.i));
+			if (x.i < 0)
+				off = -4 * x.i;
+			else {
+				assert(fn->slot >= x.i);
+				off = -4 * (fn->slot - x.i);
+			}
+			fprintf(f, "%d(%%rbp)", off);
 			break;
 		}
 		case RCon: