Hacking the NES With Lisp 80
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).
a strange mix of nausea and admiration (Score:5, Funny)
on the one hand, this guy has re-implemented assembler with lisp syntax.
on the other hand, this guy has re-implemented assembler with lisp syntax.
Re:a strange mix of nausea and admiration (Score:5, Informative)
Yeah, when you're writing Assembly, it's still assembly. Using lisp to make macros doesn't change the langauge.
Re:a strange mix of nausea and admiration (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.
Re:a strange mix of nausea and admiration (Score:4, Interesting)
Well he wasn't the first one to do it, Common Lisp already has a disassemble [psg.com] command.
Re:a strange mix of nausea and admiration (Score:5, Funny)
Great. Now I can run Super Mario Bros. in Emacs!
Re:a strange mix of nausea and admiration (Score:5, Funny)
This reminds me of the old quote "Emacs is a wonderful operating system. All it's missing is a decent text editor."
Re: (Score:1, Redundant)
Normally I wouldn't reply to an AC, but being a vi fan I have to give props. Although, you know, all the best operating systems aren't emacs, they are created *in* emacs.
Re: (Score:2)
Have a look at the original Emacs that was a set of macros written in TECO. That's scary stuff.
Re: (Score:1)
No Emacs OS can emulate vi thus it does have a desent text editor
Re: (Score:2)
Re:a strange mix of nausea and admiration (Score:5, Funny)
on the one hand, this guy has re-implemented assembler with lisp syntax.
on the other hand, this guy has re-implemented assembler with lisp syntax.
and on the gripping hand, it's the world's first assembler that requires you to start lines with seven parentheses and rewrites itself at runtime.
Re: (Score:2)
Heh +1 Motie!
Re: (Score:1)
Re:a strange mix of nausea and admiration (Score:5, Informative)
The earliest lisps had assembler. It was sort of normal in a way because assembler was your language of choice for this sort of thing. C didn't exist yet, Fortran was just wrong, the other procedural languages were bulky, etc. Machines were low on memory and you often wanted to machine specific actions, you were writing your own runtime library as you went. So even as far back as Lisp 1.5 documentation discusses how to use assembler.
The earliest lisps had compilers as well which went well with assembler written functions. Your programming environment was often a stack of cards that were loaded into a machine, or a tape that was read. So stopping to edit/compile/link/load was often impractical compared to just dumping some assembler while still in the interpreter (though of course if you crashed the machine you had to hide until pitchfork wielding mob stopped looking for you).
The thing people remember most about Lisp other than parentheses are CAR and CDR functions. These are named for specific fields in a PDP 36-bit word which were accessible via machine instructions.
Actually I remember one other think about lisp (Score:2)
Re: (Score:2)
Why is that? Must have been a bad teacher, because Lisp is really fun to program in. You need the help of an editor for the parentheses, but other than that its very easy and very powerful.
Re: (Score:2)
Re: (Score:2)
The thing people remember most about Lisp other than parentheses are CAR and CDR functions. These are named for specific fields in a PDP 36-bit word which were accessible via machine instructions.
Contents of Address Register
Contents of Data Register
Re: (Score:3)
Close but not exact. I got it wrong too, it wasn't a PDP but an IBM.
These both were fields from the same register ( bit words and the computer allowed either 15 or 16 bit word addresses). So according to Wikipedia the definitions were:
"Contents of the Address part of Register number"
"Contents of the Data part of Register number"
And a couple other tiny fields that initially were in Lisp but were later dropped.
Yea, it's kind of weird. The PDPs used at MIT later were 36 bit and also allowed sticking two wor
Re: (Score:2)
Whoops messed up again. It's "Contents of Decrement part of Register number"...
That's hot (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.
Re: (Score:2)
And somehow one of them ended up on /.
Re: (Score:2)
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.
They didn't write it in SmallTalk which would certainly be the king of all high level languages, not lisp.
Lisps only quality is its known use of braces - which is also its greatest fault. A queen among queens.
Re: (Score:3, Insightful)
Are you kidding?! There are probably more working NES consoles out there than N64 or Nokia N-gages.
Re: (Score:3)
Re:Nostalgia is a powerful force... (Score:5, Funny)
Those NES boxes are quite comfortable with their sexuality, thank you very much, and just value their privacy. If they want to stay in the closet, who are we to disagree?
Re:Nostalgia is a powerful force... (Score:5, Funny)
Re: (Score:3)
wow there killer, way to think outside of the box, you installed software on your pc and let nintendo tell you what you could do! we need more people like you and less of these retards doing interesting things with obsolete machines.
Comment removed (Score:4, Insightful)
Re: (Score:2)
So, what you're really saying is, "I'm unhappy with my life because I've never known what creativity feels like"?
Re: (Score:2)
nintendo frankly doesn't give a flying fuck what you do with a 25+ year old NES dumbass.
Since doing something creative, if not actually constructive, takes your time away from playing and buying the latest Nintendo games, I'm sure they're actually against such anti-consumerist ventures.
HTPCs don exits (Score:2)
This is why I've always preferred computers to consoles because the DRMtastic nature of the consoles quickly make them worthless.
Except most people aren't willing to buy a PC and hook it up to a TV. The cases are too big, they don't come with a recliner-friendly remote, etc. For this reason (and greed [cracked.com]), the Wii is still a lot more likely than the PC to get games capable of using multiple controllers.
Re: (Score:2)
Does that C&C lathe play CNC Music Factory
Or is it a...
Command and conquer lathe controller?
I'm not vicious or malicious, just lovely and delicious. OSLT.
Cheers!
Obligatory (Score:1)
Re: (Score:2)
a general-purpose processor and memory
All you "Turing complete" weenies seem to forget that a Turing machine has infinite memory, unlike the 4096 bytes of RAM in the NES. Sure, you can put hundreds of megabytes of RAM on a cartridge, but at that point you could put a smartphone chipset on a cartridge and have it fill a frame buffer as if it were the successor to Wide Boy/Super Game Boy.
Re: (Score:1)
Wide Boy or Super FX (Score:2)
streaming raw data prepared for it through a cable from another machine
That would be Wide Boy, the pre-production version of Super Game Boy. Or it would be Super FX, a second CPU on a Super NES cartridge that renders graphics. In discussions about "super-mappers" on NESdev BBS, I've often mentioned a TV tuner for NES connected to an Xbox 360 as the hypothetical "upper limit" of what a mapper can do.
This is what Slashdot needs more of (Score:5, Interesting)
Re:This is what Slashdot needs more of (Score:4, 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.
Super Game Boy (Score:2)
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'll have reimplemented Super Game Boy (for Super NES) or Game Boy Player (for Nintendo GameCube).
Re: (Score:2)
Didn't the gb have a z80 though? That's a bit less powerful than the 6500series cpu in the snes.
Simply because the snes databus is 16bit doesn't mean the 3rd party cpu needs to be 16bit. The snes hardware could be treated like a 16bit peripheral, as far as the embedded SoC in the cart was concerned.
I still think something more interesting than the superGB could be made this way.
Re: (Score:2)
Didn't the gb have a z80 though?
It was an 8080-derivative made by Sharp with some but not all features of the Zilog Z80, nicknamed "GBZ80" by emulator authors. Some Z80 features, such as the separate bank of BCDEHL registers for interrupt handlers, were left out in favor of special fast addressing modes for $FF00-$FFFF to mimic the 6502's "direct page" at $0000-$00FF.
That's a bit less powerful than the 6500series cpu in the snes.
The old Commodore 64 vs. ZX Spectrum flamewars ended up with a consensus that the 6502 is roughly as fast as a Z80 clocked two to three times as fast, depending on workload.
Comment removed (Score:4, Interesting)
Re: (Score:1)
Those bring back fond memories.
thats b/c "this stuff" became illegal (Score:5, Insightful)
if you tried to do what this guy is doing for NES with a Sony Playstation or IPhone you would sued and threatened with millions in legal bills. If you don't believe me, ask George Hotz.
slashdot didn't move away from geeky stuff... certain corporate interests decided to attack the entire principle of DIY at its core. you can't expect slashdot to be silent about that.
Re: (Score:2)
There's still SparkFun.com and Adafruit.com, I guess.
6502 assembler in Logo (Score:3)
I wrote a 6502 assembler in Logo in 1981 and we shipped it with the utilities disk.
A better 6502 assembler (Score:2)
Just what I needed 35 years ago.
Paul Graham will definitely... (Score:3)
Looks like Henry G. Baker's COMFY 6502 compiler (Score:4, Interesting)
This is real programming (Score:2)
I hope all the HTML-5 "coders" are taking note.
Re: (Score:2)
Coding != Programming.
HTML5 and CSS is coding.
PHP* and Javascript* is programming.
I don't care if you hate those, it's still programming. Now go cry in the corner.
And for a 6502 disassembler... (Score:2)
But you already knew it was archeology.org, didn’t you?