Skip to content

ADDRESS instruction without operands doesn't swap environments. #18

@RossPatterson

Description

@RossPatterson

TRL2 says that an ADDRESS instruction with no operands switches to the previously active command environment:

If ADDRESS is specified without either an environment name or an expression, then commands will be routed back to the environment that was selected before the previous lasting change of environment was made (and the current environment name is saved). Repeated execution of just "ADDRESS" will therefore switch the command destination between two alternative environments.

(Sec. 7 pp. 41)

The ANSI standard agrees:

At any given time, there will be two environments, the active environment and the alternate environment.

AddrInstr:
/* If ADDRESS keyword alone, environments are swapped. */
if \#Contains(address,taken_constant),
 & \#Contains(address,valueexp),
 & \#Contains(address,'WITH') then do
   call EnvAssign TRANSIENT, #Level, ACTIVE, #Level
   call EnvAssign ACTIVE, #Level, ALTERNATE, #Level
   call EnvAssign ALTERNATE, #Level, TRANSIENT, #Level
   return

(Sec 8.3.1, pp. 74)

bREXX doesn't do this. Instead, a bare ADDRESS always sets the environment to the "system string", which in CMS370 is "CMS":

static void
C_address( void )
{
	if (symbol == semicolon_sy) {
		_CodeAddByte(OP_PUSH);
			_CodeAddPtr(systemStr);
			TraceByte( other_middle );
		_CodeAddByte(OP_STOREOPT);
			_CodeAddByte(environment_opt);
		return;
	}

(compile.c)

static void
I_StoreOption( const PLstr value, const int opt )
{
	long	l;

	switch (opt) {
		case environment_opt:
			if (LLEN(*value) > 250)
				Lerror(ERR_ENVIRON_TOO_LONG,1,value);
			if (_proc[_rx_proc].env == _proc[_rx_proc-1].env)
				LPMALLOC(_proc[_rx_proc].env);
			Lstrcpy(_proc[_rx_proc].env,value);
			break;

(interpre.c)

We should change bREXX to do what TRL2 and the standard say.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions