// Tab Setting = 4
 Ŀ
                           Assembler designing                             
 



           Software Laboratory - II ( System Programming )
         




								X Assembler
                                
                                
                  Ŀ    
                       1. Problem Definition        
                       2. Program Specifications    
                       3. Assumptions               
                       4. Machine architecture      
                       5. Syntax of assembly        
                       6. Data structures           
                       7. Algorithm                 
                  


 1. Problem Definition :
    
    

		Design an assembler for hypothetical assembly language.


 2. Program Specifications :
    
    

		X assembler is a two pass assembler.

		PASS I  :-  Analysis phase of assembler
        -      

			  *		Input  : .asm source code file
                    -

			  *		Output : Symbol Table containing information about
                    -   all symbols used within the program

			  *				 Literal table containing information about
							 all the literals used in the program


		PASS II :-  Synthesis phase of assembler
                  

			  *		Input  : Error free .asm source code file
                    -

			  *		Output : Object file(.obj) which is binary file containing
                    -   object code.
							 Listing file(.lst) which is readable file
							 which consists of Object code,symbol table
							 and literal table.

			  *		Before going to PASS II it is assumed that all the errors
					in the Source assembly language program have been removed.

			  *		Opcodes corresponding to the assembly language
					instructions and the addresses of the operands are
					written in object code file (.obj).
					Listing file (.lst) is also created which contains the
					readable object code,Symbol table and literal table.

			  *		Since data segment preceeds code segment,forward reference
					is not needed.Hence,intermediate code is same as final
					code.


 3. Assumptions     :
    
   

		While designing the assembler few assumptions regarding the structure
		of assembly language program have been made.They are as follows.

		<a>. There is only one Data Segment and only one Code Segment in the
			 program.

		<b>. Whatever data you want to declare, must be declared in Data Segment
			 only.Declaration of data elewhere in the program will produce
			 an errror.

		<c>. All the instructions must be written in Code Segment only.

		<d>. END directive is used to close the Code Segment.

		<e>. Start of Code Segment will automatically close the Data Segment

		<f>. Single line comments are allowed. To put a comment in your program
			 just put ';' before the text. Entire statement after ';' will be
			 considered as comment.

		<g>. Use of literals ie permitted. Any number of literals can be used
			 in the program. Every valid literal must contain '@' as its first
			 character followed by one or more digits.


 4. Machine Architecture :
    
   

   *	We consider an hypothetical model of computer in order to apreciate
		the functions of assembler.

   *	The hypothetical model of a computer is assumed to have a single
		register and it is called accumulator.

   *	The machine has a very small instruction set which consists of
		simple instructions of data transfer, arithmatic.
		It also has small set of directives.

   *	There are total 12 instructions and 6 directives used in this
		hypothetical assembly language.


 5. Syntax of Assembly :
    
    

			On command prompt type xasm -? to get HELP.

			A complete help on the instruction set and the directives is
			provided.

			HELP also provides the meanings of Error messages which may be
			displayed during program assembly.


 6. Data Structures :
    
    

              I. Input source program

             II. A location Counter (LC), used to keep track of each
                 instruction's location.

            III. A tble,the Machine-Opcode Table (MOT), that indicates
                 the symbolic mnemonic  for each instruction and length
                 (two,four or six bytes).

             IV. A table, the Pseudo-Operation Table (POT), that indicates
                 the symbolic mnemonic and action to be taken for each
                 pseodo-op in PASS I.

              V. A table,the Symbol Table (ST),that is used to storeeach
                 label and its corresponding value.

             VI. A table,the Literal Table (LT),that is used to store each
                 literal encountered and its corresponding assigned location.

            VII. A table,the Procedure Table(PROCTABLE),which keeps track
                 of all the procedures defined within the program.


 7. Algorithm :
    
    

            I. In the first PASS the input assembly language program is
			   scanned completely and errors (if any) are displayed.

           II. All the valid symbols encountered within the program
			   are placed in the symbol table(ST) which is used in PASS II.

          III. When the errors are removed the program control flows to
			   PASS II.

           IV. In PASS II error free program is scanned again and every
			   instruction and its operands(if any) are given addresses.

            V. Binary output file (.obj) is created.Readbale file (.lst)
			   file is created which consists of detailed information
			   regarding Symbols,literals and procedures used within
			   the program.



                                
							  End of readme.txt
                              
                              
