Vous êtes sur la page 1sur 26

System Software

UNIT 2 ASSEMBLERS
2.1 MACHINE INDEPENDENT ASSEMBLER FEATURES:
2.1.1 LITERALS:
Constant operand can be specified as a part of the instruction that uses it, instead of using a label which is defined as constant else where. Such an operand is called a literal because the value is stated literally in the instruction. A literal is identified with the prefix =, which followed by a specification of the literal value. Ex: LDA =C EOF The above example is a 3 byte operand whose value is character string EOF. It loads the end of files value. TD =X05 The above example is a 1 byte literal with hexadecimal value 05. Difference between a literal and immediate operand: With immediate addressing, the operand value is assembled as part of the machine instruction. Ex: 55 0020 LDA #3 010003 With a literal, the assembler generates the specified value as a constant at some other memory location. The address of this generated constant is used as target address for machine instructions. Ex: 45 001A ENDFIL LDA =CEOF 032010 Literal Pools: All of the literal operands used in a program are gathered together into one or more literal pools. Normally literals are placed into a pool at the end of the program. In some cases, it is desirable to place literals into a pool at some other location in the object program. For this purpose, the assembler directive LTORG is used. 1. When the assembler encounters a LTORG statement, it creates a literal pool that contains all of the literal operands used since the previous LTORG. 2. This literal pool is placed in the object program at the location where the LTORG directive was encountered. 3. Literal placed in a pool by LTORG will not be repeated in the pool at the end of the program. LTORG Example: 1
Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

System Software

If we do not use a LTORG on line 93, the literal =CEOF will be placed at the end of the program. This operand will then begin at address 1073 and be too far away from the instruction that uses it. PC-relative addressing mode cannot be used. LTORG thus is used when we want to keep the literal operands close to the instruction that uses it. Duplicate Literals: Duplicate literals- the same literal used in more than once place in the program. For duplicate literals, we should store only one copy of the specified data value to save space. Most assembler can recognize duplicate literals. Ex: There are two uses of =X05 on lines 215 and 230 respectively. However, just one copy is generated on line 1076. How to recognize the duplicate literals: 1. The easiest method is to recognize duplicate literals is by comparison of the character strings defining them. Same literal name with different value. Ex: =X05 2. Compare the generated data value. Better, but will increase the complexity of the assembler. Ex: =C EOF and =X 454F46 The problem with string-defining literals: We should be careful about the literal whose value depends on their locations in the program. Ex: (* usually denotes the current value of the location counter) BASE * LDB =* If * appears on line 13, it would specify 0003. If it appears on line 55, it would specify an operand with value 0020. Literal Table: The basic data structure that assembler handles literal operands is literal table LITTAB. Contents of the literal table are:1. Literal name 2. Operand value and length 3. Address assigned to the operand when it is placed in a literal pool.

Ex: NAME OPERAND VALUE

LENGTH

ADDRESS 2

Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

System Software

=X05

05

1076

LITTAB is often recognized as a hash table, using literal name or value as the key. Implementation of literal: PASS 1: 1. Build LITTAB with literal name, operand value and length, leaving the address unassigned. 2. When LTORG statement is encountered, assign an address to each literal not yet assigned an address. 3. The location counter is updated to reflect the number of bytes occupied by each literal. PASS 2: 1. 2. 3. Search LITTAB for each literal operand encountered. Generate data values using BYTE or WORD statements. Generate Modification record for literal that represent an address in the program.

2.1.2 SYMBOL-DEFINING STATEMENTS


The user defined symbols in assembler language programs appear as labels on instructions or data areas. The value of such a label is the address assigned to the statement on which it appears. Most assemblers provide an assembler directive that allows the user to define symbol and specify their values. Commonly used ones are:a. EQU- Equate. b. ORG- Origin EQU: The general format of Equate statement is Symbol EQU value

Symbol: It can be any name to which the value is assigned. This symbol is entered into SYMTAB and values specified is assigned to it. Value: It may be a constant and previously defined symbols. EQU is used to establish symbolic names that can be used for improved readability in place of numeric values. Ex:1. +LDT #4096 can be changed to MAXLEN EQU 4096 +LDT #MAXLEN 3
Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

