This is really silly, but I just can't figure it out. I want to do what sounds like an extremely simple thing: make a 64-bit number out of two 32-bit numbers, one (e.g. L%) representing the LS 32-bits and the other (e.g. H%) the MS 32-bits; it's a requirement that it works in both the (default) *HEX 32 mode and the *HEX 64 mode.
Trivial surely? But not, by all accounts. Here are some of the things I've tried:
Doesn't work
when L% is negative, because after sign-extension to 64-bits the MS 32-bits will be &FFFFFFFF which will force the MS 32-bits of the result to be &FFFFFFFF too!
Code: Select all
r%% = L% AND &FFFFFFFF OR H% << 32
Doesn't work because the &FFFFFFFF is sign-extended to &FFFFFFFFFFFFFFFF and the AND does nothing!
Code: Select all
r%% = L% AND &00000000FFFFFFFF OR H% << 32
Doesn't work because the MS 32-bits of the hexadecimal constant are discarded, so it's the same as the previous example!
Code: Select all
r%% = (L% << 32) >> 32 OR H% << 32
Doesn't work because the << operator sign-extends into the 32 MS bits!
Code: Select all
r%% = (L% <<< 32) >>> 32 OR H% <<< 32
Doesn't work because the >>> 32 ignores the MS 32-bits!
In fact the only thing I've tried which does work is this, which is messy (and triggers a warning from the Cross-Reference Utility that Y% isn't used):
Am I missing something obvious, or is this seemingly trivial task more difficult than you might think? Can you find a better way to do it?