ALTDS replaced with ALTI/ALTR/ALTD/ALTS
cgracey
Posts: 14,155
In the next release...
What was ALTDS is now ALTI.
There are three new instructions that share the opcode space with ALTI (no more C/Z writing options, as they were meaningless for these instructions):
ALTR D,S/# - use the sum of D and S/# for the result register in the next instruction
ALTD D,S/# - use the sum of D and S/# for the D register in the next instruction
ALTS D,S/# - use the sum of D and S/# for the S register in the next instruction
The idea is that D is an offset and S/# is a base:
ALTx offset,#base
So, now we'll have simple-to-use instructions for R/D/S alterations.
This cleans up 78rpm's task switcher.
OLD CODE
NEW CODE
What was ALTDS is now ALTI.
There are three new instructions that share the opcode space with ALTI (no more C/Z writing options, as they were meaningless for these instructions):
ALTR D,S/# - use the sum of D and S/# for the result register in the next instruction
ALTD D,S/# - use the sum of D and S/# for the D register in the next instruction
ALTS D,S/# - use the sum of D and S/# for the S register in the next instruction
The idea is that D is an offset and S/# is a base:
ALTx offset,#base
So, now we'll have simple-to-use instructions for R/D/S alterations.
This cleans up 78rpm's task switcher.
OLD CODE
task_switcher ' this is the task switcher isr ' save current task addct1 task_time, ##TASKS_TIMER mov modify, curr_task_index add modify, #task_ctrl_blk altds modify, #%000_100_000 ' replace D reg mov 0-0, IRET1 ' tcb[ task index] add curr_task_index, #1 ' next task and curr_task_index, #$3 ' in range 0 - 3 ' set new task mov modify, curr_task_index add modify, #task_ctrl_blk altds modify, #%000_000_100 ' replace S reg mov IRET1, 0-0 ' tcb[ task index] reti1
NEW CODE
task_switcher addct1 task_time,##TASKS_TIMER 'set next interrupt time altd curr_task_index,#task_ctrl_blk 'save current task mov 0,IRET1 incmod curr_task_index,#3 'inc/reset task pointer alts curr_task_index,#task_ctrl_blk 'set new task mov IRET1,0 reti1 'execute new task
Comments
Can you include an ALTI summary, for completeness ?
Can ALTx D,S/# be chained?
Yes. They can be chained.
Wait! Not like in your example. One ALTx can modify the next ALTx, but you can't wind up with both D and S modified in your final instruction, unless you use ALTI, which is the old ALTDS. ALTI is more complex to use.
D normally defines where the result is to be written, ALTI or ALTR can redirect the write, while D remains one of the operands to be read.
And ALTS prefixing RDFAST could be used I presume?
It either has to be via special registers, or with a prefix instruction like I've done here.
Special registers would be faster, but we'd probably only have two of them. They would be a pain to save and restore in interrupts or between routines.
Doing indirection with a prefix instruction takes more time and code, but you can have as many of them as you want, which saves code over special registers. Plus, it's very cheap to do in hardware.
In the above code, ALTD adds ("alt" is a misnomer here) the value at curr_task_index to the D address in the next instruction. This might not be exactly right, but you get the idea...
Probably not enough time in the instruction cycle for the add.
Yes.
Good point, makes sense from an encoding viewpoint but I suspect that would restrict "task_ctrl_blk" to an immediate value only.
Actually, I just made assembler aliases for the unary cases of these instructions:
Oh, wait! I see what you are proposing. As someone pointed out, there would be no time for that add, as any substitution has to be done before the cog RAM data is latched. There's no time to add anything, only mux something - and nothing can be dependent on the RAM data, as it's arriving very late.
into a 128 bit instruction with ALTR, ALTD, and ALTS preceeding an ADD instruction. At least that would be more readable.
Edit: replaced '*' with parens to indicate indirection.
Edit2: corrected arithmetic
Yeah, I suspected as much also. But I figured I'd throw it out there in case it sparked an idea.
Did you mean ALT instead of AUG?
I am being very non-serious, but my isr is used as a code example in this thread. Consider changing ram size from 32 to 33-1/3 bits per long, the extra bit and a bit will facilitate long play. :crazy: :clown: :crazy:
If we did that wouldn't we have to also switch from digital to analog?