Elmo HARSFEN0602 Killing The Call Stack, Automatic subroutines List Of Automatic Routines, PA=0BG

Models: HARmonica HARSFEN0602

1 220
Download 220 pages 51.63 Kb
Page 49
Image 49

HARSFEN0602ElmoHARmonicaSoftwareManual

PRELIMINARYDRAFT

5.6.8Killing The Call Stack

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

jump.

Syntax:

reset <JUMP_NAME>

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

1.label

2.auto routine

3.user function with no defined input arguments

All other expression or absence of expression after the keyword ‘reset’ is illegal.

Remark: Label in reset instruction must be global. Local label is illegal, because the stack will be emptied and all local variables and return address of the function to whose the local label belongs will be erased.

Example:

Assume that an Amplifier (an axis) runs a programmed routine.

An inspection station may assert a “Product defective” digital signal. The “Product defective” signal is coupled to the digital in#1 input.

An automatic routine is coupled to the digital in#1 input, to stop the part assembly and get ready 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 the stack and go to the beginning

The reset in the #@AUTO_I1 routine is required since we do not know if any function calls are executing when Digital In #1 is asserted. If a function was executing, the reset prevents junk gathering in the call stack. Otherwise, the call stack was empty and the reset does no harm. Note that after the reset control does not return to the function which was executing before Digital In# is occurred. Stack was cleared and the return address to the interrupted function was removed from the stack.

Note

The #@AUTO_I1 routine is executed after the work code is done 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.

5.6.9Automatic subroutines

5.6.9.1List Of Automatic Routines

A special kind of routine is the auto routine. These routines are executed automatically

47

Page 49
Image 49
Elmo HARSFEN0602 Killing The Call Stack, Automatic subroutines List Of Automatic Routines, ##Startnew, #@AUTOI1, PA=0BG