??? 08/12/05 06:01 Read: times |
#99242 - the answer Responding to: ???'s previous message |
One step of assembler optimization is replacing CALL following by RET with one JMP. In my case: A_SUBROUTINE: CALL SAVE_CONTEXT ; a work CALL RESTORE_CONTEXT RETmight be replaced with: A_SUBROUTINE: CALL SAVE_CONTEXT ; a work JMP RESTORE_CONTEXT But in my case this kind of optimization must not be used such way! Routine RESTORE_CONTEXT supposes that return address is placed on the top of stack when it is called. And this is correct when the routine is called with CALL. But when it is executed by JMP the return address is not placed on the top of stack; the address is in stack deeply under values of all stored registers. So the routine uses wrong values as return address (here: values stored at the top of stack are values of R6:R7). This puzzle shows that there are subroutines which may not be executed with command JMP even they do work with CALL fully correct and as Dan said: CALL + RET != JUMP sometimes. Regards, Oleg |