100% found this document useful (1 vote)
57 views

Assemblers: Role of Assembler

The document discusses the role and functions of assemblers. Assemblers translate mnemonic operation codes to machine language equivalents and assign addresses to symbolic labels. They are machine dependent due to different instruction formats. Assemblers perform two passes to resolve forward references. They use data structures like an operation code table, symbol table, and location counter. The assembler design considers both machine dependent and independent features.

Uploaded by

Clarita Pinto
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
57 views

Assemblers: Role of Assembler

The document discusses the role and functions of assemblers. Assemblers translate mnemonic operation codes to machine language equivalents and assign addresses to symbolic labels. They are machine dependent due to different instruction formats. Assemblers perform two passes to resolve forward references. They use data structures like an operation code table, symbol table, and location counter. The assembler design considers both machine dependent and independent features.

Uploaded by

Clarita Pinto
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

ASSEMBLERS: Role of Assembler

Introduction to Assemblers Fundamental functions o translating mnemonic operation codes to their machine language equivalents o assigning machine addresses to symbolic labels Machine dependency o different machine instruction formats and codes Example Program (Fig. 2.1) BASIC ASSEMBLER FUNCTIONS: The line numbers are reference only. Index addressing is indicated with modifier X following the operand. Basic assembler directives o START specifies name and starting address of the program. o END - indicates the end of the source program and specify the first executable instruction in the program. o BYTE generate character or hexadecimal constant, occupying as many bytes as needed to represent the constant o WORD generate one word integer constant. o RESB reserve the indicated number of bytes for a data area o RESW reserve the indicated number of words for a data area. Purpose o reads records from input device (code F1) o copies them to output device (code 05) o at the end of the file, writes EOF on the output device, then RSUB to the operating system Data transfer (RD, WD) o a buffer is used to store record

o buffering is necessary for different I/O rates o the end of each record is marked with a null character (0016) o the end of the file is indicated by a zero-length record Subroutines (JSUB, RSUB) o RDREC, WRREC o save link register first before nested jump Object Program Header Col. 1 H Col. 2~7 Program name Col. 8~13 Starting address (hex) Col. 14-19 Length of object program in bytes (hex) Text Col.1 T Col.2~7 Starting address in this record (hex) Col. 8~9 Length of object code in this record in bytes (hex) Col. 10~69Object code (69-10+1)/6=10 instructions End Col.1 E Col.2~7 Address of first executable instruction (hex) (END program_name) H COPY 001000 00107A T 001000 1E 141033 482039 001036 281030 301015 482061 ... T 00101E 15 0C1036 482061 081044 4C0000 454F46 000003 000000 T 002039 1E 041030 001030 E0205D 30203F D8205D 281030 T 002057 1C 101036 4C0000 F1 001000 041030 E02079 302064 T 002073 07 382064 4C0000 05 E 001000 Figure 2.1 (Pseudo code) Assemblers functions Convert mnemonic operation codes to their machine language equivalents Convert symbolic operands to their equivalent machine addresses Build the machine instructions in the proper format Convert the data constants to internal machine representations Write the object program and the assembly listing Example of Instruction Assemble

Difficulties: Forward Reference Forward reference: reference to a label that is defined later in the program. Loc 1000 1003 1012 1033 Label FIRST CLOOP RETADR Operator STL JSUB J RESW Operand RETADR RDREC CLOOP 1

Two Pass Assembler Pass 1 o Assign addresses to all statements in the program o Save the values assigned to all labels for use in Pass 2 o Perform some processing of assembler directives Pass 2 o Assemble instructions o Generate data values defined by BYTE, WORD o Perform processing of assembler directives not done in Pass 1 o Write the object program and the assembly listing

Data Structures Operation Code Table (OPTAB) Symbol Table (SYMTAB) Location Counter(LOCCTR) OPTAB (operation code table) Content o menmonic, machine code (instruction format, length) etc. Characteristic o static table Implementation o array or hash table, easy for search SYMTAB (symbol table) Content o label name, value, flag, (type, length) etc. Characteristic o dynamic table (insert, delete, search) Implementation o hash table, non-random keys, hashing function

COPY FIRST CLOOP ENDFIL EOF THREE ZERO RETADR LENGTH BUFFER RDREC

1000 1000 1003 1015 1024 102D 1030 1033 1036 1039 2039

Assembler Design Machine Dependent Assembler Features o instruction formats and addressing modes o program relocation Machine Independent Assembler Features o literals o symbol-defining statements o expressions o program blocks o control sections and program linking

You might also like