

DCPU16 Assembler in less than 200 lines of Ruby - tophercyll
https://github.com/toph/dcpu/blob/master/asm.rb

======
judofyr
For Rubyists who wants to play with DCPU-16:

<https://github.com/judofyr/rcpu>

It's a DCPU assembler (written in a Ruby DSL) and an emulator/debugger (which
allows you to step/run through the execution).

Next up I'm going to implement library support and write some I/O functions.
Much of the code is already in place though (e.g.
[https://github.com/judofyr/rcpu/blob/master/examples/screen....](https://github.com/judofyr/rcpu/blob/master/examples/screen.rcpu)
which maps 0x8000-0x8400 to the terminal).

------
alpatters
is the 200 lines a brag? It is in fact longer than the C++ version posted
earlier.

~~~
tophercyll
Not a brag--just wanted emphasize how straightforward and fun something like
this can be.

------
sarbogast
Who will be the first one to build a DCPU16 computer inside Minecraft?

~~~
jgrahamc
I'd love to see one made using discrete logic. It's a pretty simple CPU so it
looks to me like you could pretty easily build it out of 74 series.

~~~
msarnoff
> It's a pretty simple CPU

16-bit address and data buses? Hardware multiplier, divider, and barrel
shifter? I wouldn't exactly call it simple. The cost to build one out of
discrete logic probably approaches the quadruple digits.

Magic-1 (<http://www.homebrewcpu.com/>) is a 16-bit, microcoded homebrew CPU
that took about 4 years to build, and it doesn't have any of the above
features.

------
chj
while (> 100 lines) { zzzzZZZZZzzzz.. }

------
jenius
Hate to be that guy, but this isn't actually less than 200 lines... perhaps
"about 200 lines" would have been a better title?

~~~
ianterrell
Whitespace doesn't count.

~~~
_quasimodo
DCPU16 Assembler in 0 lines of Whitespace :)

------
ATPase
What's the hype about this DCPU16 thing? The game hasn't been released yet and
people starting to write assemblers. Are you totally bored out of your life?

~~~
quaunaut
There are dozens of reasons people do things like this. It's good programming
practice for those of us who aren't as confident in our abilities. It gets you
some notoriety in the community, maybe even a community you're a big part of.
It's something that can go on a resume really easily, if used.

Or maybe, you just wanted to have fun so you spent a night doing this. It
isn't a big deal. If you don't waste one night of your life every once in
awhile, you're pretty unlike the rest of humanity.

