2018-06-23 22:35:51 +00:00
|
|
|
#include "lib.h"
|
1984-11-29 14:22:02 +00:00
|
|
|
|
2016-12-12 20:16:32 +00:00
|
|
|
#define MAXNESTING 1000
|
1984-11-29 14:22:02 +00:00
|
|
|
|
|
|
|
int _gotable[MAXNESTING];
|
2016-12-12 20:16:32 +00:00
|
|
|
int topstk = 0;
|
1984-11-29 14:22:02 +00:00
|
|
|
|
2016-12-12 20:15:25 +00:00
|
|
|
void _gosub(int x)
|
1984-11-29 14:22:02 +00:00
|
|
|
{
|
2016-12-12 20:16:32 +00:00
|
|
|
/* administer gosub */
|
1984-11-29 14:22:02 +00:00
|
|
|
#ifdef DEBUG
|
2016-12-12 20:16:32 +00:00
|
|
|
printf("store %d in %d\n", x, topstk);
|
1984-11-29 14:22:02 +00:00
|
|
|
#endif
|
2016-12-12 20:16:32 +00:00
|
|
|
if (topstk == MAXNESTING)
|
|
|
|
error(26);
|
|
|
|
_gotable[topstk] = x;
|
1984-11-29 14:22:02 +00:00
|
|
|
topstk++;
|
|
|
|
}
|
2016-12-12 20:15:25 +00:00
|
|
|
int _retstmt(void)
|
1984-11-29 14:22:02 +00:00
|
|
|
{
|
2016-12-12 20:16:32 +00:00
|
|
|
/* make sure that a return label index is on top
|
1984-11-29 14:22:02 +00:00
|
|
|
of the stack */
|
|
|
|
#ifdef DEBUG
|
2016-12-12 20:16:32 +00:00
|
|
|
printf("return to %d %d\n", _gotable[topstk - 1], topstk - 1);
|
1984-11-29 14:22:02 +00:00
|
|
|
#endif
|
2016-12-12 20:16:32 +00:00
|
|
|
if (topstk == 0 || topstk == MAXNESTING)
|
1984-11-29 14:22:02 +00:00
|
|
|
error(1);
|
2016-12-12 20:16:32 +00:00
|
|
|
return (_gotable[--topstk]);
|
1984-11-29 14:22:02 +00:00
|
|
|
}
|