Mikroelektronika MIKROE-724 データシート

ページ / 726
672
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
Setjmp Library
The  Setjmp  library  contains  functions  and  types  definitions  for  bypassing  the  normal  function  call  and  return 
discipline.
Library Routines
 
- Setjmp 
 
- Longjmp
Setjmp
Prototype
sub function setjmp(dim byref env as word[4]) as integer
Returns
0
 if the return is from direct invocation 
nonzero  value
 if the return is from a call to 
Longjmp
 (this value will be set by the 
Longjmp
 
routine) 
Description This function saves calling position for a later use by longjmp.
Parameters: 
env
: buffer suitable for holding information needed for restoring calling environment 
Requires
Nothing.
Example
dim buf as word[4]
...
Setjmp(buf)
Notes
None.
Longjmp
Prototype
sub procedure longjmp(dim byref env as word[4], dim val as integer)
Returns
Nothing.
Description Restores calling environment saved in the 
env
 buffer by the most recent invocation of 
setjmp
. If there 
has been no such invocation, or the function containing the invocation of setjmp has terminated in the 
interim, the behavior is undefined.
Parameters: 
env
: buffer holding the information saved by the corresponding 
setjmp
 invocation 
val
: value to be returned by the corresponding 
setjmp
 function 
Requires
Invocation  of 
longjmp
  must  occur  before  return  from  the  function  in  which 
setjmp
  was  called 
encounters.
Example
dim buf as word[4]
...
Longjmp(buf, 2)