2. RMAC RELOCATING MACRO ASSEMBLER


The CP/M Relocating macro Assembler, called RMAC, is a modified version of the CP/M Macro Assembler (MAC). RMAC produces a relocatable object file (REL), rather than an absolute object file (HEX), which may be linked with other modules produced by RMAC, or other language translators such as PL/I-80, to produce an absolute file ready for execution.

The differences between RMAC and MAC are described in the following sections. For a complete description of the assembly language and macro facilities, see CP/M MAC Macro Assembler: Language Manual and Application Guide.
 

2.1. RMAC Operation

RMAC is invoked by typing
 

RMAC filename.filetype


followed by optional assembly parameters. If the filetype is not specified, ASM is assumed. RMAC produces three files: a list file (PRN), a symbol file (SYM), and a relocatable object file (REL). Characters entered in the source file in lower case appear in lower case in the list file, except for macro expansions.

The assembly parameter "H" in MAC, used to control the destination of the HEX file, has been replaced by "R", which controls the destination of the REL file. Directing the REL file to the console or printer (RX or RP) is not allowed, since the REL file does not contain ASCII characters.

Example:
 

RMAC TEST $PX SB RB


directs RMAC to assemble the file TEST.ASM, send the PRN file to the console, and put the symbol file (SYM) and the relocatable object file (REL) on drive B.
 

2.2. Expressions

The operand field of a statement may consist of a complex arithmetic expression (as described in the MAC manual, section 3) with the following restrictions:

1) In the expression A+B, if A evaluates to a relocatable value or an external, then B must be a constant.

2) In the expression A-B, if A is an external, then B must be a constant.

3) In the expression A-B, if A evaluates to a relocatable value, then:

a) B must be a constant, or

b) B must be a relocatable value of the same relocation type as A (both must appear in a CSEG, DSEG, or in the same COMMON block).

4) In all other arithmetic and logical operations, both operands must be absolute.
An expression error ('E') will be generated if an expression does not follow the above restrictions.
 

2.3. Assembler Directives

The following assembler directives have been added to support relocation and linking of modules:
 

ASEG use absolute location counter
CSEG use code location counter
DSEG use data location counter
COMMON use common location counter
PUBLIC symbol may be referenced in another module
EXTRN symbol is defined in another module
NAME name of module
The directives ASEG, CSEG, DSEG and COMMON allow program modules to be split into absolute, code, data and common segments, which may be rearranged in memory as needed at link time. The PUBLIC and EXTRN directives provide for symbolic references between program modules.

NOTE: While symbol names may be up to 16 characters, the first six characters of all symbols in PUBLIC, EXTRN and COMMON statements must be unique, since symbols are truncated to six characters in the object module.
 

2.3.1. The ASEG Directive

The ASEG statement takes the form
 

label ASEG


and instructs the assembler to use the absolute location counter until otherwise directed. The physical memory locations of statements following an ASEG are determined at assembly time by the absolute location counter, which defaults to 0 and may be reset to another value by an ORG statement following the ASEG statement.
 

2.3.2. The CSEG Directive

The CSEG statement takes the form
 

label CSEG


and instructs the assembler to use the code location counter until otherwise directed. This is the default condition when RMAC begins an assembly. The physical memory locations of statements following a CSEG are determined at link time.
 

2.3.3. The DSEG Directive

The DSEG statement takes the form
 

label DSEG


and instructs the assembler to use the data location counter until otherwise directed. The physical memory locations of statements following a DSEG are determined at link time.
 

2.3.4. The COMMON Directive

The COMMON statement takes the form
 

COMMON /identifier/


and instructs the assembler to use the COMMON location counter until otherwise directed. The physical memory locations of statements following a COMMON statement are determined at link time.
 

2.3.5. The PUBLIC Directive

The PUBLIC statement takes the form
 

PUBLIC label{,label, ... ,label}


where each label is defined in the program. Labels appearing in a PUBLIC statement may be referred to by other programs which are linked using LINK-80.
 

2.3.6. The EXTRN Directive

The form of the EXTRN statement is
 

EXTRN label{,label, ... ,label}


The labels appearing in an EXTRN statement may be referenced but must not be defined in the program being assembled. They refer to labels in other programs which have been declared PUBLIC.
 

2.3.7. The NAME Directive

The form of the NAME statement is
 

NAME 'text string'


The NAME statement is optional. It is used to specify the name of the relocatable object module produced by RMAC. If no NAME statement appears, the filename of the source file is used as the name of the object module.


Next     Contents     Previous     Back to RMAC Page