<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -35,6 +35,7 @@
   (:use &quot;6502&quot; &quot;CL&quot;)
   (:shadow &quot;COMPILE&quot; &quot;CONSTANTP&quot; &quot;VARIABLEP&quot; &quot;BREAK&quot;
 	   &quot;IF&quot; &quot;+&quot; &quot;-&quot; &quot;1+&quot; &quot;1-&quot; &quot;NOT&quot; &quot;LOOP&quot; ;; &quot;PROG&quot;
+	   &quot;FOR&quot;
 	   ;; &quot;WHEN&quot; &quot;UNLESS&quot; ; candidates for control macros
 	   )
   (:export &quot;COMPILE&quot; &quot;INIT&quot; &quot;*MEM*&quot; &quot;RELOCATE&quot;
@@ -1066,7 +1067,7 @@ it with a conditional backward branch.
 
 (define-cmacro for
   ((for ?v ?from ?to . ?body)
-   `(seq ,(append '(l) from) ,(append '(st) ?v)
+   `(seq ,(append '(l) ?from) ,(append '(st) ?v)
      (while (seq ,(append '(c) ?to) llt)
        (seq ,(append '(seq) ?body)
 	    ,(append '(1+) ?v)</diff>
      <filename>comfy-6502.lisp</filename>
    </modified>
    <modified>
      <diff>@@ -8,6 +8,7 @@
   (:use &quot;COMMON-LISP&quot; &quot;6502&quot; &quot;COMFY-6502&quot; #+sbcl &quot;SB-RT&quot; #-sbcl &quot;RT&quot;)
   (:shadowing-import-from &quot;COMFY-6502&quot; 
 			  &quot;COMPILE&quot; &quot;1+&quot; &quot;1-&quot; &quot;+&quot; &quot;-&quot; &quot;IF&quot; &quot;NOT&quot; &quot;LOOP&quot;
+			  &quot;FOR&quot;
 			  &quot;BREAK&quot;))
 
 (in-package &quot;COMFY-6502-TESTS&quot;)
@@ -278,6 +279,42 @@
    (INX)                     ; [4]
    (JMP :ABSOLUTE) (:LONG-BRANCH -12))) ; [3]
 
+(deftest forj-1 (progn 
+		  (defparameter *code* 11)
+		  (compile-code (forj (\# 6) (\# 12) 
+				      (l j (lisp *code*))
+				      (lxor \# 127)
+				      (st j (lisp *code*))) -10 -20))
+  ((LDY :IMMEDIATE) (:BYTE 6)           ; [18]
+   (CPY :IMMEDIATE) (:BYTE 12)          ; [16] 
+   (BCS) (:BRANCH 23)                   ; [14] BCS -10 --&gt; win
+   (LDA :ABSOLUTE-Y) (:ABSOLUTE 11)     ; [12] (l j *code*)
+   (EOR :IMMEDIATE)  (:BYTE 127)        ; [9]  (lxor \# 127)
+   (STA :ABSOLUTE-Y) (:ABSOLUTE 11)     ; [7]  (st j *code*)
+   (INY)                                ; [4]
+   (JMP :ABSOLUTE) (:LONG-BRANCH -14))) ; [3]  -&gt; to CPY
+
+(deftest for-1 (code-result
+		 (equ code 13)  ; buffer 13..25
+		 (equ ptr 26)
+		 (comfy-6502:compile  
+		  '(for (ptr) (\# 6) (\# 12) 
+		      (li ptr)
+		      (l i code)
+		      (lxor \# 127)
+		      (st i code)) -10 -20))
+  ((LDA :IMMEDIATE) (:BYTE 6)           ; [23]
+   (STA :ZERO-PAGE) (:ZERO-PAGE 26)     ; [21]
+   (CMP :IMMEDIATE) (:BYTE 12)          ; [19] 
+   (BCS) (:BRANCH 26)                   ; [17] BCS -10 --&gt; win
+   (LDX :ZERO-PAGE) (:ZERO-PAGE 26)     ; [15]
+   (LDA :ZERO-PAGE-X) (:ZERO-PAGE 13)   ; [13] (l j *code*)
+   (EOR :IMMEDIATE)  (:BYTE 127)        ; [11] (lxor \# 127)
+   (STA :ZERO-PAGE-X) (:ZERO-PAGE 13)   ; [9]  (st j *code*)
+   (INC :ZERO-PAGE) (:ZERO-PAGE 26)     ; [7]
+   (LDA :ZERO-PAGE) (:ZERO-PAGE 26)     ; [5]
+   (JMP :ABSOLUTE) (:LONG-BRANCH -17))) ; [3]   -&gt; to CMP
+
 (deftest upc-example 
     (code-result
 ;;      (defparameter *upctable* </diff>
      <filename>comfy-tests.lisp</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>4f60b2a1d493f731f4702d29439112b31fa76f03</id>
    </parent>
  </parents>
  <author>
    <name>jaoswald</name>
    <email>josephoswald@gmail.com</email>
  </author>
  <url>http://github.com/jaoswald/cl-comfy-6502/commit/fb6c51f99ea8a9f1adb300823af469231b45e800</url>
  <id>fb6c51f99ea8a9f1adb300823af469231b45e800</id>
  <committed-date>2008-05-16T12:38:18-07:00</committed-date>
  <authored-date>2008-05-16T12:38:18-07:00</authored-date>
  <message>Fix FOR macro

Fix typo in FOR macro, export FOR symbol from COMFY-6502 package.
Added test coverage.</message>
  <tree>d5a2e01bbd2a3dd8300fcd23f14761e87d51e740</tree>
  <committer>
    <name>jaoswald</name>
    <email>josephoswald@gmail.com</email>
  </committer>
</commit>
