Slashdot Mirror


Hacking the NES With Lisp

Andy Hefner has a detailed blog post covering his quest to program an NES with the assistance of Common Lisp. He developed a new 6502 assembler, a mini-language for composing musical sequences, and a neat demo (rom image).

7 of 80 comments (clear)

  1. That's hot by Anonymous Coward · · Score: 3, Interesting

    I think that is the coolest thing I have seen in a while. Nothing like the king of all high level languages generating low level machine code.

  2. Re:a strange mix of nausea and admiration by Hentes · · Score: 3, Interesting

    Well he wasn't the first one to do it, Common Lisp already has a disassemble command.

  3. This is what Slashdot needs more of by comrade+k · · Score: 5, Interesting

    Bravo, Slashdot. This is the kind of stuff that the geek crowd finds interesting. Is it useful? Nope. Is it cool and borderline bizarre? Yep!

    --
    "Every vision is a joke until the first man accomplishes it; once realized, it becomes commonplace." -Robert H. Goddard
    1. Re:This is what Slashdot needs more of by wierd_w · · Score: 3, Interesting

      What I have always wondered about, is just how far can you push one of these old systems?

      Like the snes.. it was designed to accept a 3rd party cpu inside the cartridge, in addition to the game rom.

      What would happen if you built what would essentially be rom code toolbox routines to access the snes's hardware, and then switch execution to a more powerful/more modern low energy cpu, like an arm?

      You would use the snes as an input device (they did make a snes mouse.....), and as the graphics hardware, but run all the heavy lifting on the arm instead of the 6500 series cpu. Other than the rom routines to do the interface, everything else is handled by a shared ram bank and an sdcard slot put into the cartridge.

      Why? So you can run linux on the snes. Why? Because you could.

      I bet you could do some really clever stuff by simulating a framebuffer.

    2. Re:This is what Slashdot needs more of by DigiShaman · · Score: 3, Interesting

      Some of the best Z80 ROM music I've heard has to be M.U.S.H.A (Musha Aleste) on the Sega Genesis (Mega-Drive). Herzog Zwei comes in a close 2nd place. The composers were Gods, and they got paid to do what they loved to do. You've got to admire that kind of talent.

      --
      Life is not for the lazy.
  4. Re:a strange mix of nausea and admiration by ratboy666 · · Score: 5, Interesting

    Read the fine article. Using CL does substantially change the language. Specifically, note the higher order manipulation of the eventual low-level program that the author achieved using promises (delayed evaluations). Basically, "threading while assembling".

    Also, notice the ease of introducing higher-level flow control constructs (IF and UNTIL) into assembler. And the elimination of a second assembler pass by use of promises for forward references. It's kind of "magic" -- the correct data will be there when it's needed!

    In this use-case, CL is a notational system for NES programming. It probably shouldn't be called "assembler" anymore, as the power of CL can be brought to bear in the process of generating the desired machine code.

    --
    Just another "Cubible(sic) Joe" 2 17 3061
  5. Looks like Henry G. Baker's COMFY 6502 compiler by dwheeler · · Score: 3, Interesting

    Fun! This 6502-assembler-in-LISP looks similar to Henry G. Baker's "COMFY" 6502 compiler (described in "The COMFY 6502 compiler", SIGPLAN Notices, 1997). You can check out the COMFY-6502 implementation that uses Common Lisp (sadly this appears to be entrapped in the ACM non-commercial-use-only license, though for 6502 code that isn't very limiting). One cool thing about the approach of using LISP as an "assembler" in general is that unlike many traditional macro assemblers, this approach can easily do stuff like choose the optimal instruction set for branches because it can determine if it's in range for a short branch and use them when available. You can do it other ways, of course, but it's pretty elegant in LISP. Those interested in this sort of thing might like my page on 6502 Language Implementation Approaches or my page on making LISP-based languages more readable (especially sweet-expressions).

    --
    - David A. Wheeler (see my Secure Programming HOWTO)