Getting 12 year olds to learn assembly programming

[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.

Comments

  1. Hito says:

    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.

  2. mw says:

    s/Torvolds/Torvalds

  3. Brian says:

    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.

    • nes says:

      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.

  4. Gdogg says:

    DCPU-16 made in minecraft incoming.

  5. go_go_dancer says:

    How long until we see the linux port?

  6. warspigot says:

    10^C=0x0001 0000 0000 0000, which is the number of years that they were sleeping(or whatever it is)

  7. hpux735 says:

    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.

  8. Thesandlord says:

    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.

  9. Mihail121 says:

    Comment removed

  10. effgee says:

    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 ?

  11. unlimitedbacon says:

    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.

  12. baconisbacon says:

    “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.

  13. saul_goode says:

    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.

  14. Jarel says:

    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?

    • andar_b says:

      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.

      • Jarel says:

        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.

      • saul_goode says:

        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.

  15. mstone says:

    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.

  16. cdilla says:

    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.

  17. AussieTech says:

    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

  18. Bob Thing says:

    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?

    • blep says:

      because fun.

    • mstone says:

      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.

    • daniel says:

      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.

  19. Alex Rossie says:

    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.

  20. Aud1073cH says:

    Who will be the first to write an antivirus program for this?

  21. Setatx says:

    DRAGON BOOK! I remember that. Now where’s the ugly pink shirt book.

  22. grbgout says:

    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.”

  23. Mmarrero says:

    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

  24. mg says:

    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.

  25. localroger says:

    @ 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.

  26. paulmcguinness says:

    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

  27. paulmcguinness says:

    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

  28. zhivotnoya says:

    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.

  29. scatterbrained says:

    feels like a cpu designed by a cisc addict.

  30. itoctopus says:

    “Joy of assembly language”? Isn’t that an oxymoron? Clearly anyone who did some serious programming on ASM will disagree with you.

  31. BLuRry says:

    ; 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?”

  32. rue_mohr says:

    aha! I could use an avr as a ALU for multiplication/division! (its that or a 4G lookup table) (x2)

    hmmm…. 11 alu instuctions….
    6 ports for data in/out 4 bits for operation selection…
    52 io bits…..might have to mux something…

  33. b0rnc0nfuesed says:

    ox10c is not pronounced trillek, it is said ox10c, as notch has said it himself.

  34. Adam Johnson says:

    I remember being six years old messing with an old 16-bit computer. But unlike others, I wasn’t using languages like BASIC. I was doing things in pure Assembly.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 94,591 other followers