SAFFRONY INSTITUTE OF TECHNOLOGY TECHNOLOGY 2150708 – System Programming (SP) Assembler Q. 1 Describe elements of Assemb f Assembly language. assembly y lang anguag uage provid rovides es three basi asic feat features: ures: ü An assembl 1. Mnemoni Mnemonics op operati eration on cod codes 2. Symb Symbolic lic op operand erands 3.
Dat Data decl eclarati aration on
Let us consid consider er an assembl assembly y inst nstructi ruction on ü Let M!"# A "# A#"$ #"$,,% •
MOVER i ER is a mnemoni mnemon ic op opcod code for the op operati eration on to be performed erformed.
regis ster op operand erand in a symb symbolic lic form. • AREG is a regi •
X is a memory op o perand erand in a symb symbolic lic form.
ü Let Let us consid consider er anot another inst nstructi ruction on for data decl eclarati aration on % DS 1
Q. 2
•
DS&&Decl DS Declare st storag orage' reserves area of memory.
•
(ame of vari variable ble is %
•
)t reserves a memory area of 1 *ord ord and and associ associates the name % *ith *ith it
Explain types of Assemb f Assembly statement 1 !mp er at i#e statem en erati ent
erative ve st s tatement ement indica dicattes an acti action on to be performed erformed duri uring the e+ecuti e+ecution on of the ü An imperati assembl assemble ed st statement ement. erative ve st statement emen t typica y transl ranslates into one machi machine inst nstructi ruction. on. ü "ach imperati picall lly e+ecutable ble st statement ements. ü ,hese are e+ecut e+ample e of imperati erative ve st statement emen t are given given belo* ü Some e+ampl M!"# "# -#"$ #"$,,% S, #"AD #"AD % #) #)(, / ADD A#"$ A#"$,,0 2 Declaration statemen me nt
Declarati aration on st statement ements are for reservi reserving memory for vari var iables. ü Decl bles. ü ,he synt synta+ of decl eclarati aration on st statement ement is as foll follo o*: Label Lab
DS
Label Lab
D
constant5 ant5 4const 64 64val value5 ue57
ü DS DS:: st stand ands for Decl Declare st storag orage8 D: D: s sttand ands for Decl Declare const constant ant. ü ,he DS st statement ement reserves area of memory and an d associ associates name *ith *ith them. A DS 19 ü Above st statement emen t reserves 19 *ord ord of memory for vari variable ble A. D st statement ement const construct ructs memory *ord ords cont containing const constant ants. ü ,he D (" D (" D 617 statement emen t associ associates the name (" *ith ord cont containing the val value 617 ü Above st *ith a memory *ord
Prepared
By: T!"S P"T#
Page 1
Prepared
By: T!"S P"T#
Page 1
SAFFRONY INSTITUTE OF TECHNOLOGY 2150708 – System Programming (SP) Assembler assembly y prog rogram can use const constant ant in t*o t*o *ays$ as immedi mmedia ate operand erands8 and and as ü Any assembl litera literalls. ü Many machi machine supp suppor ortt immedi mmedia ate op operand erands in machi machine inst nstructi ruction on.. "+: ADD A#"$ A#"$,, : -ut hyp hy potheti hetica call machi machine does not not supp su ppor ortt immedi mmedia ate op o perand erands as a part art of the machi machine ü -ut nstructi ruction. on. )t )t can still still han handl e litera inst dle literalls. ü A litera literall is an op operand erand *ith *ith the synt synta+; a+;7 4val value5 ue57. "%: ADD "%: ADD A#"$ A#"$,,;7:7 ü )t differs differs from const constant ant because its its locati ocation on cannot cannot be sp speci ecif ied in assembl assembly y prog rogram. $ Assembler Directi#e
Assembler er direc ves inst nstruct ruct the assembl assembler er to perform cert certain acti ac tion on duri uring the assembl assembly y ü Assembl directi tives rogram. prog !.
%&AR & directi tive ve indica dicattes that hat f irst rst *ord ord of machi machine should should be place placed d in the memory ü ,his direc *ord ord *ith *ith add address ress 4const constant5 ant5.. 4onsttant5 ant5 ü ü S,A#, 4ons S,A#, :90 :90 "+: S, ü
!!. !!.
E'D ve indica end of the source prog rogram. ü ,his direc directi tive dicattes end erand indica dicattes address ddress of the inst nstructi ruction on *here the e+ecuti e+ecution on of prog rogram ü ,he operand should should begin. gin. efault it is f irst rst inst nstructi ruction on of the prog rogram. ü ü -y default "(D "(D 4operand erand 25 25 +ecution on cont control rol should should transfer to label given given in op operand erand f ield. ld. ü "+ecuti
!!!. !!!.
OR !G!' ü ,his direc directi tive ve is li=e li=e S,A#, inst nstructi ruction8 on8 *hich indica dicattes address ddress of the ne+t ne+t consecuti consecutive ve inst nstructi ruction on or data. ü
S,A#, 199 #, 199
2
L
M!"# "# -#"$; #"$;7727
100
3
M!"# A "# A#"$ #"$,,(
101
>
ADD A#"$;7 #"$;717
102
:
#) #)$)( L L
? !V. !V.
)*
A(/8L 8L ("%, ("%, - A(/
100
EQ( ve simply associate the name 4symb symbol5 *ith erand5..*here ü ,his direc directi tive ply associ *ith 4operand5 erand5 may may be const constant ant or symb sym bol. 4operand5
Prepared By: T!"S P"T#
Page 2
SAFFRONY INSTITUTE OF TECHNOLOGY 2150708 – System Programming (SP) Assembler ü 4symbol5 "@ 4operand25 ü "+: A
"@ -
ü Address of - is assigned to A in symbol table. V.
)&ORG ü ,his directive allocates memory to all literals of current pool and update literal table8 pool table. ü
Q. $
Explain assembly sc+eme.
OR
Explain analysis an, synt+esis p+ases of an assembler by clearly stating t+eir tas-s. OR Design specif ication of an assembler. Analysis .+ase ü ,he primary function performed by the analysis phase is the building of the symbol table. ü
)f a label is present, enter the pair &symbol, 4L content5' in a ne* entry of symbol table.
Sourcepr og.
3.
hec= validity of mnemonics opcode.
>.
erform L processing. mnemonics
opcode
length
ADD
91
1
S-
92
1
Analysis phase
Synthesis phase
,arget prog.
symbol
address
A$A)(
10>
(
113 Symbol table
Prepared
By: T!"S P"T#
Page %