System Software

When the assembler encounters the EQU statement, it enters MAXLEN into SYMTAB(with value 4096) During assembly of the LDT instruction, the assembler searches SYMTAB for the symbol MAXLEN, using its value as the operand in the instruction. Ex:2 A X L EQU 0 EQU 1 EQU 2

Here, the register A, X, and L are assigned as 0,1 and 2. These values are entered in the SYMTAB. After assigning these values we can use 0,1 and 2 in place of the register A,X and L. Ex: RMO A, X can be written as RMO 0,1 ORG: Initialize location counter to the specified value. The general format of ORG statement is ORG value The value is a constant or an expression, when the assembler encounters ORG the assembler initializes the LC to the specified value. The ORG statement can be given without any value attached to it. Whenever there is such a statement the LC will be set back to its previous LC value. Ex: LC Value 100 1100 NUMB RESB 1000H ; present LC=100 ORG NUMB ; before execution LC=1100 ; after execution LC=100 ORG ; LC is again given the value 100

Note: All symbols used on the right hand side of the statement for EQU and ORG must have been defined previously in the program. Ex: A RESW B EQU ORG 1 A B

If they are not defined then an error is displayed. Ex: B EQU A ; Undefined error A RESW 1 4
Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

System Software

Similarly ORG EQU RESW RESB A ;Undefined error C ; Undefined error 10 1

B C A

2.1.3 EXPRESSIONS
The assembler calculates the expressions and produces a single operand address or value. The expression consists of: a. Operator: +, -, *, / (division is usually defined to produce an integer result) b. Individual terms: Constants, user-defined symbols or special terms. Ex: MAXLEN EQU BUFFEND-BUFFER

Expressions can be classified as absolute expressions or relative expressions depending upon the type of value they produce. Absolute expressions: Its value is independent of program location. Ex: a constant An expression that contains only absolute terms or An expression that contains relative terms but the relative terms occur in pairs and the terms in each pair have opposite signs. (/ and * operations are not allowed) Ex: MAXLEN EQU BUFEND-BUFFER Relative expressions: Its value is relative to the beginning of the object program, and thus its value is dependent of program location. Ex: labels or reference to location counter(*) If both operands are relative terms then it is called relative expression. Ex: ALPHA EQU RETADR To determine the type of an expression, we must keep track of the types of all symbols defined in the program. For this purpose we need a flag in the symbol table to indicate type of value (absolute ore relative) in addition to the value itself. SYMTAB SYMBOL RETADR BUFFER BUFEND TYPE R R R VALUE 0030 0036 1036 5
Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

System Software

MAXLEN Illegal expressions:

1000

BUFEND+BUFFER 100-BUFFER 3*BUFFER These expressions represent neither absolute nor location within the program. Therefore, these expression are considered illegal.

2.1.4 PROGRAM BLOCKS


Segments of code that are rearranged within a single object program unit is called program block. Segments of code that are translated into independent object program units is called control sections. The assembler directive USE indicates which portion of the source program belongs to the various blocks. Each program block may actually contain several separate segments of the source program. The assembler will rearrange these segments together the piece of each block. These blocks will then be assigned addresses in the object program with the blocks appearing in the same order in which they were first begun in the source program. Syntax: USE <block name> Fig 2.11 and 2.12 shows the example of a program with multiple program blocks and with object code. Fig 2.11

6
Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

System Software

7
Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

System Software

Fig 2.12

8
Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

System Software

For this fig refer text book In the above program three blocks are used. 1. First(unnamed)(default) 2. CDATA 3. CBLKS First(unnamed)(default) block: It contains the executable instructions of the program. It is assigned to 0. The second (named CDATA) block: It contains all data areas that are a few words or less in length. It is assigned to 1. The third (named CBLKS) block: It contains all data areas that consist of larger blocks of memories. It is assigned to 2. During PASS 1: 1. Maintains a separate location counter for each program block. 2. The location counter for a block is initialized to 0 when the block is first begun. 3. The current value of this location counter is saved when switching to another block, and the saved value is restarted when resuming a previous block. 4. During PASS 1, each label is assigned an address that is relative to the beginning of the block that contains it. 5. After PASS 1, the latest value of the location counter for each block indicates the length of that block. 9
Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

