svm: Save a byte encoding (ea:stack-ref 0).
authorMatt Birkholz <matt@birkholz.chandler.az.us>
Wed, 7 Mar 2012 21:28:05 +0000 (14:28 -0700)
committerMatt Birkholz <matt@birkholz.chandler.az.us>
Thu, 8 Mar 2012 04:47:26 +0000 (21:47 -0700)
src/compiler/machines/svm/machine.scm

index 1460705297dcf5389db170eb20e6d4e09ea0ec55..976d1054bd1c874efb69d018a71eeeb6778ce24c 100644 (file)
@@ -222,7 +222,10 @@ USA.
   (ea:pre-decrement rref:stack-pointer 'WORD))
 
 (define (ea:stack-ref index)
-  (ea:offset rref:stack-pointer index 'WORD))
+  (guarantee-non-negative-fixnum index 'ea:stack-ref)
+  (if (zero? index)
+      (ea:indirect rref:stack-pointer)
+      (ea:offset rref:stack-pointer index 'WORD)))
 
 (define (ea:alloc-word)
   (ea:post-increment rref:free-pointer 'WORD))