Does PASM offer an indexed or indirect JMP or CALL?
K2
Posts: 693
I need to jump to one of 16 routines, depending on the state of four bits. If I read the manual right, the s and d fields of JMP and CALL instructions are calculated at assembly time. Can MOVS and MOVD still be used on them to do indexed jumps or calls? Can someone steer me to an example of indexed or indirect execution?
Comments
Edit: Oops. Looked like our posts crossed, Mike. Looks like you've just answered my follow-up question, too. Thank you!
-Phil
-Phil
-Phil
BTW, grandma is having a problem. For the life of me I can't understand why this isn't working. It's based on Phil's #5 post. Somehow I screwed up his perfectly great idea.
The actual busted code is much bigger. I wrote this pedacito just to pare down the problem to its essentials..
It looks like you added a line ahead of exp, so index never gets initialized.
-Phil
Marko, that's a fascinating optimization you used. In the morning I'm going to look into it further.
The Prop is so unusual that I've been timid to wander too far from the reservation. But it's not like something is going to blow up. Probably.
Anyway, you are all great examples of digging in and figuring things out, a trait I'd love to possess.
Based on all the excellent info from yesterday, I figured I could store the address of a routine in a long (named LOC_RET in this case) and later jump to that long (without #) and it would take me to the routine. Maybe it is doing that, but it seems certain from the diagnostic link (Prop Term) that something goes akimbo very quickly. (Initializing 'count' helped a lot in that regard. )
This is taken from a template I created for PASM code that accepts a command from another cog. It's simple and it always seems to work. I'm an actor. I like simple.
BTW, Thank you!!
electrodude
Perhaps if I hadn't been delving into the dangerous territory of JMPs w/o #, I wouldn't have made such a blunder, but who knows? I'll have to ponder that question while I'm assembling miniature log cabins this evening.
Still, the latest version (post 20?) works really well and is less cumbersome than my previous efforts, so perhaps it was worth a few dumb mistakes to get to that point. I've folded the great grandmother approach into the full code (302 lines of asm) and it spins like a top. Now that the needed functionality has been achieved I'm free to tweak it to death.
"i" stands for "immediate," not "indirect." When the bit is set (i.e. JMP #target), the jump location is in the source field of the instruction. When the bit is cleared (i.e. JMP target), the contents of the target location, pointed to by the source field, are used for the jump address.
-Phil