Presentation is loading. Please wait.

Presentation is loading. Please wait.

Optional Assembler Features 2

Similar presentations


Presentation on theme: "Optional Assembler Features 2"— Presentation transcript:

1 Optional Assembler Features 2
CSCI/CMPE 3334 David Egle

2 More features Allow for more flexible handling of the source and object programs the generated machine code appears in a different order in the object program than in the source the source code may be in independent sections, resulting in independent object programs these maintain their identity and are handled by the linker Program block segments of code that are rearranged in memory Control section segments of code that are translated into independent object programs

3 Program blocks Separate in source; contiguous in memory
Primary objective allow the programmer to keep data sections close to the code where it is referenced have the data in one place in memory Need the programmer to specify which sections should be together in the object

4 The USE directive At beginning of program statements assumed to be part of the unnamed (default) block If no USE statement is included, entire program belongs to this single block The USE statement signals the beginning of a block with a specific name source statements are associated with this block until another USE statement is encountered USE statement may also indicate a continuation of a previously begun block

5 Handling program blocks
During Pass 1 a separate location counter is maintained for each program block when new block is started, location counter is set to 0 current value is saved with switching to another block value is restored when a block is resumed labels are assigned addresses relative to start of current block; block name/number is included in symbol table at end, value of location counter is size of block assembler can assign to each block a starting address in object program

6 Handling program blocks 2
Pass 2 address of symbol relative to start of block is found and added to address of block this is then used in generating the object code See Figure 2.11 and 2.12 (p 79 and 81)

7 Blocks table The program blocks table is constructed during first pass
When a new USE directive is encountered, the current location counter is saved in the Length If the new block is not in the table, it is added At the end of assembly, the address field is determined by adding the address and length of the previous block Block name Block number Address Length (default) 0000 0066 CDATA 1 000B CBLKS 2 0071 1000

8 Program blocks pros and cons
Reduced use of extended format instructions No need to use base addressing Improves program readability Avoids Jump statements Can accomplish same thing by rearranging the source statements

9 Control sections A part of the program that maintains its identity after assembly separate assembly, loading, and manipulation think of separate functions in C++ Instructions in one control section may refer to instructions or data in another section external references Need to provide information for each external reference which will allow the loader to perform the required linking

10 Control section assembly
CSECT directive signals the start of a new section Symbols that are defined in another section must be identified as external references EXTREF directive names symbols used in this control section and are defined in another Need to specify which symbols may be accessed from other control sections EXTDEF directive names symbols defined in this control section which may be used in other sections Control section names are automatically global

11 External reference handling
The assembler cannot assemble the external reference addresses Need to use the extended instruction format (four bytes) to provide room for the actual address The assembler uses an address of 0 and passes information to the loader/linker If a symbol is defined in another section, but not identified in the EXTREF statement, an error will be generated if an attempt is made to reference it

12 Passing information to the linker
Need some additional record types in the object code To indicate symbols defined here and globally available Dname1 addr1 name2 addr2 … e.g., DBUFFER00033BUFEND001033LENGTH00002D To indicate external references (not defined here) Rname1 name2 name3 e.g., RBUFFERLENGTHBUFEND

13 Passing information to the linker 2
To allow for expressions, update the modification record Maddress +/- {external symbol} e.g, M BUFFER Note that this is a bit different than the text – but does illustrate the idea Also note that this still handles relocation, since the control section names may be used M00007+COPY

14 Handling expressions with external symbols
Earlier expression restriction all of relative terms must be paired, or all except one that has to be of positive sign Extended restriction both paired terms must be relative within the same control section The assembler cannot in general determine whether or not the expression is legal it evaluates all the terms it can The loader finishes the evaluation, and checks for errors


Download ppt "Optional Assembler Features 2"

Similar presentations


Ads by Google