System Software

6.

The assembler then can assign to each block a starting address in the object program.

During PASS 2: 1. When generating object code, the assembler needs the address for each symbol relative to the start of object program. 2. This can be easily done by adding the location of the symbol to the assigned block starting address. At the end of PASS 1 the assembler constructs table that contains the starting address and lengths for all blocks. BLOCKNAME Default CDATA CBLKS BLOCKNO 0 1 2 ADDRESS 0000 0066 0071 LENGTH 0066 000B 1000

Ex: 20

0006

LDA

LENGTH

032060

1. The SYMTAB shows that LENGTH has a relative address 0003 within program block1. 2. The starting address for CDATA is 0066. 3. Thus the desired target address is 0066+0003=0069 4. Because this instruction is assembled using program counter-relative addressing and PC will be 0009 when the instruction is executed, the displacement is 0069-0009=60. Fig 2.13 Object program corresponding to fig 2.11

10
Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

System Software

Fig 2.14 program blocks from fig 2.11 traced through the assembly and loading processes.

Advantages: 1. Because the target buffer area is moved to the end of the object program we no longer need to use formal instructions. 2. For the same reason use of the base register is no longer necessary; the LDB and BASE have been detected. 3. Code sharing and data protection can be more easily achieved.

11
Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

System Software

2.1.5 CONTROL SECTIONS AND PROGRAM LINKING:


A control section is a part of the program that maintains its identity after assembly. Each control section can independently be assembled loaded and manipulated separately. They may be considered as an independent program that can perform any specific operation. There are set of control sections that can be grouped to perform the required operation. It is necessary to provide some means of linking control section together. Instructions in one control section may need to refer to instruction or data located in another control section therefore linking is necessary because the control sections are independently loaded and relocated. CSECT: CSECT is an assembler directive it indicates the new sector in a program. The assembler handles the program blocks separately when it comes across CSECT. The assembler establishes a separate location counter for each control section just as it does for program blocks. Two assembler directive to identify the reference 1. 2. EXTDEF:(external definition) EXTREF:(external reference)

EXTDEF: Symbols that are defined in this control section and may be used by other sections. Ex: EXTDEF BUFFER, BUFEND, LENGTH EXTREF: Symbols that are used in this control section and are defined elsewhere. Ex: EXTREF RDREC, WRREC

Fig 2.15 Illustration of control sections and program linking

12
Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

System Software

Code involving external reference (1) 15 0003 CLOOP +JSUB RDREC 4B100000

The operand(RDREC) is named in the EXTREF statement, therefore this is an external reference. 13
Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

System Software

Because the assembler has no idea where the control section containing RDREC will be loaded, it cannot assemble the address for this instruction. Therefore, it inserts an address of zero. Code involving external reference (2) 160 0017 +STCH BUFFER, X 57900000

This instruction makes an external reference to BUFFER. The instruction is thus assembled using extended format with an address of zero. The x bit is set to 1 to indicate indexed addressing.

Code involving external reference (3) 190 0028 MAXLEN WORD BUFEND-BUFFER 000000

The value of the data word to be generated is specified by an expression involving two external references. As such, the assembler stores this value as zero. When the program is loaded, the loader will add to this data area the address of BUFEND and subtract from it the address of BUFFER, which then results in the desired value. Fig 2.16 Program from fig 2.15 with object code (Refer text book) We need two new record types in the object program and a change in the previous defined modification record type. Define record: Give information about external symbols that are defined in this control section. Col 1: D Col 2-7: Name of external symbol defined in this control section. Col 8-13: Relative address of symbol within this control section. Col 14-73: Repeat information in Col 2-13 for other external symbols. Refer record: List symbols that are used as external references by this control section. Col 1: R Col 2-7: Name of the external symbol referred to in this control section. Col 8-73: Names of other external reference symbols. 14
Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

System Software

