Workshop Assembler


Published on

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Workshop Assembler

  1. 1. Lokmanya Tilak Jan Kalyan Shikshan Sanshtha’sWorkshop on“Improving Teaching Competencies”<br />Lecture on the Topic:<br />System Programming:Assembler<br />Presented BY :<br />Manoj S. Chaudhari<br />Smt. Bhagwati Charturvedi College of Engg.<br />
  2. 2. Aim of the Lecture:<br /> To Study <br /> Assembler<br />Structure of Assembly Language Program(ALP)<br />Steps to Translate ALP to Machine Language Program<br />Data Structure/Tables used by the assembler<br />Two pass assembler<br />Pass 1 Assembler <br />Pass 2 Assembler<br />
  3. 3. Assembler:<br />System Programs:<br /> Job is done more efficiently.<br /> Executes the programs effectively.<br /> e.g. Compiler , Interpreter<br /><ul><li>Assembler:</li></ul> A system program which translate ALP into <br />its equivalent machine language.<br /> It is basically a translator.<br />
  4. 4. Structure of Assembly Language Program: <br />ALP is a sequence of Assembly language statement.<br />Each Assembly language statement consist of 4 fields:<br /> Label<br /> Opcode <br /> Operand<br /> Comment<br />Consider the Assembly Language Statement:<br /> Loop MVI B, 05H ; move data 05H to register B<br /> Label Opcode Operand Comment<br />
  5. 5. Two Types of Opcodes:<br /> 1.Pseudo- opcode <br /> 2.Machine Opcode <br /><ul><li>Pseudo-Opcode</li></ul>e.g. USING , DC, DS<br /><ul><li>Machine Opcode</li></ul>e.g. ADD, MVI , DCR<br />Types of Opcodes:<br />
  6. 6. Steps for Translating an ALP to Machine Language Code<br />Translation is statement by statement basis .<br />Read the assembly language statement and separate all the fields. <br />Verify whether opcode is Machine opcode or Pseudo opcode.<br />If Pseudo opcode , check the type of Pseudo opcode.<br />If Machine opcode , obtain information about binary code , format and length of instruction.<br />Process the operands.<br />Increment the value of counter by length of the instruction.<br />
  7. 7. Data Structure/Tables used by Assembler:<br />Following are the tables used by the assembler.<br /> 1) Machine Opcode Table (MOT)<br /> 2)Pseudo Opcode Table (POT)<br /> 3)Symbol Table (ST)<br /> 4)Base Register Table (BRT)<br /> 5)Literal Table (LT) <br />
  8. 8. 1)Machine Opcode Table<br />The table consist of the fields: Name of mnemonic i.e. machine opcode, equiv. byte opcode, format of instruction and length of instruction.<br />
  9. 9. 2)Pseudo Opcode Table(POT)<br />This table consist of the fields :<br /> Name of Pseudo opcode<br /> Routine associated with the Pseudo Opcode<br />
  10. 10. 3)Symbol Table(ST)<br />The symbol table keeps track of the symbols used in the ALP . It has the following fields .<br /> Name of symbol <br /> Value of symbol<br /> Type of symbol<br />
  11. 11. 4)Base Register Table<br />This table keeps the track of registers which are used as base register.<br />The table has the following format.<br />
  12. 12. 5)Literal Table<br />The literal table keep list of all the literals used in the program.<br />The table has the following format.<br />
  13. 13. Two Pass Assembler<br />The entire process of translating an ALP to its equivalent machine language code is divided into two passes.<br /> 1) Pass 1 Assembler.<br /> 2)Pass 2 Assembler.<br />
  14. 14. Pass 1 Assembler<br />The function of Pass 1 Assembler is :<br /><ul><li>To define and compute the value of symbols .
  15. 15. Assigning and storing the addresses to literals.</li></ul> So output of pass 1 is Symbol table and Literal table.<br />Processing of Pass 1 with :<br /><ul><li>Pseudo- opcodes:</li></ul>1)USING and DROP: No processing is done.<br />2)EQU: Processed for evaluation of operands.<br />
  16. 16. Contd…..<br />3)DC/DS: Processed for the allocation of storage and LC is updated.<br />4)START: LC is incremented by the value of the operand.<br />5)LTORG: Storage is assigned from the start of the program or from previous LTORG.<br />6)END : Assembler allocates all the literals before going for pass 2.<br /><ul><li>Machine Opcode: </li></ul> Get the length of instruction . If label/literal is present enter it in LT/ST and increment LC .<br />
  17. 17. Pass 1 Data Bases:<br />1)Input Source Program<br />2) LC : Used to keep track of each instruction.<br />3) MOT :Indicates Symbolic mnemonic for each instruction and its length.<br />4)POT: Indicates Symbolic mnemonic and action to be taken for each Pseudo Opcode.<br />5)ST: Store each label and its value.<br />6)LT: Store each literal and its corresponding location.<br />7)A Copy of input later used by pass2 <br />
  18. 18. Pass 1 Assembler Flow Chart:<br />USING DROP<br />Found<br />DC/DS <br />not found EQU END <br />Pass 1<br />LC0<br />A<br />Read ALS<br />X<br />SearchPOT?<br />Type of Pseudo Opcode<br />Adjust LC to Proper Alignment <br />E<br />Search MOT<br />Eval Operand field<br />B<br />C<br />D<br />
  19. 19. yes<br /> no <br />B<br />C<br />D<br />E<br />Llength<br />LLength of data field<br />Assign value to symbol in Label field<br />Assign Storage Location to Literals<br />Process Literals ,Enter in LT<br />Onto Pass 2<br />Any Symbol?<br />Assign Current value of LC to Symbol <br />LC=LC+L<br />A<br />Write ALS on file for Use by Pass 2<br />X<br />
  20. 20. References:<br />Textbook :<br />1)“System Programming”, By J.J. Donovan.<br />2)”System programming and Operating system”, By D. M. Dhadhere.<br />3)”Concepts of Compiler design “,By Adesh K Pandey.<br />