techcompliant / TC-Specs

Specifications for in-game computer design
28 stars 14 forks source link

Add a special register to offset addresses #13

Closed L3nn0x closed 8 years ago

L3nn0x commented 8 years ago

It would be interesting to add a special register CS (just like the interrupt handler address IA) that would offset all RAM accesses. This register would be set to 0 on boot and only be changeable via two opcodes : one to set it and one to get its value. The PC register would not be affected, nor the interrupt handler address nor RFI. But SET PC, address would be affected, as with all the other memory accesses (jsr too).

This addition would permit a basic program relocation system to be put into the game, thus allowing more freedom to create even more awesome DCPU programs!

=====special opcodes (5 bits)=====
| Cycles | Opcode | Mnemonic | Description  |
|--------+--------+----------+--------------|
| 1      | 0x15   |  CSG a   | sets a to CS |
| 1      | 0x16   |  CSS a   | sets CS to a |

Edit : some precisions after discussing it on irc : the CS register would only be used internally for RAM accesses, which is [ ] and PC. CS doesn't change the value of PC or SP, it just offset them when accessing the RAM. The interrupt handler address wouldn't be modified by CS. When setting CS, PC is modified accordingly to stay at the same position.

paultech commented 8 years ago

As discussed in IRC. This method is not suitable for the task and keeping in the limitations of the DCPU lore.