8 killing the call stack, Killing the call stack -29 – ElmoMC SimplIQ Software Manual User Manual

Page 58

Advertising
background image

SimplIQ

Software Manual

4BThe

SimplIQ

User Programming Language

MAN-SIMSW (Ver. 1.4)

5-29

5.8.8

Killing the Call Stack

In rare situations, it may be desirable to exit a function without returning to its return
address. The reset instruction solves this problem by emptying the call stack before making
a jump.

Syntax:
reset<JUMP_NAME>

The valid jump after the reset keyword is one of the following:
ƒ

Label

ƒ

Auto-routine

ƒ

User function with no defined input arguments

All other expressions or absence of expressions after the reset keyword are illegal.

A label in a reset expression must be global. A local label is illegal, because the stack

will be emptied and all local variables and the return address of the function to which
the local label belongs will be erased.

Example:
Assume that a drive (an axis) runs a programmed routine. An inspection station may assert
a “Product defective” digital signal that is coupled with digital input #1. An automatic
routine is therefore coupled to digital input #1 in order to stop the part assembly and
prepare for the assembly of the next part.

##START_NEW

Label for starting a new part.

… Working

code.

Last line of working code.

#@AUTO_I1

Subroutine

label.

PA=0;BG

Return axis to origin.

reset START_NEW

Clear stack and go to beginning.

The reset in the #@AUTO_I1 routine is required because it is not known if any function calls
are executing when digital input #1 is asserted. If a function is executing, the reset prevents
junk from accumulating in the call stack. Otherwise, the call stack is empty and reset does
no harm. Note that after the reset, control does not return to the function that was executing
prior to the #@AUTO_I1 routine. The stack is cleared and the return address to the
interrupted function is removed from the stack.

The #@ATUO_I1 routine is executed after the work code is completed for every

assembled part. The program proceeds from the last line of the working code to
PA=0;BG,

which resets the machine for another part assembly. The next instruction is

a reset to the START_NEW label.

Advertising