ASM aliases for ALTx would be convenient.
pik33
Posts: 2,366
Instead of addressing modes as in 6502 or 68000 we have ALTx instructions.
What if to add aliases for these instruction, like ## for long immediates?
This can make the code easier to read (and write)
Instead of
altr base,#offset add a,b alts table,#1 mov c,0-0
there may be
add [base+offset],a,b mov c,table[1]
Let the compiler do the work instead of us and let these 0-0 disappear
And there is alti...
If I can understand, it enables things like
add result++, source--
but we need to manually prepare its bitfield. So.. what if we can extend the asm syntax to do it for us?
Comments
This has been requested on the forum before. Syntax for 'hidden' ALTI instructions could be interesting.
Chip might have more time for these suggestions now. He appears to be back on the forums again.
I agree these would help us write code more easily. You have to get your mind into granny gear to do any of this right now, so it's painful. It's probably causing these features to be under-utilized.
We'd need to list out all the permutations that would be common.
I feel like obscuring the nature of ALTx may be somewhat harmful. If it just looks like an addressing mode, you maybe wouldn't realize that using it repeatedly doubles the time and size the code requires and that it can be used in creative ways.
Then again, I don't really have a problem with ALTD/ALTS/ALTR. I do keep forgetting what the ALTS bits do though.
Addendum: some creative uses of ALTx in my recent memory
You can use it on immediates, for example to subtract one without altering the variable:
When writing code to be SKIPF'd, you can skip just the ALTx to let the original D/S through:
I'll start with classifying the addressing modes:
#number
. AUGmented above #511.Hmm, there's also PTRA/B indexing. My brain's farting right now ... Indexed memory direct maybe.
EDIT: Found my earlier suggestions - https://forums.parallax.com/discussion/comment/1524252/#Comment_1524252
I think nobody wants to remove original ALTx instruction form the asm so you can still use ALTx as you can still use setq/imm instead of ##
About size and time... classic processors do the same: some instructions have prefixes, they have more bytes and execute longer, it is normal. We can treat altx+next instruction combination as single 64-bit opcode which executes in 4 clocks while still understanding the nature of these instructions.