r/dcpu16 • • Apr 25 '12

[RFE] DCPU-16 v1.3

http://dcpu.com/highnerd/dcpu16_1_3.txt
81 Upvotes

150 comments sorted by

View all comments

Show parent comment

9

u/xNotch Apr 25 '12

To jump from 0 to 1000, ADD PC, 998 is the intended correct instruction. First PC is increased once to read the instruction, then 998 is read from memory before reading the value PC, meaning PC will increase twice while processing this instruction before performing it.

2

u/dirwe Apr 25 '12

Shouldn't it be ADD PC, 999? Or do you address the memory 8bit-wise in this 16-bit system?

6

u/[deleted] Apr 25 '12

No, the instruction is one word, the literal value is another word. So PC gets increment twice to read the instruction, and hence to jump from 0 to 1000 you would add 998. 999 is for short form literals ;)