Hi Bitwise, that's looking good! Not sure about this bit tho:
Code:
00000014' 00000000 : .BYTE LO ($+2),HI ($+2)
This reminds me of something I've thought of only recently, that being the behavior of the "<" and ">" and "^" bit-extraction operators.
So far just about all the changes I've made have been confined to one source module, the "code generator". It turns out that nothing outside it really cares about how big a "byte" is (including the module that keeps track of the program counter, however non-intuitive that may seem).
Except, perhaps, these operators. I consider them short-hand for "shift and mask" expressions, that is, you can get the same effect by applying a shift followed by masking out unwanted bits (which is how they're implemented internally anyway).
As things stand I haven't changed their behavior. But that means using "^value" instead of ">value" to get the "high byte" (bits 31..16 of a 32-bit value instead of bits 15..08 of that same value).
If I change their behavior to "expected" then they'll become useless in the case of 32-bit bytes (only "<" would work, and so what?) and there will be no built-in way of accessing any octet of a 32-bit value. If I don't change them there's the nuisance of learning a new convention.
Hmm, if I implemented LO() and HI() functions I could change their behavior to match the "byte size" without changing the existing operators. HI() would presumably always return zero in a 32-bit byte world, at least until I have 64-bit values to play with...
Any thoughts?
=======
Slow learner. Okay, seeing as these "shortcut" operators were implemented internally via function calls anyway, it's really not a whole lot of trouble to change the function that's called. Perhaps to something that is "byte size" aware...
So I did. "<"= least significant "byte", ">" = "next-to-least significant byte", "^" = "most significant word". They all work for 8-, 16- and 32-bit "bytes", but may return zero if what's asked for doesn't exist in this implementation (eg., in the 32-bit world only "<" can be non-zero, 'cause there isn't anything larger. Kinda pointless, but at least consistent!).
You want individual octets within the "bytes"? Ah, it's shift-and-mask time in the 16- and 32-bit realms.
And...I think that's it. I can't think of any other basic code changes that need to be made. I can cut down the native 65xx version to make a preliminary 65Org16 native version, but that's all that might be left.