From: James Edward Gray II Date: 2006-07-31T23:00:52+09:00 Subject: Re: [QUIZ SOLUTION] #88 Chip-8 On Jul 30, 2006, at 12:17 PM, Tom Rauchenwald wrote: > Hi, > > Here is my solution to the current quiz. It has a few flaws, and it > uses a method call for each statement (which is probably quite slow). > The nice thing is that you can dump a program and view it in an > assembler-like way. > The implementation is quite simple, I don't think i need to explain it > in detail. I hope i haven't screwed up somewhere :) Sure looks good to me. Here's one trivial suggestion though: > if ARGV[0]==nil > STDERR.puts "Usage: #{$0} \n" > exit 1 > end > if !File.exist? ARGV[0] > STDERR.puts "Error: File not found.\n" > exit 1 > end > emu = Emulator.new > emu.scan(ARGV[0]) > print "Program read: \n" > print "============= \n" > emu.dump_prog > print "\nRunning... \n\n" > emu.run > print "Done! Registers: \n" > print "================ \n" > emu.dump puts() will add a newline character, if it's not already at the end of the String you pass to it, so you could lose a lot of \n's above if you like. James Edward Gray II