The other information needed for program linking is added to the modification record type. The new format is as follows: Revised modification record: Col 1: M Col 2-7: Starting address of the field to be modified relative to the beginning of the control section. Col 8-9: Length of the field to be modified in half bytes. Col 10: Modification flag (+ or -) Col 11-16: External symbol whose value is to be added to or subtracted from the indicated field.

Fig 2.17 object program corresponding to fig 2.15

15
Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

System Software

2.2 ASSEMBLER DESIGN OPTIONS:


2.2.1 ONE PASS ASSEMBLER:
One pass assembler gets the object code as the assembler scans through the source program only once. The main problem is about forward reference. Eliminating forward reference to data items can be easily done. Simply ask the programmer to define variables before using them. 16
Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

System Software

However, eliminating forward reference to labels on instructions cannot be easily done. Sometimes your program needs a forward jump. Asking your program to use only backward jumps is too restrictive. There are two main types of one pass assembler 1. Load and go assembler: The assembler generate object code in memory for immediate execution. 2. Generation of object code assembler: The code is generated in a file for later execution. Characteristics of load and go assembler:1. Useful for program development and testing. 2. Good for computing center where most students reassemble their programs each time. 3. Can save time for scanning the source code again. 4. Avoids the overhead of writing the object program out and reading it back into memory for execution. 5. However, one pass also avoids the overhead of an additional pass over the source program. 6. For a load and go assembler, the actual address must be known at assembly time, we can use an absolute program. Fig 2.18 Sample program for a one pass assembler

17
Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

System Software

Fig 2.19 (a) Object code in memory and symbol table entries for the program in fig 2.18 after scanning line 40

Fig 2.19 (b) object code in memory and symbol table entries for the program in fig 2.18 after scanning line 160

18
Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

System Software

The first forward reference occurred on line 15. Since the operand (RDREC) was not yet defined, the instruction was assembled with no value assigned as the operand address (denoted by ) RDREC was then entered into SYMTAB as an undefined symbol (indicated by *); the address of the operand field (2013) of the instruction was inserted in a list associated with RDREC. A similar process was followed with the instructions on lines 30 and 35. Now consider fig 2.19 (b) which corresponds to the situation after scanning line 160. By this time, some of the forward references ( ENDFIL, line 45 and RDREC line 125) have been resolved, while others (EXIT, line 175 and WRREC, line 210) have been added. When the symbol ENDFIL was defined, the assembler placed its value in the SYMTAB entry; it then inserted this value into the instruction operand field (at address 201C) as directed by the forward reference list. From this point on, any references to ENDFIL would not be forward references and would not be entered into a list. At the end of the program, any SYMTAB entries that are still marked with * indicate undefined symbols. These should be flagged by the assembler as errors. One pass assemblers that produce object programs follow a slightly different procedure from that previously described. 1. Forward references are entered into lists as before. 19
Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

System Software

2. When the definition of a symbol is encountered, instructions that made forward references to that symbol may no longer available in memory for modification. In general, they will already have been written out as part of a text record in the object program. In this case, the assembler must generate another text record with the correct operand address. 3. When the program is loaded, this address will be inserted into the instruction by the action of the loader. Fig 2.20 object program from one pass assembler for program in fig 2.18(Refer text book) The 2nd text record contains the object code generated from lines 10 through 40 in fig 2.18. The operand addresses for the instructions on lines 15, 30, and 35 have been generated as 0000. When ENDFIL on line 45 is encountered, the assembler generates the 3rd text record. This record specifies that the value 2024 ( the address of ENDFIL) is to be loaded at location 201C (the operand address field of JEQ on line 30) When the program is loaded, the value 2024 will replace the 0000 previously loaded.

Forward reference in one pass assembler: For any symbol that has not yet been defined 1. It simply generates object code instructions as it scans the source program. 2. If an instruction operand is symbol that has not yet been defined, the operand address is omitted when the instruction is assembled. 3. Insert the symbol into SYMTAB, and mark this symbol undefined. 4. The address that refers to the undefined symbol is added to a list of forward references associated with the symbol table entry. 5. When the definition for a symbol is encountered, the proper address for the symbol is then inserted into any instructions previous generated according to the forward reference list. Producing Object code When external working-storage devices are not available or too slow ( for the intermediate file between the two passes) the solution as follows: 1. When definition of a symbol is encountered, the assembler must generate another text record with the correct operand address. 2. The loader is used to complete forward references that could not be handled by the assembler. 3. The object program records must be kept in their original order when they are presented to the loader.

