[notch], the mastermind behind Minecraft, is working on a new game. It’s called 0x10c (pronounced ‘trillek’, we think) and promises to teach an entire new generation the joys of assembly programming on a 1980s-era computer.
The setup for the game is nerdy/awesome enough to make [Douglas Adams] blush; a ‘deep sleep core’ was invented in 1988 that attached to the 16-bit computers of the day. This core was big endian, where the DCPU-16 (the computer in the game) was little endian. What was supposed to be a one-year hibernation turned into a 281 Trillion year coma, the Universe is dying, and everyone from 1988 is just waking up.
The game features a fully functional 16-bit CPU that controls every aspect of your spaceship. The specs for the DCPU-16 have been released and there are several emulators available.
Already, a few communities have been set up around the web to discuss how to program the DCPU-16: the official forum of 0x10c, the 0x10c subreddit, and another dedicated to programming the in-game computer. Already there’s a C-like language that compiles executables for the DCPU and a Game of Life implementation.
We know this isn’t a usual Hackaday post. Despite this, we’re fairly certain a good percentage of our readership will be programming a DCPU-16 in the next year. It just might be time to crack the books and learn how to build a compiler and OS. The dragon book (Compilers Principles, Techniques, and Tools, Aho, Sethi, Ullman, 1985) is very good, and [Andy Tanenbaum]’s Operating Systems Design and Implementation is how [Linus Torvalds] got his start.
One more thing: we’re going to be running a contest for the best physical implementation of the DCPU-16 in a few months. We’ll wait until the in-game hardware is nailed down, along with any peripherals [notch] plans to add. Right now the prizes are some HaD schwag, but that may change. Further info with updates pending, but you’re free to start working now.
We’re going to be running a contest for the best physical implementation of the DCPU-16 in a few months
Ok, now this IS nerdy.
Someone’s going to build one if we have a contest or not.
correct!
This one of a few hundrets of videos were People implemented CPUs in Minecraft
http://www.youtube.com/watch?v=EaWo68CWWGM&feature=related
s/Torvolds/Torvalds
I wonder if someone has made a VHDL or Verilog implementation of the DCPU-16 yet. Shouldn’t be very hard, it can fit in even a small FPGA.
Or a TTL DCPU, or discrete transistors even.
Whatever, a three cycle 32-bit divide will be very big (combinatorial) or hard (iterative with tables?), or both. Same would be true for the multiply, though less extreme.
The instruction timings look a bit wonky and ill-suited to a hardware implementation. I would probably tackle it by microcoding something more basic with about 10x higher clock frequency, but it would bother me to know it would be busy waiting most of its life.
The multiply shouldn’t be too bad in a modern FPGA – most of them have fast hardware multipliers. Division though, ugh I dread to think.
Clock frequency is 100 kHz. Three cycle division, or even one cycle division, for that clock frequency would be as easy as pie on any FPGA.
DCPU-16 made in minecraft incoming.
How about porting Minecraft to the DCPU?
How long until we see the linux port?
It’s a 16 bit processor with no MMU.
Surprisingly, this isn’t a limitation. Somebody just has to write an ARM emulator for this thing.
Also, it runs at 100kHz.
10^C=0x0001 0000 0000 0000, which is the number of years that they were sleeping(or whatever it is)
Thank you, now it makes sense.
I thought Torvalds wrote Linux because Minix (the OS in Tanenbaum book) is a steaming piece of crap. I had to hack on it for a class during my undergrad, and I understand the sentiment.
More because Tanenbaum’s OS was mostly written as an educational tool.
Also, Torvalds had the (thoroughly unwise in my view) opinion that microkernels were not a good idea.
This is really cool, I have been messing around with the emulator here: http://denull.ru/dcpu/dcpu.htm
and started to learn more advanced assembly than I know for it. However, I am pretty sure once the game comes out there are going to be good C compilers for the DCPU-16 that all the real in-game programs will be written in C. What I want to see is how the in game space ship will be controlled by the computer using some sort of I/O, that is the interesting part.
Wow, sorry for the terrible grammar. Need a break from life right now…
Memory mapped io probably, which is pretty cool.
Comment removed
HaD.. I criticize Notch a bit and you immediately comment me out? I really don’t think this is appropriate. Having seen Notch’s code on numerous occasions I would know what I am speaking of.
you have not seen notch’s code. If anything you’ve seen some level of deobfuscated crap.
I can’t believe no-one has questioned the accuracy of Notch’s binary arithmetic. Its a 16 bit cpu,
“a requested sleep of 0x0000 0000 0000 0001 years to last for 0x0001 0000 0000 0000 years.
It’s now the year 281 474 976 712 644 AD”
Surely it should be 4096 AD ?
Wolfram, yo.
What? No checksum bit?
The horror!
The hex number 0×0001 0000 0000 is 281 474 976 712 644 in decimal.
The 0x means “hex”, not binary.
0×0001 0000 0000 0000 hex is 281,474,976,710,656 decimal, and when you add 1988 (the year they went to sleep) you get the decimal year quoted.
Or in other words, you aren’t smarter than a fifth grader.
i lol’d.
The real life Apollo Guidance Computer has similar specs and was actually used to send people to the moon. They’re both 16 bit processors, but the AGC has only 1 register as opposed to 8 and also fewer instructions. There is even a complete open source emulator which handles not only the CPU, but all the peripherals.
I think it would have been cool if Notch integrated yaAGC into his game instead.
“joys of assembly programming on a 1980s-era computer”
Having done this there is NO JOY in doing so. I even did assembly at university, again, NO JOY.
Hopefully after this spectacular flop people will stop preceeding his name with “mastermind” or “guru” or other unaccrediated made-up words.
Seriously, I don’t need to build a wheel out of rock with a hammer to appreciate how a car works.
I taught myself 6502 assembly in the early 1980s when I was in junior high. It effin rocked.
And yes, you really do need to know computer architecture to be a good software engineer.
Took the words out of my mouth.. 6502 assembler rocked.
So did I, on a Vic-20. We have only scratched the surface of the capabilities of an 8-bit processor.
Most all NES games were written in assembly and look at the variety and depth they exhibit even to this day.
I cant tell you how many times I try to relate this to my colleagues. Understanding the underlying hardware is a must for producing competent code. Otherwise, you get people storing IP addresses in databases as VARCHAR 128s and wondering why queries take so long to process.
Storing as a VARCHAR 128 would be really stupid, since for IP4 you would only need to store a max of 15 characters, VARCHAR 15 would do fine and and would take up a max of 16 bytes of storage (1 extra byte for varchar overhead). Of course there is a way to convert a IP4 address to an unsigned int (MySQL: INET_ATON PHP: ip2long) for better indexing.
BTW – my standing challenge for anyone who says they ‘understand the wheel’ is to explain the network of forces that make a bicycle wheel work. It’s a more complicated than most people think.
Made up words like unaccrediated?
WTG HaD…
Being a Minecraft fan I was already aware of this news, but your write up gave me a bit of new perspective on the new game\sim.
Piqued my interest by an additional ~%35 or so…
…thanks.
64% of percentage statistics are made up on the spot.
I heard about this a few days back. It’s great to know that there’s now basic documentation and emulators. I just got through writing a simple text parser.
However, does anyone else feel like this game would largely exclude the current Minecraft fan-base from playing? Let’s be honest, most people who play Minecraft are not the people building adders in it.
I mean, they’d be getting so little out of it if they’ve never programmed anything in assembly. I doubt they’ll all want to learn. They’d probably be better off playing Minecraft anyway. Is this, by design, a game only for programmers?
I think most people misunderstand why Minecraft is so popular.
My feeling on it is that Minecraft touches something very essential in us, the desire to carve out a place for ourselves with our bare hands, to build a house and find food and make a life in the ‘wilderness’. Those things are core to what we needed to survive in the not too distant past, and things that we have very little access to in most of the developed world today.
OTOH, I think it could be cool. So called ‘hacking’ games have proved popular in the past, I recall a web based puzzle game that included a minicomputer you used to circumvent traps, and Fallout 3’s hacking password system was kinda fun, but a bit far from what Notch is making here.
I sincerely hope that the coding part of the game is secondary to a survival aspect, in which you get to see the gameworld, not just through the ‘eyes’ of the CPU. Having to program to solve clear and present problems for the crew would be fun.
I don’t know if I came off the wrong way or if I just didn’t understand your reply, but I do fully understand the allure of Minecraft. I don’t think anyone expects the game to be played “through the eyes of the computer”. That sounds awful.
Anyway, “having to program to solve clear and present problems for the crew” is EXACTLY why I think some people will be disappointed.
I feel two ways about this:
1) I can’t wait for this game to come out.
2) I wonder if there will be enough people playing to keep this game going.
#2 is what really worries me.
That’s what’s great about minecraft… it means different things to different people.
For some the allure may be ‘carving out their own place with their own hands’, but for me it’s the mods and Mojang’s acceptance (nay, encouragement) of them.
For me… at this point… Minecraft is all about IndustrialCraft2, BuildCraft and RedPower and making a ‘factory’ to manage all of my harvested resources…
…I like minecraft because it allows me to let my inner engineer out of it’s cage for a bit to run around.
Given the nature of the instruction set, this thing looks like a natural Forth machine.
The advantage of Forth (for those who don’t already know it) is that it’s a stack-based RPN language. It doesn’t require a compiler because its command syntax is identical to its syntax tree. The code is executable as you type it in. Interpreters are small (I think the smallest one is like 4k) and get about as close to programming bare metal as any language can.
Leraning and programming in z80, 6502 and 6809 machine code and assembler was a highly enjoyable experience for me back in the early eighties. I am looking forward to this game giving me a bit of a nostalic high, but more importantly, maybe giving my kids the chance to experience the same. What with this and the RasPi 2012 is turning into a good year.
As an old code hacker this is quite an exciting development and I wish the project every success. I may even get sucked in myself. +1
There are 2 problems with this…
1) learning assembly is useless in todays computing for the vast majority except as a novelty, most people working in embedded even rarely use it
2) it isn’t going to teach many 12 year olds assembly because it is too obscure to get them interested in the first place
The general idea sounds great but why not make it more accessible rather than aiming at such a small niche?
because fun.
Assembly is valuable because it strips away about twelve layers of abstraction that are built into all popular/modern programming languages.
Object oriented programming? Sure, makes perfect sense if you know the correlation between abstract datatypes and function-block programming, the intricacies of data typing and scope encapsulation, and enough computation theory to see the correlation between an object oriented program and a network of theoretical register machines.
Garbage collection? Sure.. mark-and-sweep, reference counting, hard/soft reference counting, or a blend of some/all the above? In all cases, it’s a simple matter of mixing graph theory, context switching, and your OS’s memory management policies.
Those are big chunks for beginners.
Playing with assembler gives you a chance to see basic concepts like data representation and argument passing in action. You get to see why GOTO is such a powerful/dangerous thing to use indiscriminately. You get a firsthand understanding of ‘the stack’ and ‘the heap’.
Seeing the basic operations gives you a foundation for understanding what omdern programming langauges actually do.
Once you’ve got that, /then/ you can move on to multicore/multiple-processing-unit CPU architectures, microcode generation, branch prediction, pipeline latency, and all the stuff that makes compilers really earn their keep.
Knowing how your C code will convert into assembler is still very relevant. Recently I had to spend some serious effort speeding up an Arduino project, and that would have been impossible without some assembly experience and an understanding of why some methods will be faster than others.
…and why some methods are MUCH faster than others…
If you’re having problems, the LST file is a powerful tool to understand what’s going on in a very detailed way. …and I work with people who can’t even read the thing! It’s an essential skill for an embedded programmer, and a highly informative exercise for any other programmer.
Oh I love it!!!
Have you guys heard of Tau Zero? Great hard sci-fi book, recommend you read it if this story intrigues you.
Who will be the first to write an antivirus program for this?
DRAGON BOOK! I remember that. Now where’s the ugly pink shirt book.
Games are fun. While you’re at it, why not learn more about assembly? Here’s a free e-book that teaches assembly and CS concepts, Programming from the Ground Up: “… an introductory book to programming and computer science using assembly language. It assumes the reader has never programmed before, and introduces the concepts of variables, functions, and flow control.”
I think it’s not a good asm language for educational purposes.
– No signed integers
– No carry operations: rotate, add/sub, etc.
– Use “overflow” flag for carry conditions??
– JMP, RET: ok, but must be assembler macro
– [Mem],[Mem] is expensive, invalid in many CPUs
– MUL 2+ cicles, DIV only 3+ cycles? Unicorns too?
– IFx is a nice idea, but only useful in loops
I think HaD readers are being blinded by their own understanding of technology.
Think of all the people who bought and play Minecraft. Minecraft is an amazingly simple game. You get blocks which you put on other blocks. I can explain the concept of a brick block, a stone block, a cobblestone block to a three year old and have him able to build something resembling a structure in an hour or so. That is why Minecraft is so immensely popular. It’s easy to get into and learn and you can play it even if you don’t know but a fraction of the crafting recipes. All of it deals in real-world constants with almost zero abstractions involved outside of redstone. I just can’t picture even a fraction of this playerbase understanding or being interested in computing at this low of a level.
I want this to succeed, but I’m predicting a monumental failure in the making. I can’t even think of any Computer Science majors that I know who would even bother with something on this low of a level because most of them have only worked with high-level languages all of their lives. This is a game specifically aimed at hobbyists, the autistic, and engineers (none of which are exclusive to one another). People who do not need virtual 16-bit computers to play around with because they likely have microcontrollers of their own.
This isn’t going to stop HaD from controlling doors, turning on lights, posting on twitter, or delivering web-updates with the DCPU-16. Which makes me glad as I feel the tiny niche group of hackers and hobbyists may be the only people who ever end up playing this game.
@ Mmarrero …
1. 2’s complement Add and subtract are sign agnostic.
2. Carry/Overflow weirdness is actually very typical of mid 70’s minicomputers.
3. Some of those minicomputers had hardware add on boards; the HP2100A (the one I encountered via my Dad’s lab as a kid) had floating point in hardware as an option. The basic computer might not do 3 cycle multiply, but the add on card could.
The superfast mul/div is actually not such a stretch when you consider that the base clock of the computer is 170 kHz, consistent with magnetic core RAM, and even in 1975 pure silicon could be a lot faster than that.
I found this 16bit division code I used in a MS-DOS Voice Mail app I wrote in ’93 :-
DAX: DW 0
DDX: DW 0
DAXR: DW 0
DDXR: DW 0
;————————————————————
; WORDDIV – Divides DX:AX by BX, returns result in DX:AX
;————————————————————
worddiv:
MOV WORD PTR [DAX],AX
MOV WORD PTR [DDX],DX
MOV WORD PTR [DDXR],0
WD_L:CMP DX,BX ;You mustn’t divide if the high
JB WD_CONT ;word is greater than divisor
SUB DX,BX ;So just carry on subtracting
JMP WD_L ;until you got a Modulo.
WD_CONT:
DIV BX ;Divide
MOV WORD PTR [DAXR],AX ;Store in AX
MOV AX,WORD PTR [DDX] ;Divide just the High word
MOV DX,0
DIV BX
ADD WORD PTR [DDXR],AX ;and add it to the result
MOV DX,WORD PTR [DDXR]
MOV AX,WORD PTR [DAXR]
RET
DAX: DW 0
DDX: DW 0
DAXR: DW 0
DDXR: DW 0
;————————————————————
; WORDDIV – Divides DX:AX by BX, returns result in DX:AX
;————————————————————
worddiv:
MOV WORD PTR [DAX],AX
MOV WORD PTR [DDX],DX
MOV WORD PTR [DDXR],0
WD_L:CMP DX,BX ;You mustn’t divide if the high
JB WD_CONT ;word is greater than divisor
SUB DX,BX ;So just carry on subtracting
JMP WD_L ;until you got a Modulo.
WD_CONT:
DIV BX ;Divide
MOV WORD PTR [DAXR],AX ;Store in AX
MOV AX,WORD PTR [DDX] ;Divide just the High word
MOV DX,0
DIV BX
ADD WORD PTR [DDXR],AX ;and add it to the result
MOV DX,WORD PTR [DDXR]
MOV AX,WORD PTR [DAXR]
RET
Bugger…. ops pls delete this double post…
I think the DCPU will speak to the geek in us all…
I personally get great pleasure coding in LUA for the ComputerCraft addon for Minecraft. So having something else to do in a game that by definition, takes us away from the mundane, is great! Sometimes, solving complex problems with code is what any game needs. Nothing is more frustrating than trying to figure out someone else’s solution within a confined bit of code. So the geek in us all would rather just code our own solution, thereby making the solution uniquely ours while still keeping the game enjoyable and playable.
feels like a cpu designed by a cisc addict.
“Joy of assembly language”? Isn’t that an oxymoron? Clearly anyone who did some serious programming on ASM will disagree with you.
Because no games representing real-life tasks that aren’t fun are ever successful?
I heard of a game called Call of Duty that’s actually based on WAR! How horrible!
; Assembler test for DCPU
; by Markus Persson
; BLuRry: Reduced footprint by removing extra crud and introducing self-modifying code [EVIL!] These tricks will come in handy if space is a premium!
:start
set i, 0
:nextchar
set a, [data+i]
ife a, 0
:end
set PC, end
ifg a, 0xff
set PC, setcolor
bor a, b
set [0x8000+i], a
add i, 1
set PC, nextchar
:setcolor
set b, a
shl b, 8
add i, 1
sub [0x0e],1
set PC, nextchar
:data
dat 0x170, “Hello “, 0x2e1, “Hackaday”, 0x170, “, how are you?”