There is a lot of hype around a new game from Notch right now. Just google it and you'll see a lot of poeple doing crazy stuff follofing his whistle. However, it's an interesting exercise.
There is also already a lot of different implementations for DCPU-16. Sadly, it seems, nobody knows the Right Tool™ for doing things like that anymore. ;-) So here we go: a DCPU-16 Assembler in Lex/Yacc. It's pretty stable and supports different dialects I've seen so far on the Net. I's quite amazing how easy it is to add new features. If you are scared about Yacc and Lex or even never heard of it, check it out.
There is also an Emulator. Right now it is done in Ncurses, as it was used to get done in Old Good Days™. However I'm not satisfied with its speed due to nature of Ncurses output. There will be a port to SDL, since DCPU-16 shall also have some kind of a graphic display.
Extended OpCodes and features:
- BRK – stops execution (idea borrowed from 0x10co.de, not standard)
- DAT – data block, can contain numbers, strings and labels
- ORG – sets a new location in memory (not standard)
- Simple arithmetic on numeric values and labels with arbitrary order, like
Register + Offset * 32 + whateveror even
Offset + Register(as seen in some examples on dcpu.ru)
- It's small and simple (400 lines all together including comments for Assembler and another 300 for Emulator)
- The Emulator supports Keyboard input and color output.
- Macros (may come later)
- Incudes (extension, not standard)
- more Ops? (there is an example from Notch himself with uses JMP Op, even if the spec states there is none)
- Binary format for compiled code? (there is no spec on it) Right now I just use ASCII hex dump.
- Graphic display (commes with SDL port)
If you like to look at my implementation, just browse through my CVS-Repository: src/dcpu16 or pull it from it.
To compile your program run
dcpu prog.s, or start emulation with
dcpu -e prog.s.