Registers_-

A register may be used to pass variables between subroutines as shown in the following example. The address of a block of data (BLOCK) is loaded into register 9 prior to the subroutine call. By putting $RSAVL=8 prior to the Subroutine statement, register 9 would not be saved on entering the subroutine, and its contents can be accessed by the subroutine.

SUBROUTINE TEST_IT DM ; Data memory BLOCK: DS 6 ; Block of data PM ; Program memory LA 9,BLOCK ; Load R9 with address of block of data CALL ZERO_BLOCK RETURN END $RSAV0=0 $RSAVL=8 ; save registers 0-8 SUBROUTINE ZERO_BLOCK PM ; Program memory LA 12,U_ZERO(,) ; load address of zero block NOP ; avoid index register contention NOP LM 0,5,0(12) ; load some zeroes into registers 0-5 STM 0,5,0(9) ; store contents of registers 0-5 in BLOCK RETURN END

Globals_-

The BNL787 fixed locations (defined as global symbols) are accessible to all subroutines. However, users may wish to pass symbols that are not BNL787 fixed locations between subroutines. Since the BNL787 fixed locations do not take up the whole of the first 4K bytes of DM, a file has been created to reserve space for any symbols that a user may need. This file MUST be named USER_RES.MAR. An example file is found in the directory 787EXAMPLES:. This file must be present in the same directory as the files being linked with the DLINK command, but may be only a dummy if not needed. It is up to the user to ensure that the user reserved locations do not exceed the first 4K of data memory.

The USER_RES.MAR may also contain marker blocks (see above) if several subroutines need access to the data stored. A

convention has been established in the BNL787 USER_RES.MAR that the symbols should be preceded by "U_" . This makes the identifications of USER_RES symbols in subroutines obvious. Thus a programmer will be aware that all symbols beginning with "$" (see BNL787_DEFINED_LOCATIONS) or "U_" should be followed by "(,)" to denote that no base register is to be used.

A feature of the BNL standard cross-assembler is that these "absolute" symbols cannot be used as variables of a DO loop. Thus the statement

DO 5,U_START(,),U_STOP(,)

will be rejected by the cross-assembler. This can be corrected by loading the values of U_START and U_STOP into registers or local variables.

Argument_list_-

A new feature introduced in BNLSYS version 4.00 is the possibility of passing variables between subroutines using an argument list. This is really a special case of passing variables via registers, as described above. In this case, a list of arguments follows the Call statement. The arguments are automatically stored in consecutive locations in DM, and register 1 is used to point to the address of the first variable (see BNLSSP:|SSP_PROGRAMMER.MEM).

Note that if an argument list is used with a Call statement, the contents of register 1 is overwritten. If no arguments are used, register 1 is not changed, and can be used to pass information to the subroutine - thus BNLSYS version 4.00 is downwards compatible.

Converted from .HLP to .HTML by HLPTOHTML.