20
Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

System Software

2.2.2 MULTI-PASS ASSEMBLER


Multi-pass assemblers are required when the EQU and ORG assembler directive has a symbol on the RHS which is forward defined. Ex: A B C EQU EQU RESW B C 1

The symbol B cant be assigned a valued when it is encounterd during pass 1 because C has not yet been defined. As a result, A cant be evaluated during pass 2. Note that any assembler that makes only 2 sequential passes over the such program cant resolve such a sequence of definitions. The general solution is a multi pass that can make as many passes as are needed to process the definitions of symbols. Implementation: For a forward reference in symbol definition, we store in the SYMTAB. This table also indicates which symbols are dependent on the value of other to facilitate symbol evaluation. Symbol table consists of the following columns. 1. LABEL 2. DEFVAR 3. VALUE/EXPRESSION 4. DEPLABLE LABEL: It is the left hand side symbol encountered on each line. DEFVAR: It tells the number of variable in the value/expression that are not defined. VALUE/EXPRESSION: It is the field which loads the right hand side of the definition. DEPLABLE: It is the field which has the name of a label to which this label field required. Ex: 1 2 3 NUMB MAXLEN PREVB EQU EQU EQU MAXLEN/2 BEND-B B-1 21
Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

System Software

4 5

B BEND

RESB EQU DEFVAR #1

1034H * EXP/VALUE MAXLEN/2 DEPLABEL --------------

LABEL NUMB

After scanning through the line 1 the assembler update the symbol table. It means that the LHS label is NUMB. The RHS expression is MAXLEN/2, therefore there is only one variable #1 which is not defined in expression. The variable NUMB is not dependent on any other variable. Same way after scanning line 2 LABEL NUMB MAXLEN DEFVAR #1 #2 EXP/VALUE MAXLEN/2 BEND-B DEPLABEL -------------NUMB

After scanning line 3 LABEL NUMB MAXLEN PREVB DEFVAR #1 #2 #1 EXP/VALUE MAXLEN/2 BEND-B B-1 DEPLABEL -------------NUMB --------------

After scanning line 4

LABEL NUMB MAXLEN PREVB B

DEFVAR #1 #2 #1 #0

EXP/VALUE MAXLEN/2 BEND-B B-1 1034

DEPLABEL -------------NUMB -------------MAXLEN->PREVB

22
Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

System Software

The assembler examines the list of symbols that are dependent on B. The symbol table entry for the first symbol in this list(MAXLEN) shows that it depends on currently defined symbols. Therefore MAXLEN cannot be evaluated immediately instead, the #2 is changed to #1 to show only one undefined symbols and we can evaluate PREVB. LABEL NUMB MAXLEN PREVB B DEFVAR #1 #1 #0 #0 EXP/VALUE MAXLEN/2 BEND-1034 1033 1034 DEPLABEL -------------NUMB ---------------------------

In the line 5 BEND is defined the value is entered into the symbol table. The list associated with BEND then directs the assembler to evaluate MAXLEN and entering a value for MAXLEN causing the evaluation of the symbol in its list. If any symbol undefined at the end of the program, the assembler would flag an error. LABEL NUMB MAXLEN PREVB B BEND DEFVAR #1 #1 #0 #0 #0 EXP/VALUE MAXLEN/2 BEND-1034 1033 1034 2034 DEPLABEL -------------NUMB --------------------------MAXLEN

The symbol MAXLEN is depending upon BEND so we can solve MAXLEN.

LABEL NUMB MAXLEN PREVB B

DEFVAR #1 #0 #0 #0

EXP/VALUE MAXLEN/2 2034-1034 1033 1034

DEPLABEL -------------NUMB --------------------------23

Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

System Software

BEND

#0

2034

-------------

