Presentation is loading. Please wait.

Presentation is loading. Please wait.

G.Umamaheswari Lect/IT R.M.D.EC system software

Similar presentations


Presentation on theme: "G.Umamaheswari Lect/IT R.M.D.EC system software"— Presentation transcript:

1 G.Umamaheswari Lect/IT R.M.D.EC system software
Assembler Assembler Definition Assembler functions Assembler Design Algorithms for two passes Example Program with object code Machine dependent Features Instruction formats and Addressing modes PC –relative and BASE relative G.Umamaheswari Lect/IT R.M.D.EC system software

2 G.Umamaheswari Lect/IT R.M.D.EC system software
Assembler Design Machine Dependent Features Instruction formats and addressing modes Program relocation Machine independent features Literals Symbol defining statements Expressions Program blocks Control Sections and program linking G.Umamaheswari Lect/IT R.M.D.EC system software

3 G.Umamaheswari Lect/IT R.M.D.EC system software
Assembler Design Instruction Formats: Single Byte Two Byte: (Reg –Reg ) Format 3 type – (12-bit displacement value) Format 4 type – (20-bit displacement value) G.Umamaheswari Lect/IT R.M.D.EC system software

4 PC-Relative Addressing Modes
FIRST STL RETADR 17202D (14) (02D) 16 displacement= RETADR - PC = 30-3 = 2D J CLOOP 3F2FEC (3C) (FEC) 16 displacement= CLOOP-PC= 6 - 1A= -14= FEC G.Umamaheswari Lect/IT R.M.D.EC system software

5 Immediate Address Translation
Immediate addressing LDA # ( 00 ) ( 003 ) 16 C LDT # ( 74 ) ( ) 16 G.Umamaheswari Lect/IT R.M.D.EC system software

6 Immediate Address Translation (Cont.)
Immediate addressing LDB #LENGTH 69202D ( 68) ( 02D ) 16 ( 68) ( 033) the immediate operand is the symbol LENGTH the address of this symbol LENGTH is loaded into register B LENGTH=0033=PC + displacement= D if immediate mode is specified, the target address becomes the operand G.Umamaheswari Lect/IT R.M.D.EC system software

7 Indirect Address Translation
Indirect addressing target addressing is computed as usual (PC-relative or BASE-relative) only the n bit is set to 1 A J @RETADR : : RETADR RESW 1 G.Umamaheswari Lect/IT R.M.D.EC system software

8 G.Umamaheswari Lect/IT R.M.D.EC system software
Program Relocation Why Relocation It is desirable to load and run several programs at the same time The system must be able to load programs into memory wherever there is space The exact starting address of the program is not known until load time G.Umamaheswari Lect/IT R.M.D.EC system software

9 G.Umamaheswari Lect/IT R.M.D.EC system software

10 G.Umamaheswari Lect/IT R.M.D.EC system software
Absolute Program Program with starting address specified at assembly time The address may be invalid if the program is loaded into somewhere else. Example: B LDA THREE D Reload the program starting at 3000 B LDA THREE D G.Umamaheswari Lect/IT R.M.D.EC system software

11 G.Umamaheswari Lect/IT R.M.D.EC system software
Program relocation The only parts of the program that require modification at load time are those that specify direct addresses The rest of the instructions need not be modified Not a memory address (immediate addressing) PC-relative, Base-relative From the object program, it is not possible to Distinguish the address and constant The assembler must keep some information to tell the loader about this relocated address. The object program that contains the modification record is called a relocatable program G.Umamaheswari Lect/IT R.M.D.EC system software

12 Solving Relocation Problem
For an address label, its address is assigned relative to the start of the program (START 0) Produce a Modification record to store the starting location and the length of the address field to be modified. The command for the loader must also be a part of the object program G.Umamaheswari Lect/IT R.M.D.EC system software

13 G.Umamaheswari Lect/IT R.M.D.EC system software
Modification Record One modification record for each address to be modified The length is stored in half-bytes (4 bits) The starting location is the location of the byte containing the leftmost bits of the address field to be modified. If the field contains an odd number of half-bytes, the starting location begins in the middle of the first byte. G.Umamaheswari Lect/IT R.M.D.EC system software

14 G.Umamaheswari Lect/IT R.M.D.EC system software
Modification Record Modification Record Col. 1 M Col. 2-7 Starting location of the address field to be modified, relative to the beginning of the program. Col. 8-9 Length of the address field to be modified, in half-bytes (Hex) G.Umamaheswari Lect/IT R.M.D.EC system software

15 G.Umamaheswari Lect/IT R.M.D.EC system software
Object Program G.Umamaheswari Lect/IT R.M.D.EC system software

16 Machine Dependent Features-Literals
A literal is identified with the prefix =, followed by a specification of the literal value Examples: G.Umamaheswari Lect/IT R.M.D.EC system software

17 Machine Dependent Features-Literals
A literal is identified with the prefix =, followed by a specification of the literal value Examples: G.Umamaheswari Lect/IT R.M.D.EC system software

18 Literals vs. Immediate Operands
The assembler generates the specified value as a constant at some other memory location Immediate Operands The operand value is assembled as part of the machine instruction LDA # G.Umamaheswari Lect/IT R.M.D.EC system software

19 G.Umamaheswari Lect/IT R.M.D.EC system software
Literals Pool Normally literals are placed into a pool at the end of the program (after the END statement) In some cases, it is desirable to place literals into a pool at some other location in the object program Assembler directive LTORG When the assembler encounters a LTORG statement, it generates a literal pool (containing all literal operands used since previous LTORG) Reason: keep the literal operand close to the instruction Otherwise PC- relative addressing may not be allowed G.Umamaheswari Lect/IT R.M.D.EC system software

20 G.Umamaheswari Lect/IT R.M.D.EC system software
Literals Pool Normally literals are placed into a pool at the end of the program (after the END statement) In some cases, it is desirable to place literals into a pool at some other location in the object program Assembler directive LTORG When the assembler encounters a LTORG statement, it generates a literal pool (containing all literal operands used since previous LTORG) Reason: keep the literal operand close to the instruction Otherwise PC- relative addressing may not be allowed G.Umamaheswari Lect/IT R.M.D.EC system software

21 G.Umamaheswari Lect/IT R.M.D.EC system software
Literal Table LITTAB Content Literal name Operand value and length Address LITTAB is often organized as a hash table, using the literal name or value as the key G.Umamaheswari Lect/IT R.M.D.EC system software

22 Literal Implementation
Pass 1 Build LITTAB with literal name, operand value and length, leaving the address unassigned When LTORG or END statement is encountered, assign an address to each literal not yet assigned an address The location counter is updated to reflect the number of bytes occupied by each literal G.Umamaheswari Lect/IT R.M.D.EC system software

23 Literal Implementation
Pass 2 Search LITTAB for each literal operand encountered Generate data values using BYTE or WORD statements Generate Modification record for literals that represent an address in the program G.Umamaheswari Lect/IT R.M.D.EC system software


Download ppt "G.Umamaheswari Lect/IT R.M.D.EC system software"

Similar presentations


Ads by Google