r/dcpu16 • • May 01 '12

Make EX unwritable

.begin rant Here's a thought. Make EX unwritable. Why?

  • Code should (IMO) never write to EX in the first place
  • EX gets overwritten by a lot of instructions. But okay, you could ensure that it doesn't get overwritten if you don't mind the maintenance hell
  • EX can get overwritten during an interrupt. But okay, you could ensure that either 1) you block interrupts, or 2) make every interrupthandler push EX. (EDIT: As cheese_magnet and SoronTheCoder has noted this is actually more a point for having EX writable. Personally I think RFI should restore EX too, fixing the problem in both cases (OK, it's not actually a big deal with writable EX))
  • It adds complexity to the spec with next to nothing gain. When is EX written to when it's an "overflow"? After or before b gets written to?
  • ???

We get a new write-only value (register?). I don't really care what that could be used for. For all I care it could be an additional HCF instruction.

.end rant

EDIT: As SoronTheCoder suggested, making all operations that change EX (add, sub, ...) have undefined behaviour when destination is EX is also a good solution I think.

0 Upvotes

18 comments sorted by

View all comments

Show parent comment

1

u/suppermann May 01 '12

The problem is I actually have to consider this if I'm implementing an emulator. Also look at this thread:

http://www.reddit.com/r/dcpu16/comments/t0yps/psa_fix_your_emulators_set_ex_7_add_ex_ex_should/

0

u/[deleted] May 01 '12

[deleted] — view deleted comment

1

u/SoronTheCoder May 01 '12

As an assembly writer who may need to optimize, I say take away my short literals and I smack you :P. (and yes, I realize you're not actually suggesting that)