The symbol NUMB is depending upon MAXLEN so we can solve NUMB. LABEL NUMB MAXLEN PREVB B BEND DEFVAR #0 #0 #0 #0 #0 EXP/VALUE 1000/2=500 1000 1033 1034 2034 DEPLABEL -----------------------------------------------------------------

2.3 IMPLEMENTATION EXAMPLES-MASM ASSEMBLER


An MASM assembler language program is written as a collection of segments. In x86 system, memory is a collection of segments. Each segment belongs to a particular class, corresponding to its contents. The commonly used classes are: 1. 2. 3. 4. CODE: It holds the executable instructions. DATA: It holds the data declarations of program. CONST: It holds the constant values. STACK: It holds the stack specification.

During program execution, segments are addressed via the x86 segment registers. Register CS is used to address code segment and register SS addressed using stack segments. These segment registers are automatically set by the system loader when a program is loaded for execution. Data segments are normally addressed using DS, ES, FS or GS. The segment register to be used can be specified by the programmer. The assembler assumes that all references to data segments use register DS by default. The assembler directive can change this assumption by using directive, i.e. ASSUME ES: DATASEG2 This tells the assembler to assume that register ES indicates the segment DATASEG2. 24
Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

System Software

Registers DS, ES, FS and GS must be loaded by the program before they can be used to address data segments. For example, MOV AX, MOV ES, DATASEG2 AX

Would set ES to indicate the data segment DATASEG2. Jump instructions are assembled in two different ways. They are: 1. A near jump 2. A far jump A near jump is a jump to a target in same code segment. A far jump is a jump to a target in a different code segment Near jump: A near jump is assembled using current code segment registers CS and a far jump must be assembled using a different segment registers which is specified in an instruction prefix. If it is a far jump, programmer must indicate it using JMP FARPTR TARGET

By default, MASM assumes that all forward references in jump as near jump. For a near jump instruction, size is 2 or 3 bytes and for far jump instruction, size is 5 bytes. So, length of assembled instructions depends on operand here. There are many more instructions where length is depending on operands. Far jump: The far jump is similar to extended format of SIC/XE machine. The SEGMENT directive is similar to USE of SIC/XE. Here also, all segments parts are assembled together to generate one object units that is similar to program blocks of SIC/XE. The MASM has PUBLIC and EXTRN directives which are similar to EXTDEF and EXTREF of SIC/XE, to communicate between separate object modules. These are handled by linker. MASM also produces an instruction timing list that shows clock cycles required to execute each instruction.

25
Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

System Software

QUESTIONS:
1. Differentiate between literal and immediate operand with an example. (4M) 2. Describe how the assembler handles literal operands. (6M) 3. Write suitable example use of LTORG assembler directive. Explain with an example. 4. Define literal, duplicate literals and literal pools. 5. Explain symbol defining statements with example. 6. Explain absolute and relative expressions. How these are processed by an assembler? (6M) 7. What are program blocks? With suitable example explain how program blocks are processed by assembler pass 1 and pass 2. 8. How program blocks are handled by assemblers? 9. Define control section. How does control section differ from the program blocks? Explain with an example. (10M) 10. What are control sections? How are they processed? (8M) 11. Give the format for the following record necessary to obtain object code. i. Header record ii. Text record iii. Define record iv. Refer record v. Modification record(revised) vi. End record 12. Discuss different design options of assembler. (10 M) 13. List the characteristics of load and go assembler. 14. Explain load and go assembler with an example. (8M) 15. What is the difficulty encountered in implementing one pass assembler and how is it solved. (6M) 16. With an example, explain the multi pass assembler. (5M) 17. Explain how multi pass assembler handles the following forward reference. 1 2 3 4 5 HALFSZ MAXLEN PREVBT BUFFER BUFEND EQU EQU EQU RESB EQU MAXLEN/2 BUFEND-BUFFER BUFFER-1 4096 *

Assume that, when assembler goes to line 4, location counter contains 1.34(H) (10M) 18. Compare a two pass assembler with a one pass assembler. How forward References are handled in one pass assemblers? (10M) 19. Write a note on MASM assembler. (6M) 26
Prepared by: Sandeep B L, Asst. Prof. / Dept. of ISE / MSRIT, Bangalore

Vous aimerez peut-être aussi