Hacker News new | past | comments | ask | show | jobs | submit login

I believe this suffers, as do several other CHIP-8 emulators I've seen, from the early mis-documentation of the SHR and SHL instructions. Forgive me if I am reading this incorrectly; I am not used to Lisp:

    (define-instruction op-shr (_ r _ _) ;; SHR
      (setf (values (register r) flag)
             (>>_8 (register r))))
    (define-instruction op-shl (_ r _ _) ;; SHL
      (setf (values (register r) flag)
            (<<_8 (register r))))
Since there is only one reg argument, it seems these are shifting the source register in place. It should put the shifted value of the source register into the target register (8XY6: VX <- VY>>1) This was recently clarified in an exchange on the retrocomputing forum [1].

[1] https://groups.yahoo.com/neo/groups/rcacosmac/conversations/...

Your analysis looks correct.


    (setf (values X Y) Z)
is roughly equivalent to the Python:

    (X, Y) = Z

    (setf (values (register r) flag)
          (<<_8 (register r)))
might be idiomatically in python:

    (registers[r], flag) = leftShift8(registers[r])
And in any event is using the same register "r" as both source and destination.

Applications are open for YC Summer 2019

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact