Advanced Assembler Directives
- The syntax of this directive is
ORIGIN <address specification>
where <address specification> is an <operand specification> or <constant>.
- This directive instructs the assembler to put the address given by <address specification> in the location counter.
- The ORIGIN statement is useful when the target program does not consist of a single contiguous area of memory.
- The ability to use an <operand specification> in the ORIGIN statement provides the ability to change the address in the location counter in a relative rather than absolute manner.
- The EQU directive has the syntax
<symbol> EQU <address specification>
where <address specification> is either a <constant> or <symbolic name> ±
- The EQU statement simply associates the name <symbol> with the address specified by <address specification>. However, the address in the location counter is not affected.
- The LT0RG directive, which stands for ‘origin for literals’, allows a programmer to specify where literals should be placed.
- The assembler uses the following scheme for placement of literals: When the use of a literal is seen in a statement, the assembler enters it into a literal pool unless a matching literal already exists in the pool.
- At every LTORG statement, as also at the END statement, the assembler allocates memory to the literals of the literal pool and clears the literal pool.
- This way, a literal pool would contain all literals used in the program since the start of the program or since the previous LTORG statement.
- Thus, all references to literals are forward references by definition.
- If a program does not use an LTORG statement, the assembler would enter all literals used in the program into a single pool and allocate memory to them when it encounters the END statement.
ORIGIN [ Advanced Assembler Directives ]
- Statement number 18 of the above program viz. ORIGIN LOOP + 2 puts the address 204 in the location counter because symbol LOOP is associated with the address 202. The next statement MULT CREG, B gave the address 204.
- On encountering the statement BACK EQU LOOP, the assembler associates the symbol BACK with the address of LOOP i.e. with 202.
LTORG [ Advanced Assembler Directives ]
- In assembly program, the literals =’5′ and =’1′ added to the literal pool in Statements 2 and 6, respectively. The first LTORG statement (Statement 13) allocates the addresses 211 and 212 to the values ‘5’ and ‘1’. A new literal pool now started. The value T is put into this pool in Statement 15. This value allocated the address 219 while processing the END statement. The literal =’1′ used in Statement 15 therefore refers to location 219 of the second pool of literals rather than location 212 of the first pool.