25

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 same colour in the end?

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Mr Speaker
  • 3,047
  • 24
  • 17
  • 5
    As far as I know the only official docs are here: http://0x10c.com/doc/dcpu-16.txt . So not sure you can get an answer unless Notch himself visits this site :-) My guess would be that they are not "reserved" registers and that they all are general purpose. – Ville Krumlinde Apr 04 '12 at 14:15
  • 1
    The interpreter is 140 lines of C code, don't hesitate to have a look-see. No, nothing special about those registers. – Hans Passant Apr 04 '12 at 14:35
  • @HansPassant Where is this interpreter? – Ville Krumlinde Apr 04 '12 at 15:41
  • At github, follow the google link. – Hans Passant Apr 04 '12 at 16:06
  • 1
    @HansPassant Do you refer to this one: https://github.com/swetland/dcpu16/blob/master/dcpu.c ? It's an unofficial implementation so I'd say it's not 100% guaranteed to run like the "real thing". But since it follows the spec and the spec does not say anything about special registers I agree it should be ok. – Ville Krumlinde Apr 04 '12 at 16:54

2 Answers2

23

Everything points out to the DCPU-16's eight main registers being "general purpose": while they are 'intended' for a certain use, programmers can use them as they will. The x86 has a similar architecture for its general registers.

The only special purpose registers on DCPU-16 are SP, PC and O.

Edit: The DCPU 1.3 specification introduces a single instruction (MVI) that adds 1 to both I and J after executing, with the intention of being used as a fast memory copy. Notch has expressed disliking this, so it might be eventually dropped, but now I and J are a bit special.

zaratustra
  • 8,148
  • 8
  • 36
  • 42
  • 5
    The intention of the x86 registers is encoded in the instruction set-- if you use them as they were originally imagined to be used, instructions tend to fit in 1 byte. http://www.swansontec.com/sregisters.html has a full treatment – rmmh Apr 04 '12 at 19:21
2

I'm sure conventions will emerge but the instruction set is completely orthogonal with respect to the registers A, B, C, X, Y, Z, I and J so there is no difference between them inherent in the DCPU-16.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
James Tauber
  • 3,386
  • 6
  • 27
  • 37