|
|
@ -42,41 +42,41 @@
|
|
|
|
(define-macro (tgl X)
|
|
|
|
(define-macro (tgl X)
|
|
|
|
#'(λ(regs)
|
|
|
|
#'(λ(regs)
|
|
|
|
((if (toggled?)
|
|
|
|
((if (toggled?)
|
|
|
|
(make-inc-base X)
|
|
|
|
(make-inc-base 'X)
|
|
|
|
(make-tgl-base X)) regs)))
|
|
|
|
(make-tgl-base 'X)) regs)))
|
|
|
|
|
|
|
|
|
|
|
|
(define-macro (make-cpy-base X Y)
|
|
|
|
(define-macro (make-cpy-base X Y)
|
|
|
|
#'(λ(regs)
|
|
|
|
#'(λ(regs)
|
|
|
|
(define val (if (number? 'X) 'X (hash-ref regs 'X)))
|
|
|
|
(define val (if (number? X) X (hash-ref regs X)))
|
|
|
|
(hash-set! regs 'Y val)))
|
|
|
|
(hash-set! regs Y val)))
|
|
|
|
|
|
|
|
|
|
|
|
(define-macro (cpy X Y)
|
|
|
|
(define-macro (cpy X Y)
|
|
|
|
#'(λ(regs)
|
|
|
|
#'(λ(regs)
|
|
|
|
((if (toggled?)
|
|
|
|
((if (toggled?)
|
|
|
|
(make-jnz-base X Y)
|
|
|
|
(make-jnz-base 'X 'Y)
|
|
|
|
(make-cpy-base X Y)) regs)))
|
|
|
|
(make-cpy-base 'X 'Y)) regs)))
|
|
|
|
|
|
|
|
|
|
|
|
(define-macro (make-dec-base X) #'(λ(regs) (hash-update! regs 'X sub1)))
|
|
|
|
(define-macro (make-dec-base X) #'(λ(regs) (hash-update! regs X sub1)))
|
|
|
|
(define-macro (make-inc-base X) #'(λ(regs) (hash-update! regs 'X add1)))
|
|
|
|
(define-macro (make-inc-base X) #'(λ(regs) (hash-update! regs X add1)))
|
|
|
|
|
|
|
|
|
|
|
|
(define-macro (inc X) #'(λ(regs)
|
|
|
|
(define-macro (inc X) #'(λ(regs)
|
|
|
|
((if (toggled?)
|
|
|
|
((if (toggled?)
|
|
|
|
(make-dec-base X)
|
|
|
|
(make-dec-base 'X)
|
|
|
|
(make-inc-base X)) regs)))
|
|
|
|
(make-inc-base 'X)) regs)))
|
|
|
|
|
|
|
|
|
|
|
|
(define-macro (dec X) #'(λ(regs)
|
|
|
|
(define-macro (dec X) #'(λ(regs)
|
|
|
|
((if (toggled?)
|
|
|
|
((if (toggled?)
|
|
|
|
(make-inc-base X)
|
|
|
|
(make-inc-base 'X)
|
|
|
|
(make-dec-base X)) regs)))
|
|
|
|
(make-dec-base 'X)) regs)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-macro (make-jnz-base X Y)
|
|
|
|
(define-macro (make-jnz-base X Y)
|
|
|
|
#'(λ(regs)
|
|
|
|
#'(λ(regs)
|
|
|
|
(when (not (zero? (if (number? 'X) 'X (hash-ref regs 'X))))
|
|
|
|
(when (not (zero? (if (number? X) X (hash-ref regs X))))
|
|
|
|
Y)))
|
|
|
|
Y)))
|
|
|
|
|
|
|
|
|
|
|
|
(define-macro (jnz X Y)
|
|
|
|
(define-macro (jnz X Y)
|
|
|
|
#'(λ(regs)
|
|
|
|
#'(λ(regs)
|
|
|
|
((if (toggled?)
|
|
|
|
((if (toggled?)
|
|
|
|
(make-copy-base X Y)
|
|
|
|
(make-cpy-base 'X 'Y)
|
|
|
|
(make-jnz-base X Y)) regs)))
|
|
|
|
(make-jnz-base 'X 'Y)) regs)))
|
|
|
|