CALL w/o RET?
K2
Posts: 693
Since CALL and RET on the Propeller do not involve a stack, would any harm come from putting a second exit point into a CALLed routine, with the second exit point being a JMP? The JMP would be taken only if I never intended to RET at all. (In other words, I would be abandoning that particular execution thread.) Some time later I may CALL the same routine again, and perhaps this time use the RET.
While it may lose a few point in terms of readability or orthodoxy, I haven't thought of any reason why this wouldn't work. But I'm just a grasshopper.
While it may lose a few point in terms of readability or orthodoxy, I haven't thought of any reason why this wouldn't work. But I'm just a grasshopper.
Comments
Even the CALL is just as pseudo op-code that the assembler calculates for you.
The jmpret simple self-modify it's own jmp_return line.
@ Jazzed: One of the features I like most about the Prop is conditional execution. You've illustrated how convenient it can make branching.
In the case I'm dealing with, the JMP exit would be taken in response to an error condition detected inside the subroutine. By jumping out of the routine right then, the calling function (which operates at high speed) doesn't have to be cluttered with tests.
Nevertheless, breaking from established practice usually gets me into trouble. But the trouble could surely be minimized by clear documentation, as Cluso points out.
@Tony: Thanks for the great explanation. It makes laugh to consider how sly Chip was to employ such simple solutions. That's part of what makes the Prop so much fun to use.