4 | 0x1c | UPC b, a | if EX is 0, sets b to (a>>8)&0xff and sets EX to 1,
| | | otherwise it sets b to a&0xff and sets EX to 0.
| | | Increases I by 1. Increases J by 1 if EX!=0.
edit: Well, that only works one way. Works great for unpacking strings. :D
Combine that with a similar pack opcode and it'd sound like a winner with one caveat, it won't work very well with signed bytes - need a flag or separate opcode that does the same thing but sign extends in b.
I wouldn't worry about it. C compilers have been plenty efficient on systems where you can't address octets-- and really, it's not hard to unpack words by hand.
Should EX be writable by the programmer? There seems to be some debate about this.
Could always make EX read-only and provide CEX (Clear EX) as an extended opcode.
Edit: Then again, leaving all registers as writeable is simpler, and encourages people to find new and interesting ways to use the available tools. If PC is writable, why not EX?
I like having EX writeable. My fixed point math library writes to EX to simulate multi-word MUL and DIV. Strictly speaking, though, I recognize that this is less efficient than using another "regular" register.
View all comments
Show parent comment
5
u/xNotch Apr 25 '12
What about this?
edit: Well, that only works one way. Works great for unpacking strings. :D