Questions tagged [dcpu-16]

The DCPU-16 is a simple 16-bit CPU used for the 0x10^c game by Notch.

The DCPU-16 is a simple 16-bit CPU used for the 0x10c game by Notch. See 0x10c.com for more information about the game; you can also find the DCPU-16 spec there.

Useful tools

  • DCPU-16 toolchain - yes, someone's written a development toolchain including compiler, standard library, linker, assembler, emulator and kernel.
  • dcpu.ru - the jsfiddle equivalent for DCPU-16.
25 questions
25
votes
2 answers

Are the I and J registers special in DCPU-16?

DCPU-16 includes 8 general registers named A, B, C, X, Y, Z, I and J. It's a bit of a programmer "trope" to use I and J for loop counters. In DCPU-16, are I and J specialized registers, that should only be used in loops - or do they all end up the…
Mr Speaker
  • 3,047
  • 24
  • 17
10
votes
4 answers

Portability of C code for different memory addressing schemes

If I understand correctly, the DCPU-16 specification for 0x10c describes a 16-bit address space where each offset addresses a 16-bit word, instead of a byte as in most other memory architectures. This has some curious consequences, e.g. I imagine…
Wim Coenen
  • 66,094
  • 13
  • 157
  • 251
10
votes
4 answers

Is a preemptive multitasking OS possible on the interruptless DCPU-16?

I am looking into various OS designs in the hopes of writing a simple multitasking OS for the DCPU-16. However, everything I read about implementation of preemptive multitasking is centered around interrupts. It sounds like in the era of 16-bit…
Andrew Gorcester
  • 19,595
  • 7
  • 57
  • 73
9
votes
2 answers

How to understand the first line of the DCPU-16 specs assembly example?

I am trying to understand the specs, but fail to understand the first line of the example given: SET A, 0x30 ; 7c01 0030 Here is what I understood from the specs: the first word (7c01) fully defines the instruction the operator is 0x1…
Timothée HENRY
  • 14,294
  • 21
  • 96
  • 136
8
votes
1 answer

What is the appropriate Racket/Scheme idiom for this code?

I'm new to racket/scheme, so i decided to learn by implemeting an emulator for the DCPU-16, a simple 16 bit processor. My question is thus: What is a better way to implement my solution? This is the solution I hacked together to control the cpu's…
Kevin Coffey
  • 386
  • 1
  • 6
7
votes
1 answer

How did Turbo Pascal overlays work?

I'm implementing an assemblinker for the 16-bit DCPU from the game 0x10c. One technique that somebody suggested to me was using "overlays, like in Turbo Pascal back in the day" in order to swap code around at run time. I get the basic idea (link…
Aubrey Jones
  • 123
  • 6
7
votes
2 answers

Can you write to [PC]?

According to the DCPU specification, the only time a SET instruction fails is if the a value is a literal. So would the following work? SET [PC],0x1000 A more useful version would be setting an offset of PC, so a rather strange infinite loop would…
Matt
  • 7,100
  • 3
  • 28
  • 58
6
votes
1 answer

Signed arithmetic/control-flow in DCPU-16?

DCPU-16 (the CPU in Notch's new game) doesn't seem to have any signed IF/MUL/DIV instructions. Is there still a way to do signed arithmetic/control-flow that isn't super incredibly painful?
BlueRaja - Danny Pflughoeft
  • 84,206
  • 33
  • 197
  • 283
6
votes
1 answer

is DCPU-16 assembler 'dat' with a string supposed to generate a byte or word per character?

It's not clear to me whether dat "Hello" is supposed to generate 5 words or 3 (with one byte of padding)
James Tauber
  • 3,386
  • 6
  • 27
  • 37
4
votes
1 answer

Reducing size of switch statement in emulator?

I started writing a DCPU-16 emulator using this v1.7 spec. I started laying down the architecture, and I don't like the fact that I'm using very long switch statements. This is my first time writing an emulator, and so I don't know if there's better…
Bertie Wheen
  • 1,215
  • 1
  • 13
  • 20
4
votes
2 answers

DCPU-16 DIV instruction

I'm looking at the specification for the DCPU-16 and I'm having trouble understanding the purpose of the overflow value with the DIV instruction: DIV a, b - sets a to a/b, sets O to ((a<<16)/b)&0xffff. Can anybody explain the semantic meaning of O…
Chad
  • 7,279
  • 2
  • 24
  • 34
4
votes
1 answer

Optimizing DCPU-16 FizzBuzz

I tried to implement FizzBuzz in DCPU-16. I use this web emulator: http://mappum.github.com/DCPU-16/ (repository: https://github.com/mappum/DCPU-16). It stops before the end of the loop. Why? How can I optimize it? I'm a high level language…
halukul
  • 65
  • 4
2
votes
2 answers

DCPU-16 won't accept input from keyboard

I've started learning assembly for the DCPU-16 to prepare for 0x10c, but upon arriving at the conclusion of the tutorial I was running through, I found that the program wasn't responding to keyboard input. Going into step by step, I found that the…
2
votes
1 answer

Keeping track of original line numbers through macro expansion

I'm working on a assembler for fun, written in C,flex,bison. I'd like to add macros, includes and repeating blocks and was thinking of doing this with a separate preprocessing stage parser. My question is, how might I keep track of original source…
blueshift
  • 6,742
  • 2
  • 39
  • 63
2
votes
2 answers

Writing RC4 for a 16 bit system

I am writing RC4 for the DCPU-16, however I have some questions before I begin. RC4 algorithm: //KSA for i from 0 to 255 S[i] := i endfor j := 0 for i from 0 to 255 j := (j + S[i] + key[i mod keylength]) mod 256 swap values of S[i] and…
Scott Chamberlain
  • 124,994
  • 33
  • 282
  • 431
1
2