Shortened Constants

 

I've been quite disgusted with the way that constants &emdash; both numeric and verb &emdash; are handled by my system. It's a godawful mess! I am sorely tempted by an alternative that will require me to go back and rewrite a lot of code, but might be better in the long run. It would limit all numeric and verb constants to values of ±8192 or less. This will certainly not be a problem with verb constants, and I have difficulty imagining it giving us trouble with numeric constants. We implement this with the high bit of the 16-bit word. If the S-code has its bit #15 set (hence is less than zero), then it is a constant of some sort. Bit #14 tells us whether this is a numeric constant or a verb constant. Bit #13 gives us the sign of the constant and the other 13 bits give us its value; this permits values of ±8192. Really, this would greatly simplify the code.

 

I am a little worried about how to sign-extend a 13-bit word. I suppose that, after I strip off the top two bits, I can simply say

if (value > 8191) then value = 8192 - value;

 

Yeah, sure.

 

The advantage of this is that it greatly simplifies all the calculations with tokens. I just don't know when I can get to it.