Lect 4

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

‫ثزيجخ الَظى‬

)4( ‫يحبضزح‬ ‫راثعخ حبصت‬

٘
‫ أحًذ انحزة‬/‫دكتٕر‬

Assemblers ‫تابع‬
Figure 3.5 illustrates the interrelation of some of the data bases and the two passes
of the assembler.

1
Format of data bases

The third step in our design procedure is to specify the format and contents of

each of the data bases, the algorithm, data base, and formats are all interlocked.

Pass 2 requires MOT containing name, length, binary code, and format. While,

Pass 1 requires only name and length. The MOT and POT are examples of fixed

tables, the contents of these tables are not altered during the assembly process.

:ٙ‫ه‬ٚ ‫ كًب‬، instruction ‫خ نكم‬ٛ‫ت‬ٜ‫بَبد ا‬ٛ‫ عجبرح عٍ جذٔل ثّ انج‬MOT ‫جذٔل‬

Symbolic mnemonic, Instructions lengths (2 bytes, 4 bytes, or 6 bytes), binary

machine op-code, and Instruction format (they are: RR, RX, RS, SI, SS).

The op code is the key and its value is the binary op-code equivalent, which is

stored for use in generating machine code. The instruction length is stored for use

in updating the LC; the instruction format for use in forming the machine language

equivalent.

Figure 3.7 depicts a possible pseudo-op table. Each pseudo-op is listed with

an associated pointer to the assembler routine for processing the pseudo-op.

2
:‫ٍ ًْب‬ٚ‫تكٌٕ يٍ عًٕد‬ٚ ‫ْذا انجذٔل‬

(a) Pseudo-op (5 bytes characters),

(b) Physical address for each Pseudo-op,

‫تى يٍ خالنٓى عًم‬ٚ ٙ‫ٔانت‬process ‫ نهـ‬Pseudo-ops ‫ ْٕٔ ثطٕل‬،3-bytes،

:‫ ٌحتوي على البٍانات اَتٍة‬ST ‫جذول‬

(a) Symbol names,

ّ‫ انذ٘ تى دراصت‬ٙ‫ ثزَبيج األصًجه‬ٙ‫ ْٔذِ األصًبء كًب ف‬، 8-bytes ‫ٔتكٌٕ ثطٕل‬

JOHN, FOUR, FIVE, TEMP :‫ انًحبضزح انضبثقخ ْى‬ٙ‫ف‬

(b) Relative address for all symbols.

.‫ َظبو صبدس عشز‬4-bytes ‫ٔتكٌٕ ثطٕل‬

(c) Length.

.‫ َظبو صبدس عشز‬1-byte ‫ٔتكٌٕ ثطٕل‬

(d) Relocation

‫كتت ثّ حزف‬ٚٔ ،‫ أ٘ حزف ٔاحذ فقط‬:ٙ‫ حزف‬1-byte ‫ٔتكٌٕ ثطٕل‬

. Relativeٌ‫ كب‬symbol ٕ‫ ن‬R ‫كتت ثّ حزف‬ٚٔ ، absolute ٌ‫ كب‬symbol ٕ‫ ن‬A

‫ كم‬symbols ْٗ ٗ‫ انًذكٕرح ثأعه‬R ،

3
Figure 3.9 depicts a possible base table that is used by the assembler to generate

the proper base register reference in machine instructions and to compute the

correct offsets.

.base registers ‫ صطز ْٔى َفش عذد‬15 ّ‫ٕجذ ث‬ٚ ‫ ْٔذا انجذٔل‬

‫ كُظبو صبدس عشز‬3-bytes ‫كٌٕ ثطٕل‬ٚٔ ،‫ٍ فقط‬ٚ‫ ٔ ثّ عًٕد‬

)base registers( ‫حذد‬ٛ‫ ن‬Y ٔ‫ أ‬N ‫كتت ثّ حزف‬ٚٔ )1-byte( ‫ ثطٕل‬: ‫ العمود األول‬

USING ‫ انًضتخذو ٔانًحذد ثٕاصطخ‬base register ‫ نهـ‬Y ‫كتت حزف‬ٚ ‫ث‬ٛ‫انًٕجٕدح ح‬

‫ز يتبح‬ٛ‫عًم غ‬ٚٔ USING pseudo-op ‫زيحذد ثـ‬ٛ‫ ٔانغ‬، free ‫ نهـ‬N ٔ ،pseudo-op

.DROP pseudo-op ‫ثٕاصطخ‬

‫ضبعذ‬ٚ ْٕٔ ،base register ‫بد‬ٕٚ‫ نًحت‬relative address ٗ‫حتٕ٘ عه‬ٚ : ً‫ العمود الثان‬

‫ كًب‬symbol ‫ نكم‬address ‫ٕنذ‬ٚ assembler ٌ‫ث أ‬ٛ‫ ح‬،)correct address( ‫ حضبة‬ٙ‫ف‬

:ٙ‫ه‬ٚ

offset (index register number, base register number)

:‫فً حالة التطبٍق المستخذم‬

‫ ْٕ انًضتخذو فقط‬15 ‫ رقى‬base register ٌ‫ َجذ أ‬-

‫تى‬ٚ ‫ ٔانذ٘ يٍ خالنٓى‬Symbol Relative ‫حتٕ٘ عهٗ انعُٕاٌ نهـ‬ٚ ST ٌ‫ث أ‬ٛ‫ ح‬-

.‫خ انجزَبيج‬ٚ‫ذ ثذا‬ٚ‫تحذ‬

4
base ‫ختبر‬ٛ‫ ن‬BT ‫ضتخذو جذٔل‬ٚ assembler ٌ‫ٍ عٍ ٔاٌ فإ‬ٕٚ‫تى تك‬ٚ ‫ عُذيب‬-

‫ُئذ‬ٛ‫ ح‬symbolic reference ‫ًخ أقزة نهـ‬ٛ‫حتٕ٘ عهٗ ق‬ٚ ‫ انذٖ صٕف‬register

:ٌٕ‫ك‬ٚٔ ‫جٓز‬ٚ address

Base register number = the base register containing a value closest to the

symbolic reference.

Offset = value of symbol in ST – contents of base register

ٍ‫ ثذالً ي‬Literals ّ‫ث تحفظ ث‬ٛ‫ ح‬،ST ‫ ْٕ جذٔل يًبثم نجذٔل‬Literal Table (LT)

.Symbols

The following assembly program is used to illustrate the use of the

variable tables (ST, LT, and BT) and to describe the motivation for

the algorithms presented in the next section. We are only concerned

with the problem of assembling this program; its specific function is

irrelevant.

5
6
In the pass 1, symbols and literals are defined. So, the symbol and

literal tables are created below.

‫كٌٕ عُٕآَب يحذد‬ٚ ٙ‫ ثزَبيج األصًجه‬ٙ‫ ف‬َٙ‫) ثبنعًٕد انثب‬Absolute Symbols( ٌ‫ٌجذ أ‬

.AC, INDEX, TOTAL, DATABASE :‫ ْى‬Symbols ِ‫ ْٔذ‬.‫كًب ثبنعًٕد انزاثع‬

.2, 3, 4, 13 :‫ت‬ٛ‫ُٓى ْى عهٗ انتزت‬ٚٔ‫ٔعُب‬

:ٙ‫ه‬ٚ ‫) ْى كًب‬Relative Symbols( ‫بٍنما‬

PRGAM2, SETUP, LOOP, SAVE, DATAAREA, DATA1

.LT ‫ جذٔل‬ٙ‫ ف‬LITERALS ‫ٍ كم‬ٕٚ‫تى تك‬ٚ ‫ثبنًثم‬

You might also like