Permalink
Browse files

fixin stuff and other things also got the

  • Loading branch information...
1 parent a2c3d3a commit e5bb259631953b4c94fe24b42903b6eb4598cf3e @jadudm committed Apr 26, 2012
Showing with 7 additions and 5 deletions.
  1. +3 −1 swigls-compiler/asm-emulate.rkt
  2. +2 −2 swigls-compiler/create_id_list.rkt
  3. +2 −2 swigls-compiler/to_asm.rkt
@@ -168,7 +168,7 @@
(define LAB "^\\((.*?)\\) *$")
(define CONST "^@([a-zA-Z_]+[0-9a-zA-Z_-]*?) *$")
(define NUM "^@([0-9]+) *$")
-(define LABEL "^\\(([a-zA-Z]+[0-9a-zA-Z]*)\\) *$")
+(define LABEL "^\\(([a-zA-Z]+[0-9a-zA-Z-]*)\\) *$")
(struct jump (type val) #:inspector (make-inspector))
(define (interp i loc)
@@ -245,6 +245,7 @@
(cond
[(regexp-match LABEL (get-code i))
(let ([the-sym (second (regexp-match LABEL (get-code i)))])
+ (printf "FOUND LABEL: ~a~n" the-sym)
(new-label the-sym i))]
[else 'DONOTHING])
(loop (add1 i)))))
@@ -259,6 +260,7 @@
;; Always initialize the state of the machine.
(init-state)
(populate-table num-inst)
+ ;;(exit)
;; Then, loop through each instruction.
;; Interpret it.
;; This is often called a "fetch-execute" loop
@@ -78,8 +78,8 @@
e
(list
(id (set-ident structure) (extract-sym (last e))))))]
- [(goto? structure) (list (id (sym 'goto) (goto-sym structure)))]
- [(label? structure) (list (id (sym 'label) (label-sym structure)))]
+ [(goto? structure) (list (id (sym 'goto) (goto (goto-sym structure))))]
+ [(label? structure) (list (id (sym 'label) (label (label-sym structure))))]
[(num? structure) (list (id (sym 'num) (num-value structure)))]
[(variable? structure) (list (id (sym 'sym) (variable-value structure)))]
))
@@ -58,13 +58,13 @@
; CONTRACT
;; input Label -> String
(define (asm-label input)
- (string-append "(" (stringify (label-sym input)) ")")
+ (string-append "(" (stringify (label-sym (id-value input))) ")\n")
)
; CONTRACT
;; input GoTo -> String
(define (asm-goto input)
- (string-append "@" (stringify (goto-sym input)) "\n"
+ (string-append "@" (stringify (goto-sym (id-value input))) "\n"
"0;JMP\n")
)

0 comments on commit e5bb259

Please sign in to comment.